While trying to process a PDF, I got the error HexaPDF::FilterError (Problem while decoding Flate encoded stream: buffer error)
class SampleProcessor < HexaPDF::Content::Processor
attr_reader :text
def initialize()
super()
@text = ['']
def show_text(str)
@text << decode_text(str)
alias :show_text_with_positioning :show_text
I found that when I performed the following:
reader = HexaPDF::Document.new(io: io)
processor = SampleProcessor.new
reader.pages.each do |page|
page.process_contents(processor)
The error would manifest. The PDF file I used is attached. My apologies if this is something easily addressed. I do not have a deep understanding of the gem.
OriginationDocuments-20190514.pdf
Thanks for providing the faulty PDF file and sample code which helped a lot in figuring out the problems.
So, the problem with the AES encrypted string is really a problem with the file itself. However, I have still implemented a work-around for this kind of problem to make HexaPDF more resilient.
I also found the problem with the Flate encoded stream that is the root cause of your error message. This is also an error with the file itself because an empty stream was encoded incorrectly. I have implemented another work-around for this problem.
Will release a bug fix version with the fixes later!