"Cannot handle iref streams." in PDF with GemBox.Document

When password-protecting a PDF via Password protect a PDF online for free | Adobe Acrobat (United States) upon loading the PDF document with DocumentModel.Load(@"CustomInvoice-protected.pdf", new PdfLoadOptions {Password = "blah"}); I got the following error

Cannot handle iref streams. The current implementation of PDF component cannot handle this PDF feature introduced with Acrobat 6

Alternatively while loading it via GemBox.Pdf.PdfDocument.Load the document loads properly. Is this a bug in GemBox.Document?

Hi,

Yes, I’m afraid that GemBox.Document’s PDF reader never left the BETA stage, it cannot handle newer PDF features, like “iref streams” which are cross-reference tables stored in streams.

But as you already noticed, GemBox.Pdf does support cross-reference streams.
So as a workaround, for now, you could load PDF with GemBox.Pdf, remove “iref streams”, and then successfully load PDF with GemBox.Document.

string inputPdfFile = "input.pdf";
MemoryStream outputPdfStream = new MemoryStream();

// Load PDF with GemBox.Pdf.
var pdfDocument = PdfDocument.Load(inputPdfFile);

// Change cross reference type.
pdfDocument.SaveOptions.CrossReferenceType = PdfCrossReferenceType.Table;

// Save PDF with GemBox.Pdf.
pdfDocument.Save(outputPdfStream);

// Load PDF with GemBox.Document.
var document = DocumentModel.Load(outputPdfStream, LoadOptions.PdfDefault);
pdfDocument.Close();

// ...

I hope this helps.

Regards,
Mario

Thanks!

What was missing from the example was the line pdfDocument.SaveOptions.Encryption = null; as otherwise I got “The PDF document is protected with an encryption not supported by GemBox component.”

This issue is resolved in the current latest version:

Install-Package GemBox.Document -Version 35.0.1715-hotfix

Now both PDF readers in GemBox.Document (logical loading and high fidelity loading) use the same PDF implementation.