yob / pdf-reader

The PDF::Reader library implements a PDF parser conforming as much as possible to the PDF specification from Adobe.
MIT License
1.81k stars 271 forks source link

PDF::Reader::MalformedPDFError when PDF contains an image #365

Closed calbers191 closed 2 years ago

calbers191 commented 2 years ago

Full error message:

PDF::Reader::MalformedPDFError: PDF malformed, expected 'endstream' but found 0 instead

For full context, this is happening while using Prawn to add an existing PDF to a new PDF. Stack trace points to pdf-reader library, error coming from here: pdf/reader/error.rb in str_assert at line 36

I believe this to be due to an image in the PDF, because I cannot recreate it when I remove the image. The PDF in question is attached (with PHI altered).

I cannot recreate this using an alternate PDF library (https://github.com/gdelugre/origami), which to me suggests that there is a bug in this one, although I'm open to alternate explanations.

Thanks!

MARGE.pdf