List Info

Thread: Re: How to set PDF-Export Options via API?




Re: How to set PDF-Export Options via API?
user name
2007-10-23 23:50:59
Hi André,

the problem is that these filter specific properties are not
documented. 
Well i would like to see some kind of documentation for all
filters but 
that is different story.

I have collected additional properties from the sources but
can't find 
it at the moment. I have to search again later and i promise
that i will 
create wiki page 

Anyway you can set additional filter properties this way:

########
public static void main(String[] args) {
   try {
     // get the remote office component context
     XComponentContext xContext = Bootstrap.bootstrap();

     XMultiComponentFactory xMCF =
xContext.getServiceManager();

     XComponentLoader xLoader = (XComponentLoader)
       UnoRuntime.queryInterface(XComponentLoader.class,

     xMCF.createInstanceWithContext(
       "com.sun.star.frame.Desktop", xContext));

     XTextDocument xDoc =
(XTextDocument)UnoRuntime.queryInterface(
       XTextDocument.class, xLoader.loadComponentFromURL(
         "private:factory/swriter",
"_blank", 0, new PropertyValue[0])); 


     xDoc.getText().setString("A simple PDF export
test");

// !!!! important code here
     PropertyValue[] pdfprops = new PropertyValue[3];
     pdfprops[0] = new PropertyValue();
     pdfprops[0].Name = "UseTaggedPDF";
     pdfprops[0].Value = new Boolean(true);
// well i haven't tested ExportBookmarks and
ExportFormFields but i 
assume that they are boolean props too
     pdfprops[1] = new PropertyValue();
     pdfprops[1].Name = "ExportBookmarks";
     pdfprops[1].Value = new Boolean(true);
     pdfprops[2] = new PropertyValue();
     pdfprops[2].Name = "ExportFormFields";
     pdfprops[2].Value = new Boolean(true);

     PropertyValue[] props = new PropertyValue[2];
     props[0] = new PropertyValue();
     props[0].Name = "FilterName";
     props[0].Value = "writer_pdf_Export";
     props[1] = new PropertyValue();
     props[1].Name = "FilterData";
     props[1].Value = pdfprops;


     XStorable xStorable =
(XStorable)UnoRuntime.queryInterface(
       XStorable.class, xDoc);
    
xStorable.storeToURL("file:///export/TaggedPDFExport.pd
f", props);

    XCloseable xCloseable =
(XCloseable)UnoRuntime.queryInterface(
      XCloseable.class, xDoc);
    xCloseable.close(false);
  } catch (java.lang.Exception e){
    e.printStackTrace();
  }
  finally {
    System.exit( 0 );
  }
}
########

André Schnabel wrote:
> Hi,
> 
> I working on a little tool to export documents to PDF
using OOo-API 
> (based on the java file exporter example - my first
attemt in OOo 
> programming).
> 
> Works quite well, but I'd like to set enhanced  export
properties like  
> ExportBookmarks or  ExportFormFields. I didn't find
information about 
> that in the SDK. Can anybody give me a int, how to set
these options?
> 
> Thanks in advance,
> 
> André
> 
>
------------------------------------------------------------
---------
> To unsubscribe, e-mail: dev-unsubscribeapi.openoffice.org
> For additional commands, e-mail: dev-helpapi.openoffice.org
> 

------------------------------------------------------------
---------
To unsubscribe, e-mail: dev-unsubscribeapi.openoffice.org
For additional commands, e-mail: dev-helpapi.openoffice.org


[1]

about | contact  Other archives ( Real Estate discussion Medical topics )