PdfSharpCore icon indicating copy to clipboard operation
PdfSharpCore copied to clipboard

Unexpected EOF with PdfReader.Open(PdfDocumentOpenMode.Import) when opening a PDF with a textbox and slash

Open nh104622 opened this issue 3 years ago • 2 comments

Basically title. When I try to take in an existing PDF byte array then open up a memory stream to read the PDF then Call PDFReader.Open(...), I get an error message with the below external stack trace. The issue goes away when I take out the slashes in a date text field of the editable PDF. The example PDF has a date in the format of: 01/01/1970 in a textbox. Is there any way around this issue?

using var stream = new MemoryStream(pdfData);
using var doc = PdfReader.Open(stream, PdfDocumentOpenMode.Import);

Stack Trace: ICSharpCode.SharpZipLib.SharpZipBaseException: Unexpected EOF at ICSharpCode.SharpZipLib.Zip.Compression.Streams.InflaterInputStream.Fill at ICSharpCode.SharpZipLib.Zip.Compression.Streams.InflaterInputStream.Read at PdfSharpCore.Pdf.Filters.FlateDecode.Decode at PdfSharpCore.Pdf.Filters.Filtering.Decode at PdfSharpCore.Pdf.PdfDictionary+PdfStream.get_UnfilteredValue at PdfSharpCore.Pdf.IO.Parser.ReadXRefStream at PdfSharpCore.Pdf.IO.Parser.ReadXRefTableAndTrailer at PdfSharpCore.Pdf.IO.Parser.ReadTrailer at PdfSharpCore.Pdf.IO.PdfReader.Open

nh104622 avatar Nov 30 '22 20:11 nh104622

An update on this issue, I still have this problem with an inconvenient workaround. Basically this PDF I am trying to import has editable fields and generates the above exception when calling PdfReader.Open(...). The workaround is to manually edit one of the fields using Adobe then undo my change and save it. For some reason this seems to work when re-running my application with the above code.

Does anyone have any insights on what could be happening here? This happens with multiple documents.

nh104622 avatar Apr 26 '23 14:04 nh104622

https://github.com/ststeiger/PdfSharpCore/issues/451 The same issue

toolgood avatar Aug 06 '24 09:08 toolgood