Cookbook
Transform document formats
The conversion plugin, available for the Advanced and Premium licenses, allows to transform document formats, e.g., from DOCX to PDF, HTML or PNG, from DOC to DOCX, from RTF to DOC, etcetera.
The following table shows all the changes the conversion plugin supports:
Source | Output | |||||||
---|---|---|---|---|---|---|---|---|
DOCX | HTML | DOC | ODT | PNG | RTF | TXT | ||
DOC | DOCX | HTML | ODT | PNG | RTF | TXT | ||
ODT | DOCX | HTML | DOC | PNG | RTF | TXT | ||
RTF | DOCX | HTML | DOC | ODT | PNG | TXT |
Note
Due to format limitations, the PNG transformation only generates the first page of the document.
You can complement the conversion plugin with two javadocx methods: embedHTML to transform HTML to DOCX and TXT2DOCX to convert text files to DOCX.
These functionalities enable javadocx to perform virtually any type of conversion.
Doing the conversion
Once the conversion plugin is installed, the transformation from one document format to another is as simple as calling the transformDocument method.
For example, these lines of code convert DOCX to PDF...
...this one converts DOC to DOCX...
...and finally, these lines convert DOCX to PNG and HTML: