Apache OpenOffice (AOO) Bugzilla – Issue 119417
Problems with PDF export using FilterData (VB-Script using COM interface)
Last modified: 2013-02-24 21:08:38 UTC
Created attachment 77598 [details] Windows VBS script The problem is related to PDF export using COM Bridge on Windows: I am trying to export a doc file to PDF. Basically, the export works fine but thenone of FilterData properies take effect. Using the same code as an OpenOffice Macro works fine. VBS Script ---------- I am executing the following VB script (see attached vbs file) on a Wndows XP PC with Apache OpenOffice 3.4: ========================================================================================= Set oSM = CreateObject("com.sun.star.ServiceManager") Set oDesk = oSM.createInstance("com.sun.star.frame.Desktop") Dim OpenParam(0) Set OpenParam(0) = MakePropertyValue(oSM, "Hidden", false) Set oDoc = oDesk.loadComponentFromURL("file:///c:/test.odt", "_blank", 0, OpenParam) ' Save the document using a filter. Dim SaveFilter(0) Dim SaveOptions(1) Set SaveFilter(0) = MakePropertyValue(oSM, "PageRange", "1" ) Set SaveOptions(0)= MakePropertyValue(oSM, "FilterName", "writer_pdf_Export" ) Set SaveOptions(1)= MakePropertyValue(oSM, "FilterData", SaveFilter ) Call oDoc.storeToURL( "file:///c:/test.pdf", SaveOptions) Call oDoc.close( false ) Function MakePropertyValue(oServiceManager, cName, uValue) Dim oPropertyValue Set oPropertyValue = oServiceManager.Bridge_GetStruct("com.sun.star.beans.PropertyValue") oPropertyValue.Name = cName oPropertyValue.Value = uValue Set MakePropertyValue = oPropertyValue End Function ========================================================================================= The problem is, that the FiltaData property does not take effect - all pages are exported as PDF even though I set the "PageRange" property to "1". I tested some other properties, like "MaxImageResolution" or security related ones like "EncryptFile" and "DocumentOpenPassword" with no success. It seems that none of these work. OpenOffice Macro ----------------- I made the same code as a Macro within OpenOffice and it works fine and the FilterData works: ================================================================ Sub Main Dim OpenParam(0) Set OpenParam(0)=MakePropertyValue( "Hidden", false ) oDoc = StarDesktop.loadComponentFromURL( "file:///c:/test.odt", "_blank", 0,OpenParam ) ' Save the document using a filter. Dim SaveFilter(0) Dim SaveOptions(1) Set SaveFilter(0) = MakePropertyValue( "PageRange", "1" ) Set SaveOptions(0)= MakePropertyValue( "FilterName", "writer_pdf_Export" ) Set SaveOptions(1)= MakePropertyValue( "FilterData", SaveFilter ) oDoc.storeToURL( "file:///c:/test.pdf", SaveOptions) oDoc.close( false ) End Sub Function MakePropertyValue( Optional cName As String, Optional uValue ) As com.sun.star.beans.PropertyValue Dim oPropertyValue As New com.sun.star.beans.PropertyValue oPropertyValue.Name = cName oPropertyValue.Value = uValue MakePropertyValue() = oPropertyValue End Function ================================================================ It looks like the COM interface does not work as expected.
This is a subtlety of COM bridge. You have to specify explicitly that SaveFilter is an array of com.sun.star.beans.PropertyValue. See thread [Solved] [PHP] Problem to export PDF /A with puno http://user.services.openoffice.org/en/forum/viewtopic.php?f=44&t=36163 Your code should work with these changes: Dim unoWrap Set unoWrap = oSM.Bridge_GetValueObject unoWrap.set "[]com.sun.star.beans.PropertyValue", SaveFilter Set SaveOptions(1)= MakePropertyValue(oSM, "FilterData", unoWrap)
Yes, this fixed the issue. Thanks