P
Peter Bailey
Hi,
I need to process individual pages of PDFs. To do so, I need to get the
page count of the PDF, then, do some image magic with each page of that
PDF. So, first thing I do is use a utility that gives me that page
count. I get the page count, but,it's an array. And, it doesn't let me
treat that "array" as a number, so, I can't do what I want. Here's a
snippet of my script and what I get with it. Thanks.
Dir.chdir("N:/infoconpdf")
file = "ehs-X7917735.pdf"
pages = `pdfinfo #{file}`
pages = pages.scan(/^Pages:[ ]{2,99}([0-9]+)/)
puts pages
1.upto(pages) do |n|
puts n
end
I get this:
78
================ ArgumentError =====================
C:\Users\pb4072\Documents\scripts\RUBY\multitiffs.rb:12:in `>'
1.upto(pages) do |n|
C:\Users\pb4072\Documents\scripts\RUBY\multitiffs.rb:12:in `upto'
1.upto(pages) do |n|
C:\Users\pb4072\Documents\scripts\RUBY\multitiffs.rb:12:in `<main>'
1.upto(pages) do |n|
Exception: comparison of Fixnum with Array failed
Program exited with code 0
I need to process individual pages of PDFs. To do so, I need to get the
page count of the PDF, then, do some image magic with each page of that
PDF. So, first thing I do is use a utility that gives me that page
count. I get the page count, but,it's an array. And, it doesn't let me
treat that "array" as a number, so, I can't do what I want. Here's a
snippet of my script and what I get with it. Thanks.
Dir.chdir("N:/infoconpdf")
file = "ehs-X7917735.pdf"
pages = `pdfinfo #{file}`
pages = pages.scan(/^Pages:[ ]{2,99}([0-9]+)/)
puts pages
1.upto(pages) do |n|
puts n
end
I get this:
78
================ ArgumentError =====================
C:\Users\pb4072\Documents\scripts\RUBY\multitiffs.rb:12:in `>'
1.upto(pages) do |n|
C:\Users\pb4072\Documents\scripts\RUBY\multitiffs.rb:12:in `upto'
1.upto(pages) do |n|
C:\Users\pb4072\Documents\scripts\RUBY\multitiffs.rb:12:in `<main>'
1.upto(pages) do |n|
Exception: comparison of Fixnum with Array failed
Program exited with code 0