tags:

views:

1309

answers:

3

Using Perl, how can I combine or merge the sample PDF files into a single PDF file?

+2  A: 

You can use the GhostScript utility pdf2ps to convert the PDFs into PostScript files, concatenate the PostScript files, and then use ps2pdf to convert the result back into a PDF.

Adam Rosenfield
Why the downvote? At least leave a reason...
Adam Rosenfield
I think it's because your solution doesn't use Perl.
Nathan Fellman
Just because it's not a native Perl solutions doesn't mean it isn't any good. Perl can very easily invoke other utilities via the shell.
Adam Rosenfield
+10  A: 

CAM::PDF can do this quite easily, and has a simple command-line front end to help. Note: I'm the author of that library. Example:

appendpdf.pl file1.pdf file2.pdf outfile.pdf
Chris Dolan
Accept this answer.
Murali VP
+4  A: 

Why do you need to do it from Perl? Chris has already mentioned CAM::PDF.

If you just need to merge them, pdftk (PDF ToolKit) works just fine. It's a simple command line:

pdftk file1.pdf file2.pdf cat output merged.pdf
brian d foy