Check to see if the PDF file is damaged.
int pdfFileIsDamaged(PDFViewerHandle viewer)
This function returns true if the PDF file is damaged, meaning that the object structure couldn't be parsed, and required repair.

XpdfViewer attempts to repair all damaged files. If the repair is unsuccessful, pdfLoadFile will return an error. If pdfLoadFile succeeds, pdfFileIsDamaged can be used to check whether the file was repaired.

if (pdfFileIsDamaged(viewer)) { .... }