Skip to content

Commit

Permalink
Merge pull request #13 from abramovks/master
Browse files Browse the repository at this point in the history
Update pdftoimage.rb to fix "Error determining page count"
  • Loading branch information
robflynn authored Dec 20, 2024
2 parents a41ff11 + 25a7d2d commit 84b239d
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/pdftoimage.rb
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def exec(cmd, error = nil)
private

def page_size(filename, page)
cmd = "pdfinfo -f #{page} -l #{page} #{Shellwords.escape(filename)} | grep Page"
cmd = "pdfinfo -f #{page} -l #{page} #{Shellwords.escape(filename)} | grep -a Page"
output = exec(cmd)

matches = /^Page.*?size:.*?(\d+).*?(\d+)/.match(output)
Expand All @@ -92,7 +92,7 @@ def page_size(filename, page)
end

def page_count(filename)
cmd = "pdfinfo #{Shellwords.escape(filename)} | grep Pages"
cmd = "pdfinfo #{Shellwords.escape(filename)} | grep -a Pages"
output = exec(cmd)
matches = /^Pages:.*?(\d+)$/.match(output)
if matches.nil?
Expand Down

0 comments on commit 84b239d

Please sign in to comment.