Conversion plugin javadocx

Running the first example and available options

Running the first example

You can transform documents with the CreateDocx class methods or directly calling the TransformDocAdvOpenOffice or TransformDocAdvLibreOffice classes.

The CreateDocx class allows javadocx to perform an additional check of the elements that were added during the document creation. For example, if your method includes the altchunk tag, an alert will inform that the conversion isn't possible.

This is the easiest example to transform a DOCX to PDF:

Either with LibreOffice or OpenOffice, the configuration file defines the transformation method, previously explained.

If you don't need to generate a new document, or you just need to make the conversion to PDF, you can directly instantiate the following classes:

  • TransformDocAdvLibreOffice, for LibreOffice
  • TransformDocAdvOpenOffice, for OpenOffice

Working with these classes is as simple as including the autoloader:

Then, instantiate an object with the desired class:

For LibreOffice:

For OpenOffice:

Lastly, call the transformation:

Available options

The transformDocument method has some parameters which you may have to customize.

Here's the signature of the method:

These are the available parameters:

  • $docSource: Sets the document you want to transform.
  • $docDestination: Defines the destination document. The extension sets the document output format.
  • $tempDir: Sets the temporary path for the conversion. In the case of not being able to access the temporary directory of the operating system or having trouble working with it, this parameter allows to set a new temporary path for the conversion. It can be set in a relative or absolute way.
  • $options: This is the conversion options array. The available keys are:
    • 'method'. It comes with a direct and a script option. The direct option uses the passthru method from Java. The script option does the transformation with an external script as it was using the CLI mode.
    • 'odfconverter'. This boolean key allows true or false options. It enables and disables OdfConverter. Only used by OpenOffice.
    • 'debug'. A boolean key. It outputs the whole information of the method. It's a successful way to detect and solve issues.
  • $version: This parameter is available only for OpenOffice. It sets the OdfConverter version, either 32bit or 64bit. If not specified, the method automatically detects it.
Next - Preparing the templates and exporting