Joined: 27 Sep 2006
|Posted: Tue Oct 03, 2006 3:03 am Post subject: Exporting PS/EPS with UNO/Python
my problem is the following: I want to export the pages of an .sxd file automatically to EPS/PDF. As a starting base, I got a Python script from a collegue exporting the document into Postscript. Another Python script then extract the single pages and named them according to the information in the XML files.
Surely, this is not the optimal way, but it works.
Now, I needed some improvements like...
(1) automatically convert certain colors into grayscales or replaced them by hatches if used as filling colors.
(2) exporting it as a grayscale image
(1) works fine, but (2) makes problems:
propTuple = (OOoLib.createPropertyValue("FileName", cTargetURL), OOoLib.createPropertyValue("PrintQuality", ???)
=> PrintQuality not responsible for Color/Grayscale?
Then I tried to add another printer using only Grayscale by copying the default printer in psprint.conf and customizing it. The funny thing is that I really get grayscale, but it exports only in portrait mode, although drawn in landscape mode. Even if a change this in psprint.conf, this does not help. Btw: The default printer uses portrait mode and can make it, however.
My code to change the printer looks as follows (I tried to select the new printer by the PrinterName property during exporting, but this did not work...):
printer = oDoc.getPrinter
for prop in printer:
if prop.Name == "Name":
prop.Value = "uno_grayscale" <= the new printer
Is there any solution?
My favourite solution would be to export the single pages directly into EPS instead exporting one multi-page PS document. From my point of view, this strategy used by the original script I got, is responsible for the problems.
So I tried to export the pages into EPS (but again without success)
I also considered: http://www.oooforum.org/forum/viewtopic.phtml?t=6769
but this did not help.
Here again my code:
oGraphic = OOoLib.createUnoService('uno.sun.star.drawing.GraphicExportFilter')
filterData = (OOoLib.createPropertyValue('Level', 2), OOoLib.createPropertyValue('ColorFormat', 2), OOoLib.createPropertyValue('TextMode', 1), OOoLib.createPropertyValue('Preview', 0), OOoLib.createPropertyValue('CompressionMode', 2))
oGraphic.setSourceDocument(xPage) <== the current page as as a collection of shapes
argsExport = (OOoLib.createPropertyValue('URL', cExportURL, OOoLib.createPropertyValue('MediaType', 'application/postscript'), OOoLib.createPropertyValue('FilterData', filterData))
=> The problem is that I get an EPS file with binary data before the postscript code, although I turned compression off. I also tried other parameter combinations and it seems that the properties have no effect!?
And: I can view the file with kghostview, but not include it into a latex document.
Thank you very much in advance!