#=> A new file called combined.pdf which is the concatenation of the two
pdfs
I need to be able to run this in ruby because I would like to eventually
append all files that have the same names in two directories and put it
into one final directory. As a test this is the code I came up with.
So I ran your code and it put out the line but then had an error
pdfappend.rb:18:in ``': No such file or directory - pdftk 01_cool.pdf
02_cool.pdf cat output combined.pdf (Errno::ENOENT) from
pdfappend.rb:18:in '<main>'
I also tried putting quotations around the #{cmd} and that run with no
errors but did not output my new file
···
On Thu, Apr 26, 2012 at 1:07 PM, Christopher D. <lists@ruby-forum.com> > wrote:
Glad you got it working. One further note: you don't need to say things like
ex = Dir["P:\project\bin\pdftk.exe"]
file = Dir["P:\project\bin\combined.pdf"]
all the Dir[...] command does is expand shell wildcards for you. So
Dir["*.pdf"] will return an array of all the pdf files in the current
directory, but Dir["combined.pdf"] will just return back
["combined.pdf"] since there are no wildcards to expand.
martin
···
On Fri, Apr 27, 2012 at 9:15 AM, Christopher D. <lists@ruby-forum.com> wrote:
I couldn't edit my above post but I figured it out. Thank you martin!
Like martin mentioned you need to escape the slashes.
It looks like it isn't finding the pdftk executable. I'm not sure how
windows does path lookups - try calling it with the full path to pdftk
(e.g. "c:\program files\pdftk.exe #{pdfs}") instead of just pdftk. You
will probably need to escape the backslashes too.
martin
···
On Thu, Apr 26, 2012 at 1:38 PM, Christopher D. <lists@ruby-forum.com> wrote:
So I ran your code and it put out the line but then had an error
pdfappend.rb:18:in ``': No such file or directory - pdftk 01_cool.pdf
02_cool.pdf cat output combined.pdf (Errno::ENOENT) from
pdfappend.rb:18:in '<main>'
I also tried putting quotations around the #{cmd} and that run with no
errors but did not output my new file
So I ran your code and it put out the line but then had an error
pdfappend.rb:18:in ``': No such file or directory - pdftk 01_cool.pdf
02_cool.pdf cat output combined.pdf (Errno::ENOENT) from
pdfappend.rb:18:in '<main>'
I also tried putting quotations around the #{cmd} and that run with no
errors but did not output my new file
It looks like it isn't finding the pdftk executable. I'm not sure how
windows does path lookups - try calling it with the full path to pdftk
(e.g. "c:\program files\pdftk.exe #{pdfs}") instead of just pdftk. You
will probably need to escape the backslashes too.
martin
Appreciate the follow up.
So the pdftk definitely works but only in the command line. If I write
out