I use GhostScript to fix/repair non-compliant/corrupted PDFs in order to let them be successfully opened by PDF readers and be edited with Acrobat Pro without errors or warnings.
gs \
-o repaired.pdf \
-sDEVICE=pdfwrite \
-dPDFSETTINGS=/default \
corrupted.pdf
I noticed however that PNGs images into the PDF are turned into JPEGs with a loss of quality.
Is there a way or specific option to avoid that?
I searched into the documentation without success.