impose icon indicating copy to clipboard operation
impose copied to clipboard

Breaks on most PDFs: ``_apply': undefined method '[]' for nil:NilClass (NoMethodError)`

Open hasnolen opened this issue 2 years ago • 0 comments

MWE

# get this PDF
wget https://bayes.wustl.edu/etj/articles/random.pdf
impose random.pdf
/Library/Ruby/Gems/2.6.0/gems/pdf-impose-1.0.0/lib/pdf/impose/builder.rb:109:in `_apply': undefined method `[]' for nil:NilClass (NoMethodError)
        from /Library/Ruby/Gems/2.6.0/gems/pdf-impose-1.0.0/lib/pdf/impose/builder.rb:101:in `initialize'
        from /Library/Ruby/Gems/2.6.0/gems/pdf-impose-1.0.0/bin/impose:143:in `new'
        from /Library/Ruby/Gems/2.6.0/gems/pdf-impose-1.0.0/bin/impose:143:in `<top (required)>'
        from /usr/local/bin/impose:23:in `load'
        from /usr/local/bin/impose:23:in `<main>'

Ideas

The line in question is

source_width = @source.page(1).page_object[:MediaBox][2]

, and I believe this means that @source.page(1).page_object is nil.

Maybe this is therefore a bug in PDF::Reader?

hasnolen avatar Aug 12 '23 05:08 hasnolen