I have a series of PDFs named sequentially like so:
- 01_foo.pdf
- 02_bar.pdf
- 03_baz.pdf
- etc.
Using Ruby, is it possible to combine these into one big PDF while keeping them in sequence? I don't mind installing any necessary gems to do the job.
If this isn't possible in Ruby, how about another language? No commercial components, if possible.
Update: Jason Navarrete's suggestion lead to the perfect solution:
Place the PDF files needing to be combined in a directory along with pdftk (or make sure pdftk is in your PATH), then run the following script:
pdfs = Dir["[0-9][0-9]_*"].sort.join(" ")
`pdftk #{pdfs} output combined.pdf`
Or I could even do it as a one-liner from the command-line:
ruby -e '`pdftk #{Dir["[0-9][0-9]_*"].sort.join(" ")} output combined.pdf`'
Great suggestion Jason, perfect solution, thanks. Give him an up-vote people.