Curious MalformedPDFError

Skip to first unread message

John Halloran

Dec 29, 2020, 5:55:42 AM12/29/20
to PDF::Reader
The pdf at:
generates a MalformedPDFError when I try to access the 'text' attribute of any page, even though it seems perfectly viewable via Acrobat Reader, and by Preview (Mac).

In fact, if I open it with Preview, and then export it to a different filename (without making any changes), the exported file seems then to be readable.

FWIW, this is not a major problem for me - I expect to get the information I need in some other way, but wanted to provide the example. The file is being generated by FINRA ( who create plenty of PDF's with valuable data, so if there is something to set them straight on, might be useful.

Thanks for a great project!

James Healy

Dec 30, 2020, 7:33:50 AM12/30/20
Thanks for sending this through.

I had a look at the sample file, and ruby's zlib bindings were
refusing to inflate some of the compressed data.

Interestingly though, the inflation works fine if I strip the final
byte from all compressed streams in that file (see
For your particular file, the extra byte is always 0x01.

I'm not familiar enough with the zlib format to know the root cause
here. Maybe the program that wrote that file added a garbage 0x01 byte
by accident?

In any case, my general rule is that if Adobe can parse a file and
pdf-reader can't, it's a pdf-reader bug. I've merged the above PR so
your files can be read.

> --
> You received this message because you are subscribed to the Google Groups "PDF::Reader" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to
> To view this discussion on the web visit

John Halloran

Dec 30, 2020, 1:27:37 PM12/30/20
to PDF::Reader
Thanks so much for the quick turnaround! I will need to find some time to build from source and test, but it sounds like you've identified a straightforward issue.

Thanks again for your work on this project. Super useful!

Reply all
Reply to author
0 new messages