Cookbook

Preview documents in a web browser

Thanks to the conversion plugin, available for the Advanced and Premium licenses, it is possible to generate a preview of the documents to see them in browsers.

You can export the documents to PDF and PNG formats. Both of them allow a preview in a browser.

To open a PDF document in a browser you need a viewer such as pdf.js (https://mozilla.github.io/pdf.js/). On the other hand, PNG files are compatible with all browsers, as they are shown just as any other image.

For example, an embedded PDF would look like this:

phpdocx 8 and newer releases of Advanced and Premium licenses include native PHP classes to transform DOCX to HTML. The output can be viewed using a web browser or customized to fit the needs of any project. For more information, read DOCX to HTML.

To convert a DOCX document to PDF type the following code:

To transform a DOCX to PNG just change the extension of the target file: