Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

undefined method `[]' for nil:NilClass #86

Closed
justindarc opened this issue Feb 20, 2013 · 4 comments
Closed

undefined method `[]' for nil:NilClass #86

justindarc opened this issue Feb 20, 2013 · 4 comments

Comments

@justindarc
Copy link

I have encountered a simple 1-page PDF generated by OpenOffice that causes the pdf-reader gem to throw an error when extracting text. The error occurs in the "int_to_name" method on line 127 of lib/pdf/reader/encoding.rb. The reason for the error is that @differences is nil.

Here is the error:

undefined method []' for nil:NilClass /Users/Justin/.rvm/gems/jruby-1.7.1/gems/pdf-reader-1.3.1/lib/pdf/reader/encoding.rb:127:inint_to_name'

@yob
Copy link
Owner

yob commented Feb 25, 2013

Thanks for the bug report.

Can you generate a sample PDF that triggers this and email it to me at
james@yob.id.au?

@kedarmhaswade
Copy link

I see the same error. The glyph_code is 183 and for that when lookup happens @differences is nil.

stack trace:

NoMethodError - undefined method `[]' for nil:NilClass:
    (eval):2:in `method_missing'
    gems/pdf-reader-1.3.1/lib/pdf/reader/encoding.rb:127:in `int_to_name'
    gems/pdf-reader-1.3.1/lib/pdf/reader/width_calculator/built_in.rb:42:in `glyph_width'
    gems/pdf-reader-1.3.1/lib/pdf/reader/font.rb:89:in `glyph_width'
    gems/pdf-reader-1.3.1/lib/pdf/reader/page_text_receiver.rb:107:in `block in internal_show_text'
    gems/pdf-reader-1.3.1/lib/pdf/reader/page_text_receiver.rb:100:in `each'
    gems/pdf-reader-1.3.1/lib/pdf/reader/page_text_receiver.rb:100:in `each_with_index'
    gems/pdf-reader-1.3.1/lib/pdf/reader/page_text_receiver.rb:100:in `internal_show_text'
    gems/pdf-reader-1.3.1/lib/pdf/reader/page_text_receiver.rb:57:in `show_text'
    gems/pdf-reader-1.3.1/lib/pdf/reader/page.rb:154:in `block in callback'
    gems/pdf-reader-1.3.1/lib/pdf/reader/page.rb:153:in `each'
    gems/pdf-reader-1.3.1/lib/pdf/reader/page.rb:153:in `callback'
    gems/pdf-reader-1.3.1/lib/pdf/reader/page.rb:140:in `content_stream'
    gems/pdf-reader-1.3.1/lib/pdf/reader/page.rb:105:in `walk'
    gems/pdf-reader-1.3.1/lib/pdf/reader/page.rb:75:in `text'

James -- I will send you a pdf file separately in an email ...

@yob
Copy link
Owner

yob commented Apr 1, 2013

Thanks @kedarmhaswade. I think this bug has been fixed in 1.3.2, can you try upgrading and let me know?

@kedarmhaswade
Copy link

Whoa! Thank you, @yob! Upgrading to 1.3.2 parses the file I sent you correctly. I think I agree with you. This bug seems to have been fixed.

@yob yob closed this as completed Apr 1, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants