June 22, 2017 Webby

Customising Export Options

Since version 2.1.0, JODConverter supports the ability to specify custom export options when converting. This applies to any output format, but is especially useful for PDFs.

Custom options can be configured in a global document-formats.xml if they applies to all conversions, or for a specific conversion by passing a customised DocumentFormat to the convert() method of the DocumentConverter. For example here’s how to generate a password protected PDF document:

// create a PDF DocumentFormat (as normally configured in document-formats.xml)
DocumentFormat customPdfFormat =
    new DocumentFormat("Portable Document Format", "application/pdf", "pdf");
customPdfFormat.setExportFilter(DocumentFamily.TEXT, "writer_pdf_Export");

// now set our custom options
Map pdfOptions = new HashMap();
pdfOptions.put("EncryptFile", Boolean.TRUE);
pdfOptions.put("DocumentOpenPassword", "mysecretpassword");
customPdfFormat.setExportOption(DocumentFamily.TEXT, "FilterData", pdfOptions);

// and convert using our custom format
converter.convert(inputFile, outputFile, customPdfFormat);

The available options are the same that are displayed in the correspondent OpenOffice.org export dialog. Most of them are documented in the PDF Export Dialog Specification, Chapter 3 “Configuration”.

Additional security-related options (not documented in the specification above) are, as of OpenOffice.org 2.0.4 (from the source code file filter/source/pdf/impdialog.cxx)

NameValue TypeDefault ValuePossible Values
PrintingInteger20: Not permitted
1: Low resolution (150 DPI)
2: High resolution
ChangesInteger40: Not permitted
1: Inserting, deleting and rotating pages
2: Filling in form fields
3: Commenting, filling in form fields
4: Any except extracting pages