Hi guys
this script i downloaded from here, http://win32com.goermezer.de/index.p...193&Itemid=274
I copied this script and setup and instance of open office writer.
created a .doc file and a copied it making a change to that file.
here is the code -
#This script compares two Word documents with OpenOffice via the PyUNO Bridge and shows the differents in PDF file.
-
#The PDF result is the original Word document with highlighted diffs. This script came from
-
#http://mithrandr.moria.org/blog/447.html.
-
-
#Before you run this script in the OpenOffice program directory with the python.bat you should start OpenOffice in server
-
#mode like:
-
-
#soffice -headless -invisible '-accept=socket,host=localhost,port=2002;urp;
-
-
#!/usr/bin/env python
-
-
-
-
import uno
-
import socket
-
-
from com.sun.star.beans import PropertyValue
-
from com.sun.star.task import ErrorCodeIOException
-
-
url = uno.systemPathToFileUrl('c:\\OpenOffice_24\\program\\kn2.doc')
-
url_original = uno.systemPathToFileUrl('c:\\OpenOffice_24\\program\\kn.doc')
-
url_save = uno.systemPathToFileUrl('c:\\OpenOffice_24\\program\\kn_diff.pdf')
-
-
### Get Service Manager
-
context = uno.getComponentContext()
-
resolver = context.ServiceManager.createInstanceWithContext("com.sun.star.bridge.UnoUrlResolver", context)
-
ctx = resolver.resolve("uno:socket,host=localhost,port=2002;urp;StarOffice.ComponentContext")
-
smgr = ctx.ServiceManager
-
-
### Load document
-
properties = []
-
p = PropertyValue()
-
p.Name = "Hidden"
-
p.Value = True
-
properties.append(p)
-
properties = tuple(properties)
-
desktop = smgr.createInstanceWithContext("com.sun.star.frame.Desktop", ctx)
-
doc = desktop.loadComponentFromURL(url, "_blank", 0, properties)
-
-
### Compare with original document
-
properties = []
-
p = PropertyValue()
-
p.Name = "URL"
-
p.Value = url_original
-
properties.append(p)
-
properties = tuple(properties)
-
dispatch_helper = smgr.createInstanceWithContext("com.sun.star.frame.DispatchHelper", ctx)
-
dispatch_helper.executeDispatch(doc.getCurrentController().getFrame(), ".uno:CompareDocuments", "", 0, properties)
-
-
### Save File
-
properties = []
-
p = PropertyValue()
-
p.Name = "Overwrite"
-
p.Value = True
-
properties.append(p)
-
p = PropertyValue()
-
p.Name = "FilterName"
-
p.Value = 'writer_pdf_Export'
-
properties.append(p)
-
properties = tuple(properties)
-
try:
-
doc.storeAsURL(url_save, properties)
-
except ErrorCodeIOException, e:
-
import sys
-
import traceback
-
import cStringIO
-
(exc_type, exc_value, tb) = sys.exc_info()
-
error_file = cStringIO.StringIO()
-
traceback.print_exception(exc_type, exc_value, tb,
-
file=error_file)
-
stacktrace=error_file.getvalue()
-
print "Failed while writing: '%s'" % url_save
-
print stacktrace
-
doc.dispose()
-
why does it fail while writing pdf? on : - doc.storeAsURL(url_save, properties)
Thank you so much
1 4381
okay found out.
This line -
doc.storeAsURL(url_save, properties)
-
needs to be changed to: -
doc.storeToURL(url_save, properties)
-
All the best
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Ryan |
last post by:
PowerPoint.Application cannot open PPT file
I am trying to use the following code using to open a PPT file using VS.NET 2003 and PowerPoint 2003
Option Strict Off
Imports System.Runtime.InteropServices
Imports Microsoft.Office.Interop
Imports Microsoft.Office.Interop.PowerPoint
Imports Microsoft.Office.Core
Imports...
|
by: Tom Weston |
last post by:
Help
I have 4 databases containing different data relating to safety, not written
by me. It is not possible to merge the databases into one large data base. I
would like to create a user interface with 4 buttons, one for each database.
The aim would be for the user to click on a button and the related database
opens for use. When the database...
|
by: M Fisher |
last post by:
I have an Access XP Database. On one of the forms I have a button that
opens and Excel Spreadsheet as follows:
Dim xl As Excel.Application
Set xl = New Excel.Application
xl.Application.Workbooks.Add
xl.Cells(1,1) = "Some Text From the database"
etc.
|
by: Java script Dude |
last post by:
For those who are missing the feature on how to import into Open Office
dBase app from text files and spreadsheets in OOO Base 2.0:
A wizard exists to import from spreadsheets only at this time but there
is no menu pick for `importing` at this time.
OOO 2.0 dBase Import SOP:
1) Open the spreadsheet -or- text file as a spreadsheet
2)...
|
by: sudha |
last post by:
Hi,
To open a word doc from c#, i use the following code :
Word.ApplicationClass WordApp = new Word.ApplicationClass
();
// give any file name of your
choice.
object fileName = "C:\\test.doc";
object readOnly = false;
| |
by: Richard Cleaveland |
last post by:
A client has just successfully upgraded from Access 97 to 2000. I don't
have Access 2000, but I do have Office XP. Can I successfully use my Access
on their database? They kind of did this behind my back, and I'm responsible
for the application maintenance...!
Dick
|
by: bkdraper via AccessMonster.com |
last post by:
I currently have a handful of Access 2000 tools I've written for my office.
Here in the next few weeks, the office is getting upgraded to Office 2007.
My question is, does anybody know how much trouble my Access 2000 tools are
going to have running on Access 2007? Am I going to have to rewrite all my
code (or half, or 1/3 of my code) or...
|
by: TBass |
last post by:
Hi,
For years, I've been using visual basic and the Excel Object library
version 9 and 10 to pass data back and forth between Visual Basic and
Microsoft Excel. A few months ago, we changed over to Visual
Basic .NET 2003. After converting the project, I dropped in my code
from from the vb6 days, did a few slight modifications, refereneced...
|
by: saketmayur |
last post by:
Hi ,
I have write the following code to open word document on server
using Microsoft.Office.Interop.Word;
string DocPath = System.Configuration.ConfigurationManager.AppSettings;
ApplicationClass wordApp = new ApplicationClass();
string filePath = "";
filePath = DocPath + Session + "/" +...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it. ...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |