PdfPig: Adobe Reader cannot open some pdf created with PdfPig
Hi,
I’m using pdfPig to cut out one big Pdf file into several pdf. The code below is an example of how I am using your library to create one new pdf with only the first page of my source file :
var stream = File.OpenRead(pdfPath);
var sourceDocument = PdfDocument.Open(stream);
var documentBuilder = new PdfDocumentBuilder();
documentBuilder.AddPage(sourceDocument, 1);
var newDoc = documentBuilder.Build();
// then create fileStream from newDoc byte[]
The source file can be open without any error in Adobe Reader or Chrome. But, when I try to open the newly created with Adobe Reader, I encountered this error (It works fine with chrome btw) :

It works fine with many source Pdf but sometimes I’m facing this issue. It depends on the source file 😞 . Unfortunatly, due to the sensitive content of these pdf I cannot attached it.
Have you ever facing such an issue ? Let me know if you need more information.
Thanks in advance,
Florent
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 1
- Comments: 32 (14 by maintainers)
@plaisted I have made some test and your PR fixes the bug with my pdf. Thanks ! And I hope it will be merged soon 😃
PdfPig is unable to open the created (broken) PDF. Both a “normal”
PdfDocument.Open()and one withParsingOptions.LenientParsingOffthrow the same exception: