yob/pdf-preflight — Issue #3: Error with MinPpi rule on some PDFs
Author: tomtaylor
Created: 2012-01-21 14:10:57+00:00
State: open

I'm getting an error when I run the MinPpi rule against some PDFs ([here's a link to a sample file](http://files.newspaperclub.com.s3.amazonaws.com/tmp/10997.pdf) It happens on a couple of different Ruby versions.

Here's the stack trace on Ruby Enterprise Edition 1.8.7.

/Users/tom/.rbenv/versions/ree-1.8.7-2011.03/lib/ruby/1.8/matrix.rb:476:in `*': undefined method `*' for nil:NilClass (NoMethodError)
from /Users/tom/.rbenv/versions/ree-1.8.7-2011.03/lib/ruby/1.8/matrix.rb:474:in `upto'
from /Users/tom/.rbenv/versions/ree-1.8.7-2011.03/lib/ruby/1.8/matrix.rb:474:in `*'
from /Users/tom/.rbenv/versions/ree-1.8.7-2011.03/lib/ruby/gems/1.8/gems/bundler-1.0.21/lib/bundler/runtime.rb:68:in `collect'
from /Users/tom/.rbenv/versions/ree-1.8.7-2011.03/lib/ruby/1.8/matrix.rb:471:in `each'
from /Users/tom/.rbenv/versions/ree-1.8.7-2011.03/lib/ruby/1.8/matrix.rb:471:in `collect'
from /Users/tom/.rbenv/versions/ree-1.8.7-2011.03/lib/ruby/1.8/matrix.rb:471:in `*'
from /Users/tom/.rbenv/versions/ree-1.8.7-2011.03/lib/ruby/gems/1.8/gems/bundler-1.0.21/lib/bundler/runtime.rb:68:in `collect'
from /Users/tom/.rbenv/versions/ree-1.8.7-2011.03/lib/ruby/1.8/matrix.rb:469:in `each'
from /Users/tom/.rbenv/versions/ree-1.8.7-2011.03/lib/ruby/1.8/matrix.rb:469:in `collect'
from /Users/tom/.rbenv/versions/ree-1.8.7-2011.03/lib/ruby/1.8/matrix.rb:469:in `*'
from /Users/tom/.rbenv/versions/ree-1.8.7-2011.03/lib/ruby/gems/1.8/bundler/gems/pdf-preflight-7bb5c17a2390/lib/preflight/rules/min_ppi.rb:68:in `concatenate_matrix'
from /Users/tom/.rbenv/versions/ree-1.8.7-2011.03/lib/ruby/gems/1.8/bundler/gems/pdf-preflight-7bb5c17a2390/lib/preflight/rules/min_ppi.rb:82:in `invoke_xobject'
from /Users/tom/.rbenv/versions/ree-1.8.7-2011.03/lib/ruby/gems/1.8/gems/pdf-reader-1.0.0/lib/pdf/reader/form_xobject.rb:62:in `send'
from /Users/tom/.rbenv/versions/ree-1.8.7-2011.03/lib/ruby/gems/1.8/gems/pdf-reader-1.0.0/lib/pdf/reader/form_xobject.rb:62:in `callback'
from /Users/tom/.rbenv/versions/ree-1.8.7-2011.03/lib/ruby/gems/1.8/gems/pdf-reader-1.0.0/lib/pdf/reader/form_xobject.rb:61:in `each'
from /Users/tom/.rbenv/versions/ree-1.8.7-2011.03/lib/ruby/gems/1.8/gems/pdf-reader-1.0.0/lib/pdf/reader/form_xobject.rb:61:in `callback'
from /Users/tom/.rbenv/versions/ree-1.8.7-2011.03/lib/ruby/gems/1.8/gems/pdf-reader-1.0.0/lib/pdf/reader/form_xobject.rb:73:in `content_stream'
from /Users/tom/.rbenv/versions/ree-1.8.7-2011.03/lib/ruby/gems/1.8/gems/pdf-reader-1.0.0/lib/pdf/reader/form_xobject.rb:42:in `walk'
from /Users/tom/.rbenv/versions/ree-1.8.7-2011.03/lib/ruby/gems/1.8/bundler/gems/pdf-preflight-7bb5c17a2390/lib/preflight/rules/min_ppi.rb:105:in `invoke_form_xobject'
from /Users/tom/.rbenv/versions/ree-1.8.7-2011.03/lib/ruby/gems/1.8/bundler/gems/pdf-preflight-7bb5c17a2390/lib/preflight/rules/min_ppi.rb:85:in `invoke_xobject'
from /Users/tom/.rbenv/versions/ree-1.8.7-2011.03/lib/ruby/gems/1.8/gems/pdf-reader-1.0.0/lib/pdf/reader/page.rb:144:in `send'
from /Users/tom/.rbenv/versions/ree-1.8.7-2011.03/lib/ruby/gems/1.8/gems/pdf-reader-1.0.0/lib/pdf/reader/page.rb:144:in `callback'
from /Users/tom/.rbenv/versions/ree-1.8.7-2011.03/lib/ruby/gems/1.8/gems/pdf-reader-1.0.0/lib/pdf/reader/page.rb:143:in `each'
from /Users/tom/.rbenv/versions/ree-1.8.7-2011.03/lib/ruby/gems/1.8/gems/pdf-reader-1.0.0/lib/pdf/reader/page.rb:143:in `callback'
from /Users/tom/.rbenv/versions/ree-1.8.7-2011.03/lib/ruby/gems/1.8/gems/pdf-reader-1.0.0/lib/pdf/reader/page.rb:130:in `content_stream'
from /Users/tom/.rbenv/versions/ree-1.8.7-2011.03/lib/ruby/gems/1.8/gems/pdf-reader-1.0.0/lib/pdf/reader/page.rb:95:in `walk'
from /Users/tom/.rbenv/versions/ree-1.8.7-2011.03/lib/ruby/gems/1.8/bundler/gems/pdf-preflight-7bb5c17a2390/lib/preflight/profile.rb:91:in `check_pages'
from /Users/tom/.rbenv/versions/ree-1.8.7-2011.03/lib/ruby/gems/1.8/bundler/gems/pdf-preflight-7bb5c17a2390/lib/preflight/profile.rb:90:in `each'
from /Users/tom/.rbenv/versions/ree-1.8.7-2011.03/lib/ruby/gems/1.8/bundler/gems/pdf-preflight-7bb5c17a2390/lib/preflight/profile.rb:90:in `check_pages'
from /Users/tom/.rbenv/versions/ree-1.8.7-2011.03/lib/ruby/gems/1.8/bundler/gems/pdf-preflight-7bb5c17a2390/lib/preflight/profile.rb:63:in `check_io'
from /Users/tom/.rbenv/versions/ree-1.8.7-2011.03/lib/ruby/gems/1.8/gems/pdf-reader-1.0.0/lib/pdf/reader.rb:159:in `open'
from /Users/tom/.rbenv/versions/ree-1.8.7-2011.03/lib/ruby/gems/1.8/bundler/gems/pdf-preflight-7bb5c17a2390/lib/preflight/profile.rb:61:in `check_io'
from /Users/tom/.rbenv/versions/ree-1.8.7-2011.03/lib/ruby/gems/1.8/bundler/gems/pdf-preflight-7bb5c17a2390/lib/preflight/profile.rb:56:in `check_filename'
from /Users/tom/.rbenv/versions/ree-1.8.7-2011.03/lib/ruby/gems/1.8/bundler/gems/pdf-preflight-7bb5c17a2390/lib/preflight/profile.rb:55:in `open'
from /Users/tom/.rbenv/versions/ree-1.8.7-2011.03/lib/ruby/gems/1.8/bundler/gems/pdf-preflight-7bb5c17a2390/lib/preflight/profile.rb:55:in `check_filename'
from /Users/tom/.rbenv/versions/ree-1.8.7-2011.03/lib/ruby/gems/1.8/bundler/gems/pdf-preflight-7bb5c17a2390/lib/preflight/profile.rb:40:in `check'
from test.rb:15

If I switch to Ruby 1.9.2, a different error occurs:

/Users/tom/.rbenv/versions/1.9.2-p290/lib/ruby/gems/1.9.1/bundler/gems/pdf-preflight-7bb5c17a2390/lib/preflight/rules/min_ppi.rb:81:in `[]': can't convert Symbol into Integer (TypeError)
from /Users/tom/.rbenv/versions/1.9.2-p290/lib/ruby/gems/1.9.1/bundler/gems/pdf-preflight-7bb5c17a2390/lib/preflight/rules/min_ppi.rb:81:in `invoke_xobject'
from /Users/tom/.rbenv/versions/1.9.2-p290/lib/ruby/gems/1.9.1/gems/pdf-reader-1.0.0/lib/pdf/reader/form_xobject.rb:62:in `block in callback'
from /Users/tom/.rbenv/versions/1.9.2-p290/lib/ruby/gems/1.9.1/gems/pdf-reader-1.0.0/lib/pdf/reader/form_xobject.rb:61:in `each'
from /Users/tom/.rbenv/versions/1.9.2-p290/lib/ruby/gems/1.9.1/gems/pdf-reader-1.0.0/lib/pdf/reader/form_xobject.rb:61:in `callback'
from /Users/tom/.rbenv/versions/1.9.2-p290/lib/ruby/gems/1.9.1/gems/pdf-reader-1.0.0/lib/pdf/reader/form_xobject.rb:73:in `content_stream'
from /Users/tom/.rbenv/versions/1.9.2-p290/lib/ruby/gems/1.9.1/gems/pdf-reader-1.0.0/lib/pdf/reader/form_xobject.rb:42:in `walk'
from /Users/tom/.rbenv/versions/1.9.2-p290/lib/ruby/gems/1.9.1/bundler/gems/pdf-preflight-7bb5c17a2390/lib/preflight/rules/min_ppi.rb:105:in `invoke_form_xobject'
from /Users/tom/.rbenv/versions/1.9.2-p290/lib/ruby/gems/1.9.1/bundler/gems/pdf-preflight-7bb5c17a2390/lib/preflight/rules/min_ppi.rb:85:in `invoke_xobject'
from /Users/tom/.rbenv/versions/1.9.2-p290/lib/ruby/gems/1.9.1/gems/pdf-reader-1.0.0/lib/pdf/reader/page.rb:144:in `block in callback'
from /Users/tom/.rbenv/versions/1.9.2-p290/lib/ruby/gems/1.9.1/gems/pdf-reader-1.0.0/lib/pdf/reader/page.rb:143:in `each'
from /Users/tom/.rbenv/versions/1.9.2-p290/lib/ruby/gems/1.9.1/gems/pdf-reader-1.0.0/lib/pdf/reader/page.rb:143:in `callback'
from /Users/tom/.rbenv/versions/1.9.2-p290/lib/ruby/gems/1.9.1/gems/pdf-reader-1.0.0/lib/pdf/reader/page.rb:130:in `content_stream'
from /Users/tom/.rbenv/versions/1.9.2-p290/lib/ruby/gems/1.9.1/gems/pdf-reader-1.0.0/lib/pdf/reader/page.rb:95:in `walk'
from /Users/tom/.rbenv/versions/1.9.2-p290/lib/ruby/gems/1.9.1/bundler/gems/pdf-preflight-7bb5c17a2390/lib/preflight/profile.rb:91:in `block in check_pages'
from /Users/tom/.rbenv/versions/1.9.2-p290/lib/ruby/gems/1.9.1/bundler/gems/pdf-preflight-7bb5c17a2390/lib/preflight/profile.rb:90:in `each'
from /Users/tom/.rbenv/versions/1.9.2-p290/lib/ruby/gems/1.9.1/bundler/gems/pdf-preflight-7bb5c17a2390/lib/preflight/profile.rb:90:in `check_pages'
from /Users/tom/.rbenv/versions/1.9.2-p290/lib/ruby/gems/1.9.1/bundler/gems/pdf-preflight-7bb5c17a2390/lib/preflight/profile.rb:63:in `block in check_io'
from /Users/tom/.rbenv/versions/1.9.2-p290/lib/ruby/gems/1.9.1/gems/pdf-reader-1.0.0/lib/pdf/reader.rb:159:in `open'
from /Users/tom/.rbenv/versions/1.9.2-p290/lib/ruby/gems/1.9.1/bundler/gems/pdf-preflight-7bb5c17a2390/lib/preflight/profile.rb:61:in `check_io'
from /Users/tom/.rbenv/versions/1.9.2-p290/lib/ruby/gems/1.9.1/bundler/gems/pdf-preflight-7bb5c17a2390/lib/preflight/profile.rb:56:in `block in check_filename'
from /Users/tom/.rbenv/versions/1.9.2-p290/lib/ruby/gems/1.9.1/bundler/gems/pdf-preflight-7bb5c17a2390/lib/preflight/profile.rb:55:in `open'
from /Users/tom/.rbenv/versions/1.9.2-p290/lib/ruby/gems/1.9.1/bundler/gems/pdf-preflight-7bb5c17a2390/lib/preflight/profile.rb:55:in `check_filename'
from /Users/tom/.rbenv/versions/1.9.2-p290/lib/ruby/gems/1.9.1/bundler/gems/pdf-preflight-7bb5c17a2390/lib/preflight/profile.rb:40:in `check'
from test.rb:15:in `

'