Cookbook

Repair PDF documents

mergePDF is a method intended to combine PDF documents, available on Advanced and Premium liceses. It requires the documents to be internally correct, that means uncorrupted and unprotected.

In case of calling the method and obtaining the following error message

it is necessary to repair the PDF document in order to correctly merge it.

The simplest tool to repair a PDF document is pdftocairo (Linux: https://www.mankier.com/1/pdftocairo, Windows: http://blog.alivate.com.au/poppler-windows/, macOS: http://macappstore.org/poppler/). After installing it, it is possible to capture the launched exception and repair the document with the Java methods exec, system or passthru.

The command that repairs a PDF is: