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
Repair PDF documents
Working with PDF methods such as mergePdf, watermarkPdf, or sign (PDF), requires the documents to be internally correct, that means well-formed, uncorrupted and unprotected.
To repair a PDF document that is not well-formed, the easiest approach is using ghostscript, available for Windows, Linux and macOS.
After installing ghostscript, the command to repair a PDF is:
PDF documents that are not well-formed throw PHP Warnings when calling phpdocx PDF methods. These warnings can be catched using a custom error handler, repair the PDF using ghostscript and call again the phpdocx PDF method with the repaired PDF: