Hello
I use open office to convert MS Word files to PDF documents. This is
basically done with the methods, I found in the Code Snippet Base
http://codesnippets.services.openoffice.org/Office/Office.ConvertDocumen
ts.snip
Now I also want to add a watermark to the pdf file, to indicate that it
is a copy of another document. My idea was just to add a background
image to the MS Word file, before converting it to pdf. I do this with
the following method (also mainly taken out of the Code Snippet Base).
private static void addWatermark(XComponent xDocument, XComponentContext
xRemoteContext) throws Exception {
XTextDocument oDoc = (XTextDocument)
UnoRuntime.queryInterface(XTextDocument.class, xDocument);
// create a supplier to get the Style family collection
XStyleFamiliesSupplier xSupplier = ( XStyleFamiliesSupplier )
UnoRuntime.queryInterface(XStyleFamiliesSupplier.class, oDoc);
// get the NameAccess interface from the Style family collection
XNameAccess xNameAccess = xSupplier.getStyleFamilies();
XNameContainer xPageStyleCollection = (XNameContainer)
UnoRuntime.queryInterface(XNameContainer.class, xNameAccess.getByName(
"PageStyles" ));
// create a PropertySet to set the properties for the new Pagestyle
XPropertySet xPropertySet = (XPropertySet)
UnoRuntime.queryInterface(XPropertySet.class,
xPageStyleCollection.getByName("Standard") );
xPropertySet.setPropertyValue("BackGraphicURL",
createUNOFileURL("watermark.jpg", xRemoteContext));
}
But this method does not always add a background image to the file. I
did not find any pattern, when an image is put on the page and when not.
Also if the file is longer than one page, there is never a background
image on the first page, but only on the following pages.
Thanks for any help that can solve these problems
Robert
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]