![]() You must be aware of the fact that they are implementation specific, so you may not find all of them in previous versions (nor expect that they remain the same in the future). The following tables contain all the properties available in the PDF export filter implementation since 2.4 up to 3.2. In the next section, we will describe the complete list of specific properties available at the present for the PDF export filter. In the case of the PDF export filter, another array of PropertyValue structs is expected. This parameter is used to pass properties specific for a special filter type. ![]() You can fully customize the PDF export process by adding another PropertyValue struct to the MediaDescriptor array: FilterData. In this case, it includes only the struct for the FilterName, indicating the name of the filter for exporting Writer documents to PDF. The media descriptor is used for loading/importing and saving/exporting documents, please refer to the Developer's Guide for a detailed explanation. storeToURL (sURL, aMediaDescriptor ) Īs the code shows, XStorable.storeToURL() expects an URL as first parameter, and an array of .PropertyValue structs as second parameter, which implements the .MediaDescriptor service, consisting of property definitions. ![]() PropertyValue aMediaDescriptor = new PropertyValue ĪMediaDescriptor = new PropertyValue ( ) ĪMediaDescriptor. getHomeDir (m_xContext ) + "/Simple_PDF_EXPORT_demo.pdf" // Exporting to PDF consists of giving the proper // filter name in the property "FilterName" // With only this, the document will be exported // using the existing PDF export settings // (the one used the last time, or the default if the first time) class, xComponent ) // XStorable.storeToURL() expects an URL telling where to store the document // and an array of PropertyValue indicating how to store it // URL = use helper method to get the home directory String sURL = Helper. XStorable xStorable = (XStorable ) UnoRuntime. setString ( "Simple PDF export demo." ) // XStorable to store the document class, xComponent ) // access the text body and set a string XTextDocument xTextDocument = (XTextDocument ) UnoRuntime. createNewDoc (m_xContext, "swriter" ) // access its XTextDocument interface XComponent xComponent = null // create a new Writer document using a helper The following code shows the basic procedure: In the simplest case, all you need for exporting to PDF is the URL where you want to export the document and the filter name this way, the document will be exported using the current PDF export settings (the ones used the last time, or the default values stipulated by the filter configuration, if this is first time). The property needed for this purpose is the string argument FilterName that takes the name of a filter already known by Apache OpenOffice. In the API, documents are storable through their interface .XStorable, as discussed in detail in Developer's Guide - Office Development - Storing Documents.įor exporting, besides the location (in URL notation) where the exported document is to be stored, a filter name must be passed to XStorable.storeAsURL() and XStorable.storeToURL(). They are not intended to provide a ready-to-use PDF export application, but to give you a tool for doing your own experiments.Ī document can be exported by saving it to a different location and using a special filter capable to write the document to the desired format. The sources for this tutorial can be found here. This tutorial also aims to provide a full up-to-date documentation about the PDF export filter options, as these specific properties are usually not documented and only available in the core Apache OpenOffice source code (thus not accessible for developers aiming to work only with its API). The reader should have at least a basic knowledge about handling office documents (how to load and store a document), and should also know how to access Apache OpenOffice configuration. This tutorial will show how to use Apache OpenOffice API to export documents to PDF. PDF export is an important and useful feature of Apache OpenOffice that can completely be automatized using Apache OpenOffice API, quite every aspect of exporting to PDF in the graphical user interface is also available for programming: documents can be exported directly with default settings just passing the proper filter name and an URL, every option the user can set in the GUI can also be set programmatically in the filter options, also these settings are configurable via the API (they can be accessed, changed, or reset to their default values), and even the options dialog for exporting to PDF can be used through pure API calls.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |