If you have issues with PDFs, fix them like this: pdftk <corrupted_file>.pdf output <fixed_file>.pdf
Background
I had an issue where an included PDF would not show up in a document created with xelatex
. This is the relevant line of LaTeX code:
\AddToShipoutPicture*{ \includegraphics[width=21cm]{/home/dominik/code/ihero/public/system/stationery/original/stationery.pdf} }
The included PDF is a stationery for invoices which users can upload themselves. It did work until someone updated their stationery with a nearly-identical version. Now the stationery would be missing for no obvious reason. I suspected the PDF was somehow corrupted, and
someone on StackExchange
Show archive.org snapshot
had the hint how to fix it: The pdf toolkit pdftk
.
pdftk
can do almost any PDF-related task as merging, splitting, rotating, decrypting, encrypting, filling forms, applying watermarks, reporting metadata and bookmarks, attaching files and ... repairing.
Resources
A valuable resource for debugging PDF problems seems to be the comprehensive Understanding the PDF format Show archive.org snapshot series. Have a look.