1. Try multiple PDF viewers first — Before attempting repair, try opening the PDF in several different viewers: Adobe Acrobat Reader, Chrome, Firefox (PDF.js), macOS Preview, Foxit Reader. Each has a different parser with different error tolerance. A file that fails in Acrobat may open in Chrome; one that fails in both may succeed in mutool. Chrome and Firefox's PDF.js have particularly lenient parsers that recover from many malformed structures.
2. qpdf — the first tool to try —
qpdf is a command-line tool that performs structural transformation of PDFs. Its
--recover option attempts to rebuild the cross-reference table by scanning the file for valid PDF objects:
qpdf --recovery input.pdf output.pdf
qpdf also provides diagnostic information:
qpdf --check input.pdf reports xref errors, encryption issues, and structural problems. If the xref is the only issue and the content objects are intact, qpdf's recovery succeeds reliably.
3. Ghostscript — structural normalisation — Ghostscript processes PDF by rendering it through its interpreter and writing new PDF output. This regenerates the entire file structure:
gs -dBATCH -dNOPAUSE -sDEVICE=pdfwrite -sOutputFile=output.pdf input.pdf
Ghostscript is more aggressive than qpdf — it will silently skip objects it cannot parse and continue. The output PDF may be smaller than expected if some objects were unrecoverable. Add
-dPDFSETTINGS=/prepress to preserve image quality.
4. mutool (MuPDF) — lenient parsing — mutool from the
MuPDF library has a lenient parser useful for recovery:
mutool clean -gggg input.pdf output.pdf
The
-gggg flag performs aggressive garbage collection, removing unreferenced objects and writing a clean output file.
5. Adobe Acrobat Pro — File > Open (Acrobat will attempt repair and prompt if it detects corruption). Also: File > Save As to force a full file rebuild. For advanced recovery: preflight (Tools > Print Production > Preflight) can identify specific structural errors.
6. Recovery services for severe corruption — For PDFs damaged by storage failure (large sectors of random bytes), tool-based recovery may not be sufficient. Commercial services like
PDF2Go Repair or specialist data recovery firms may recover more content through byte-level analysis.