API/Tutorials/PDF export
PDF Export filter data
The following tables contain all the properties available in the PDF export filter implementation in OpenOffice.org 2.4.
The tables follow the order of the PDF Export dialog tab pages, so that you can easily understand their meaning just comparing them with this dialog.
Notes:
- The Description column contains descriptions taken mainly from the PDF Export Dialog configuration, found in
<opt/openoffice.org2.4>/share/registry/schema/org/openoffice/Office/Common.xcs
- The Type column refers to the UNO IDL data types (see Developer's Guide - Professional UNO - Simple Types), not the OpenOffice.org Registry data types (see Developer's Guide - Configuration Management - Object Model and OpenOffice.org Registry Format - Registry Object Model).
- The Default value column contains the default value as indicated in the PDF Export Dialog configuration mentioned above.
General properties
|
|
|
|
PageRange
|
If this property is set, it indicates the range of pages to be printed.
If you want to print all the pages, leave this property unset. If you want to export a selection, leave this property unset, setting only the property Selection. |
|
|
Selection
|
An any corresponding to the current selection in the document. | |
|
UseLosslessCompression
|
Specifies if graphics are exported to PDF using a lossless compression eg. PNG or if they are compressed using the JPEG format. | |
|
Quality
|
Specifies quality of the JPG export. A higher value results in higher quality and file.
Minimum inclusive value: 1. Represents lowest value that can be used. The lower the value, the less good is the compression quality and the bigger is be the file size. Minimum inclusive value:100. Represents highest value that can be used. The higher the value, the better is the compression quality and the smaller is the file size. |
|
|
ReduceImageResolution
|
Specifies if the resolution of each image is reduced to the resolution specified by the property MaxImageResolution. | |
|
MaxImageResolution
|
If the property ReduceImageResolution is set to true all images will be reduced to the given value in DPI.
Posible values:
|
|
|
SelectPdfVersion
|
Specifies the version of PDF to emit.
Possible values:
|
|
|
UseTaggedPDF
|
Determines if PDF are created by using special tags also known as Tagged PDF. | |
|
ExportFormFields
|
Specifies whether form fields are exported as widgets or only their fixed print representation is exported. | |
|
FormsType
|
Specifies the submitted format of a PDF form.
Possible values:
|
|
|
ExportBookmarks
|
Specifies if bookmarks are exported to PDF. | |
|
ExportNotes
|
Specifies if notes are exported to PDF. | |
|
ExportNotesPages
|
Specifies if notes pages are exported to PDF. (Notes pages are available in Impress documents only). | |
|
IsSkipEmptyPages
|
Specifies that automatically inserted empty pages are suppressed. This option is active only if storing Writer documents. | |
|
IsAddStream
|
Specifies that a stream is inserted to the PDF file which contains the original document for archiving purposes. | |
|
Initial view
|
|
|
|
---|---|---|---|
InitialView
|
Specifies how the PDF document should be displayed when opened.
Possible values:
|
|
|
InitialPage
|
Specifies the page on which a PDF document should be opened in the viewer application. | |
|
Magnification
|
Specifies the action to be performed when the PDF document is opened.
Possible values:
|
|
|
Zoom
|
specifies the zoom level a PDF document is opened with. Only valid if "Magnification" is set to "4". | |
|
PageLayout
|
Specifies the page layout to be used when the document is opened.
Possible values:
|
|
|
FirstPageOnLeft
|
Used with the value 3 of the PageLayout property above, true if the first page (odd) should be on the left side of the screen. | |
|
User interface
|
|
|
|
---|---|---|---|
ResizeWindowToInitialPage
|
Specifies that the PDF viewer window is opened full screen when the document is opened. | |
|
CenterWindow
|
Specifies that the PDF viewer window is centered to the screen when the PDF document is opened. | |
|
OpenInFullScreenMode
|
Specifies that the PDF viewer window is opened full screen, on top of all windows. | |
|
DisplayPDFDocumentTitle
|
Specifies that the title of the document, if present in the document properties, is displayed in the PDF viewer window title bar. | |
|
HideViewerMenubar
|
Specifies whether to hide the PDF viewer menubar when the document is active. | |
|
HideViewerToolbar
|
Specifies whether to hide the PDF viewer toolbar when the document is active. | |
|
HideViewerWindowControls
|
Specifies whether to hide the PDF viewer controls when the document is active. | |
|
UseTransitionEffects
|
Specifies slide transitions are exported to PDF. This option is active only if storing Impress documents. | |
|
OpenBookmarkLevels
|
Specifies how many bookmark levels should be opened in the reader application when the PDF gets opened.
Possible values:
|
|
|
Links
|
|
|
|
---|---|---|---|
ExportBookmarksToPDFDestination
|
Specifies that the bookmarks contained in the source OpenOffice.org file should be exported to the PDF file as Named Destination (see PDF 1.4 section 8.2.1). | |
|
ConvertOOoTargetToPDFTarget
|
Specifies that the target documents with .od[tpgs] extension, will have that extension changed to .pdf when the link is exported to PDF. The source document remains untouched. | |
|
ExportLinksRelativeFsys
|
Specifies that the file system related hyperlinks (file:// protocol) present in the document will be exported as relative to the source document location. | |
|
PDFViewSelection
|
Specifies the way the exported PDF will be viewed (experienced) by the user.
Possible values:
|
|
|
Security
|
|
|
|
---|---|---|---|
EncryptFile
|
If true, selects to encrypt the PDF document with a password. The PDF file can be opened only when the user enters the correct password. | |
|
DocumentOpenPassword
|
This is the password that allows the user to open the PDF file is "EncryptFile" is set to true. | |
|
RestrictPermissions
|
If true, selects to restrict some permissions. The permissions can be changed only when the user enters the correct password. | |
|
PermissionPassword
|
This is the password that allows the user to access some permissions restricted if "RestrictPermissions" is set to true. | |
|
Printing
|
Specifies what printing is allowed.
Possible values:
|
|
|
Changes
|
Specifies the change allowed to the document.
Possible values:
|
|
|
EnableCopyingOfContent
|
Specifies that the pages and the document content can be extracted to be used in other documents (copy and paste). | |
|
EnableTextAccessForAccessibilityTools
|
Specifies that the document content can be extracted to be used in accessibility applications. | |
|
PDF Export Configuration
The settings of PDF export dialog are stored in the OpenOffice.org registry every time the this dialog is used and the user confirms his/her choices. Not all properties passed to the PDF filter a are stored in the registry (as it makes no sense to store the page range to be exported, or the passwords for protecting the document).
The following is a list of the properties available in the node path /org.openoffice.Office.Common/Filter/PDF/Export:
- CenterWindow
- Changes
- CompressMode [deprecated]
- ConvertOOoTargetToPDFTarget
- DisplayPDFDocumentTitle
- EnableCopyingOfContent
- EnableTextAccessForAccessibilityTools
- ExportBookmarks
- ExportBookmarksToPDFDestination
- ExportFormFields
- ExportLinksRelativeFsys
- ExportNotes
- ExportNotesPages
- FirstPageOnLeft
- FormsType
- HideViewerMenubar
- HideViewerToolbar
- HideViewerWindowControls
- InitialPage
- InitialView
- IsAddStream
- IsSkipEmptyPages
- Magnification
- MaxImageResolution
- OpenBookmarkLevels
- OpenInFullScreenMode
- PDFViewSelection
- PageLayout
- Printing
- Quality
- ReduceImageResolution
- ResizeWindowToInitialPage
- SelectPdfVersion
- UseLosslessCompression
- UseTaggedPDF
- UseTransitionEffects
- Zoom
The following properties are not part of the registry:
- DocumentOpenPassword
- EncryptFile
- PageRange
- PermissionPassword
- RestrictPermissions
- Selection
Accessing the configuration
import com.sun.star.beans.Property; import com.sun.star.beans.PropertyValue; import com.sun.star.beans.XPropertySet; import com.sun.star.beans.XPropertySetInfo; import com.sun.star.comp.helper.Bootstrap; import com.sun.star.lang.XMultiComponentFactory; import com.sun.star.lang.XMultiServiceFactory; import com.sun.star.uno.Exception; import com.sun.star.uno.UnoRuntime; import com.sun.star.uno.XComponentContext; public class PDFExportConfigAccess { private final XComponentContext m_xContext; public PDFExportConfigAccess(XComponentContext xContext){ m_xContext = xContext; } public static void main(String[] args) { try { // get the remote office component context XComponentContext xContext = Bootstrap.bootstrap(); PDFExportConfigAccess demo = new PDFExportConfigAccess(xContext); demo.run(); } catch (java.lang.Exception e){ e.printStackTrace(); } finally { System.exit( 0 ); } } public void run(){ Object oConfig = getPDFConfigAccess(m_xContext); if (oConfig == null ) { System.out.println("Impossible to access the PDF configuration"); return; } XPropertySet xPropertySet = (XPropertySet) UnoRuntime.queryInterface( XPropertySet.class, oConfig); XPropertySetInfo xPropertySetInfo = xPropertySet.getPropertySetInfo(); Property[] properties = xPropertySetInfo.getProperties(); System.out.println("\nProperties and values\n"); for (Property property : properties) { String sValue = ""; try { Object aValue = xPropertySet.getPropertyValue( property.Name ); sValue = String.valueOf( aValue ); } catch (Exception ex) { ex.printStackTrace(); } System.out.println(property.Name + " =\t" + sValue); } } public static Object getPDFConfigAccess(XComponentContext xContext){ Object oPDFExportConfig = null; try { XMultiComponentFactory xMCF = xContext.getServiceManager(); Object oConfigProvider = xMCF.createInstanceWithContext( "com.sun.star.configuration.ConfigurationProvider", xContext); XMultiServiceFactory oConfigProvMSF = (XMultiServiceFactory) UnoRuntime.queryInterface( XMultiServiceFactory.class, oConfigProvider); PropertyValue[] args = new PropertyValue[1]; args[0] = new PropertyValue(); args[0].Name = "nodepath"; args[0].Value = "/org.openoffice.Office.Common/Filter/PDF/Export/"; String sServiceName = "com.sun.star.configuration.ConfigurationAccess"; oPDFExportConfig = oConfigProvMSF.createInstanceWithArguments( sServiceName, args); } catch (Exception ex) { ex.printStackTrace(); } finally { return oPDFExportConfig; } } }
Modifying the configuration
import com.sun.star.beans.PropertyValue; import com.sun.star.beans.PropertyVetoException; import com.sun.star.beans.UnknownPropertyException; import com.sun.star.beans.XPropertySet; import com.sun.star.comp.helper.Bootstrap; import com.sun.star.lang.IllegalArgumentException; import com.sun.star.lang.WrappedTargetException; import com.sun.star.lang.XMultiComponentFactory; import com.sun.star.lang.XMultiServiceFactory; import com.sun.star.uno.Exception; import com.sun.star.uno.UnoRuntime; import com.sun.star.uno.XComponentContext; import com.sun.star.util.XChangesBatch; public class PDFExportConfigUpdate { private final XComponentContext m_xContext; public PDFExportConfigUpdate(XComponentContext xContext){ m_xContext = xContext; } public static void main(String[] args) { try { // get the remote office component context XComponentContext xContext = Bootstrap.bootstrap(); PDFExportConfigUpdate demo = new PDFExportConfigUpdate(xContext); demo.run(); } catch (java.lang.Exception e){ e.printStackTrace(); } finally { System.exit( 0 ); } } public void run() { Object oConfig = getPDFConfigUpdateAccess(m_xContext); if (oConfig == null) { System.out.println("Impossible to access the PDF configuration"); return; } XPropertySet xPropertySet = (XPropertySet) UnoRuntime.queryInterface( XPropertySet.class, oConfig); try { // change some properties /** * The first property specifies that the resolution of each image * must be reduced to the resolution specified by the second property * The value is given in DPI. */ xPropertySet.setPropertyValue("ReduceImageResolution", Boolean.TRUE); xPropertySet.setPropertyValue("MaxImageResolution", new Integer(600)); /** * When exporting a document to PDF, the default is PDF 1.4 * Since OOo 2.4 the PDF/A-1a is also supported. * PDF/A-1a is an ISO 19005-1:2005 International Standard. * * NOTE that some other options WILL NOT be available if this format * is selected (UseTaggedPDF, ExportFormFileds, FormsType, * all security options) */ xPropertySet.setPropertyValue("SelectPdfVersion", new Integer(1)); /** * "Magnification" specifies the action to be performed * when the PDF document is opened. * A value of 4 opens with the zoom level specified in the * "Zoom" property. */ xPropertySet.setPropertyValue("Magnification", new Integer(4)); xPropertySet.setPropertyValue("Zoom", new Integer(60)); XChangesBatch xChangesBatch = (XChangesBatch) UnoRuntime.queryInterface( XChangesBatch.class, xPropertySet); xChangesBatch.commitChanges(); } catch (UnknownPropertyException ex) { ex.printStackTrace(); } catch (PropertyVetoException ex) { ex.printStackTrace(); } catch (IllegalArgumentException ex) { ex.printStackTrace(); } catch (WrappedTargetException ex) { ex.printStackTrace(); } } public static Object getPDFConfigUpdateAccess(XComponentContext xContext){ Object oPDFExportConfig = null; try { XMultiComponentFactory xMCF = xContext.getServiceManager(); Object oConfigProvider = xMCF.createInstanceWithContext( "com.sun.star.configuration.ConfigurationProvider", xContext); XMultiServiceFactory oConfigProvMSF = (XMultiServiceFactory) UnoRuntime.queryInterface( XMultiServiceFactory.class, oConfigProvider); PropertyValue[] args = new PropertyValue[1]; args[0] = new PropertyValue(); args[0].Name = "nodepath"; args[0].Value = "/org.openoffice.Office.Common/Filter/PDF/Export/"; // ConfigurationUpdateAccess instead of ConfigurationAccess String sServiceName = "com.sun.star.configuration.ConfigurationUpdateAccess"; oPDFExportConfig = oConfigProvMSF.createInstanceWithArguments( sServiceName, args); } catch (Exception ex) { ex.printStackTrace(); } finally { return oPDFExportConfig; } } }
Resetting the configuration
ToDo
PDF Export Dialog
How to use it from Java
ToDo
How to use it from C++
ToDo
How to use it from OOo Basic
ToDo