Detecting and fixing non-conformant PDF files

28 views
Skip to first unread message

ASR

unread,
May 20, 2019, 8:06:54 AM5/20/19
to PDFTron PDFNet SDK
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

Ryan

unread,
May 21, 2019, 3:49:19 PM5/21/19
to PDFTron PDFNet SDK
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();


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.
Reply all
Reply to author
Forward
0 new messages