Repair a PDF that won't open
The download cut off at 98%, the FTP transfer ran in text mode, the export crashed halfway. The viewer says the file is damaged, but the pages are usually still sitting inside; what broke is the index that finds them. repair rebuilds that structure and writes a clean copy.
How to do it
pip install pdfblah
pdfblah repair broken.pdf -o fixed.pdf
repaired: 34 page(s) saved (structure reconstructed) -> fixed.pdf
Why you can trust the answer
- The output is proven, not assumed. After rebuilding, the result is re-opened and checked before success is claimed. "Repaired" means it actually opens.
- The recovered pages go into a fresh file. Rewriting the damaged file in place can drag its broken structure along; a new file can't inherit the disease.
- Honest failures. A file with nothing recoverable is a clear "no", not a zero-page success. And a file that's actually password-protected rather than broken gets pointed at
pdfblah unlockinstead.
Tips
- Repair first, then do whatever you actually wanted: tools that refused the broken file (viewers, NotebookLM, printers) accept the rebuilt one.
- If the file came off a flaky download, try re-downloading first; repair recovers what is in the file, not what never arrived.
- Some content can be genuinely gone (the report's page count is what survived). What repair saves is everything that is still there.