Detecting and fixing non-conformant PDF files

Hi,

We currently use the IsModified flag to detect if PDFtron fixed something on loading the non conformant pdf.
Clients complaining when they load 3rd party PDFs that are non conformant.
Just wondering if there is a way to detect the type of issue and if the modified pdf can safely be saved as Acrobat does with these same files?

Thanks

The following code can be used to check if a PDF has a cross reference table and was repaired.

PDFDoc doc = new PDFDoc(pathToPdf);
doc.InitSecurityHandler();
bool wasRepaired = doc.HasRepairedXRef();

https://www.pdftron.com/api/PDFTronSDK/dotnet/pdftron.PDF.PDFDoc.html#pdftron_PDF_PDFDoc_HasRepairedXRef

As you noted, IsModified will return true in this case also. To reset both flags, requires saving the PDF.

if the modified pdf can safely be saved as Acrobat does with these same files?
Yes, saving will apply the updated xref table. Note that different vendors will repair differently, so it might be good to keep the original file.

We regularly get PDF files that are in a malformed state from other vendors, and we often improve our handling. So if you have not already, please use the latest version of our SDK.

Otherwise, feel free to send us the file if you can so we can review.