combine_pdf icon indicating copy to clipboard operation
combine_pdf copied to clipboard

Broken when parsing PDF with empty object

Open sh-miyoshi opened this issue 2 years ago • 0 comments

Hi there, I found an error while parsing PDF.

When parsing a PDF file containing an empty object like following,

14 0 obj
<<
>>
endobj

...
/Resources 14 0 R

I got /Resources 0 0 R. PDF file does not contain 0 0 obj, so the PDF is broken. I suspect a bug in this method. https://github.com/boazsegev/combine_pdf/blob/master/lib/combine_pdf/renderer.rb#L92

Steps to reproduce

  1. Create pdf with empty object
  • I created pdf file by [Microsoft Print to PDF] in windows 10
  1. Run pdf_data = ::CombinePDF.parse(File.read(pdf_file)).to_pdf
  2. insert something to pdf_data

After this, I opened pdf by Acrobat Reader, and I found an error.

sh-miyoshi avatar Jun 07 '22 08:06 sh-miyoshi