Cookbook
- Learn phpdocx in 5 minutes
- Tutorial
- API quick guide
- HTML to Word
- HTML Extended
- Conversion plugin
- Word to HTML
- DOCXPath
- Bulk processing
- DOCXCustomizer
- Digital signature
- Cryptophpdocx
- Right to left languages
- phpdocx CLI command
- Tracking
- Artificial Intelligence
- Blockchain for documents
- JavaScript API
- Compiled mode
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 transformations the conversion plugin supports:
Source | Output | |||||||
---|---|---|---|---|---|---|---|---|
DOCX | (X)HTML | DOC | ODT | PNG | RTF | TXT | ||
DOC | DOCX | (X)HTML | ODT | PNG | RTF | TXT | ||
ODT | DOCX | (X)HTML | DOC | PNG | RTF | TXT | ||
DOCX | DOC | ODT | RTF | PNG | TXT | |||
RTF | DOCX | (X)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 phpdocx methods: embedHTML to transform HTML to DOCX and TXT2DOCX to convert text files to DOCX.
These functionalities enable phpdocx 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: