Skip to content
This repository was archived by the owner on Nov 29, 2019. It is now read-only.

Errors showing up for some pdf files #9

Open
shivams opened this issue Mar 13, 2014 · 5 comments
Open

Errors showing up for some pdf files #9

shivams opened this issue Mar 13, 2014 · 5 comments

Comments

@shivams
Copy link

shivams commented Mar 13, 2014

While using pdf-extract, it shows various errors sometimes:

error: undefined method `ascent' for nil:NilClass. Use --trace to view backtrace

error: undefined method `load_file' for #<PDF::Core::ObjectStore:0xcc69308 @objects={}, @identifiers=[]>. Use --trace to view backtrace

PS: I'm using Ruby v1.9.3p194.

@eduhideki
Copy link

uninstall pdf-reader and install pdf-reader -v 1.1.1

@bwakkie
Copy link

bwakkie commented Aug 27, 2014

Obviously -v 0.1.1 is ment here ;-)

I had the same problem. Perhaps add a line like the following would help newbs like us:

install stable version use: gem install pdf-reader -v 0.1.1
install dev version use gem install pdf-reader

I installed 0.1.1 and I still have this problem?
/usr/local/lib64/ruby/gems/2.0.0/gems/pdf-extract-0.1.1/lib/font_metrics.rb:42:in initialize': undefined methodascent' for #PDF::Reader::Font:0x00000003ccacd8 (NoMethodError)

Does it have to do with a missing gem? I am a Ruby newb too so that could be possible here...

@mgree
Copy link

mgree commented Dec 18, 2014

I'm getting a variety of errors on PDFs as well:

$ pdf-extract extract -t --titles --sections XXX/YYY.pdf
/Library/Ruby/Gems/2.0.0/gems/pdf-extract-0.1.1/lib/analysis/titles.rb:30:in block (2 levels) in include_in': undefined method[]' for nil:NilClass (NoMethodError)
from /Library/Ruby/Gems/2.0.0/gems/pdf-extract-0.1.1/lib/pdf.rb:98:in call' from /Library/Ruby/Gems/2.0.0/gems/pdf-extract-0.1.1/lib/pdf.rb:98:incall_after'
from /Library/Ruby/Gems/2.0.0/gems/pdf-extract-0.1.1/lib/pdf.rb:160:in invoke_calls' from /Library/Ruby/Gems/2.0.0/gems/pdf-extract-0.1.1/lib/pdf-extract.rb:42:inblock in parse'
from /Library/Ruby/Gems/2.0.0/gems/pdf-extract-0.1.1/lib/pdf-extract.rb:38:in each' from /Library/Ruby/Gems/2.0.0/gems/pdf-extract-0.1.1/lib/pdf-extract.rb:38:inparse'
from /Library/Ruby/Gems/2.0.0/gems/pdf-extract-0.1.1/lib/pdf-extract.rb:53:in view' from /Library/Ruby/Gems/2.0.0/gems/pdf-extract-0.1.1/bin/pdf-extract:115:inblock (4 levels) in <top (required)>'
from /Library/Ruby/Gems/2.0.0/gems/pdf-extract-0.1.1/bin/pdf-extract:112:in each' from /Library/Ruby/Gems/2.0.0/gems/pdf-extract-0.1.1/bin/pdf-extract:112:inblock (3 levels) in <top (required)>'
from /Library/Ruby/Gems/2.0.0/gems/commander-4.2.1/lib/commander/command.rb:180:in call' from /Library/Ruby/Gems/2.0.0/gems/commander-4.2.1/lib/commander/command.rb:180:incall'
from /Library/Ruby/Gems/2.0.0/gems/commander-4.2.1/lib/commander/command.rb:155:in run' from /Library/Ruby/Gems/2.0.0/gems/commander-4.2.1/lib/commander/runner.rb:421:inrun_active_command'
from /Library/Ruby/Gems/2.0.0/gems/commander-4.2.1/lib/commander/runner.rb:81:in run!' from /Library/Ruby/Gems/2.0.0/gems/commander-4.2.1/lib/commander/delegates.rb:8:inrun!'
from /Library/Ruby/Gems/2.0.0/gems/commander-4.2.1/lib/commander/import.rb:10:in `block in <top (required)>'

$ pdf-extract extract -t --titles --sections XXX/ZZZ.pdf
/Library/Ruby/Gems/2.0.0/gems/pdf-extract-0.1.1/lib/font_metrics.rb:42:in initialize': undefined methodascent' for #PDF::Reader::Font:0x007fb951e449b0 (NoMethodError)
from /Library/Ruby/Gems/2.0.0/gems/pdf-extract-0.1.1/lib/model/characters.rb:134:in new' from /Library/Ruby/Gems/2.0.0/gems/pdf-extract-0.1.1/lib/model/characters.rb:134:inblock in build_fonts'
from /Library/Ruby/Gems/2.0.0/gems/pdf-extract-0.1.1/lib/model/characters.rb:131:in each' from /Library/Ruby/Gems/2.0.0/gems/pdf-extract-0.1.1/lib/model/characters.rb:131:inbuild_fonts'
from /Library/Ruby/Gems/2.0.0/gems/pdf-extract-0.1.1/lib/model/characters.rb:163:in block (2 levels) in include_in' from /Library/Ruby/Gems/2.0.0/gems/pdf-extract-0.1.1/lib/pdf.rb:81:incall'
from /Library/Ruby/Gems/2.0.0/gems/pdf-extract-0.1.1/lib/pdf.rb:81:in block (2 levels) in expand_listeners_to_callback_methods' from /Library/Ruby/Gems/2.0.0/gems/pdf-extract-0.1.1/lib/pdf.rb:170:inblock in invoke_calls'
from /Library/Ruby/Gems/2.0.0/gems/pdf-extract-0.1.1/lib/pdf.rb:169:in each' from /Library/Ruby/Gems/2.0.0/gems/pdf-extract-0.1.1/lib/pdf.rb:169:ininvoke_calls'
from /Library/Ruby/Gems/2.0.0/gems/pdf-extract-0.1.1/lib/pdf-extract.rb:42:in block in parse' from /Library/Ruby/Gems/2.0.0/gems/pdf-extract-0.1.1/lib/pdf-extract.rb:38:ineach'
from /Library/Ruby/Gems/2.0.0/gems/pdf-extract-0.1.1/lib/pdf-extract.rb:38:in parse' from /Library/Ruby/Gems/2.0.0/gems/pdf-extract-0.1.1/lib/pdf-extract.rb:53:inview'
from /Library/Ruby/Gems/2.0.0/gems/pdf-extract-0.1.1/bin/pdf-extract:115:in block (4 levels) in <top (required)>' from /Library/Ruby/Gems/2.0.0/gems/pdf-extract-0.1.1/bin/pdf-extract:112:ineach'
from /Library/Ruby/Gems/2.0.0/gems/pdf-extract-0.1.1/bin/pdf-extract:112:in block (3 levels) in <top (required)>' from /Library/Ruby/Gems/2.0.0/gems/commander-4.2.1/lib/commander/command.rb:180:incall'
from /Library/Ruby/Gems/2.0.0/gems/commander-4.2.1/lib/commander/command.rb:180:in call' from /Library/Ruby/Gems/2.0.0/gems/commander-4.2.1/lib/commander/command.rb:155:inrun'
from /Library/Ruby/Gems/2.0.0/gems/commander-4.2.1/lib/commander/runner.rb:421:in run_active_command' from /Library/Ruby/Gems/2.0.0/gems/commander-4.2.1/lib/commander/runner.rb:81:inrun!'
from /Library/Ruby/Gems/2.0.0/gems/commander-4.2.1/lib/commander/delegates.rb:8:in run!' from /Library/Ruby/Gems/2.0.0/gems/commander-4.2.1/lib/commander/import.rb:10:inblock in <top (required)>'

Here's my platform:

$ uname -a
Darwin Michaels-MacBook-Pro.local 14.0.0 Darwin Kernel Version 14.0.0: Fri Sep 19 00:26:44 PDT 2014; root:xnu-2782.1.97~2/RELEASE_X86_64 x86_64
$ gem list pdf-extract

*** LOCAL GEMS ***

pdf-extract (0.1.1)
$ ruby --version
ruby 2.0.0p481 (2014-05-08 revision 45883) [universal.x86_64-darwin14]

@mgree
Copy link

mgree commented Dec 18, 2014

So installing pdf-reader 1.1.1 and removing 1.3.3, despite what pdf-extract.gemspec says, fixes the first error (the missing 'ascent' method in PDF::Reader::Font). But I still get the [] error...

@mgree
Copy link

mgree commented Dec 18, 2014

And protecting the tallest_line = titles.first[:line_height] line in titles.rb with a check to return [] if there are no titles stops the crash, but then I don't get any results at all. Apparently pdf-extract finds neither titles nor sections in that PDF... :(

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants