Q:
Could you help me figure out why the PDF files attached could not be
opened or converted to bitmap? They are able to be opened in Acrobat
(but Acrobat shows a brief message - 'Fixing PDF...' when opening the
file).
---
A:
The problem is that these 'damaged' files are corrupt (i.e. they are
not valid PDF documents). Acrobat attempts to dynamically to fix these
files during 'file open'. If you have Acrobat Pro you will be prompted
to save the file when closing the window (and the error will go
away).
Using PDFNet you could also attempt to programmatically fix a broken
PDF documents using SDF.XRefRebuilder class (or SDF.Doc.FixBrokenDoc()
in PDFNet 4.x or above). Still, if a PDF document is corrupt there are
no guarantees that XRefRebuilder will be able to fix the problem.
The following is an example of using XRefRebuilder (assuming C#):
PDFDoc doc;
try {
doc = new PDFDoc(input_file);
....
}
catch (Exception e)
{
try {
// try rebuilding the doc
Filter stm = StdFile(input_file, StdFile.OpenMode.e_read_mode));
XRefRebuilder rb = new XRefRebuilder();
doc = new PDFDoc(rb.Rebuild(stm));
}
catch (Exception e) {
// Error: Document rebuild failed.
return false;
}
...
}