I wanted to join multiple pdf files together. I usually have used pdftk but it has been retired. You can get a pdftk source rpm but it depends on gcj and several other packages that have been superseded in Fedora 21.
So an alternative is needed...
# install poppler-utils yum install poppler-utils # use the pdfunite command to join the pdfs pdfunite pdf1.pdf pdf2.pdf output.pdf
Winning!
The perl package PDF::API2 can also be used to create replacement programs for pdftk. I also needed a script that merged PDF files, so I wrote the following pdf-merge.pl:
use English;
use strict;
use PDF::API2;
my $output_pdf_file_name = pop @ARGV;
if (not @ARGV) {die "usage: perl $PROGRAM_NAME input-pdf-file ... input-pdf-file output-pdf-file\n";}
my $output_pdf = PDF::API2->new(-file => $output_pdf_file_name);
while (@ARGV)
{
my $input_pdf = PDF::API2->open(shift @ARGV);
my $number_of_input_pages = $input_pdf->pages();
for (my $page_number = 1; $page_number importpage($input_pdf, $page_number, 0);
} # for $page_number
} # while
$output_pdf->save();
exit 0;
Cut and paste didn't work too well. Nor did the "code" and "/code" tags that I tried to place around the perl code. And, of course, the HTML obliterated my indentation.
The inner loop should look like this:
for (my $page_number = 1; $page_number importpage($input_pdf, $page_number, 0);
} # for $page_number
If this doesn't look right, I'm not fixing it again.
For the correct source code, go here: http://www.panix.com/~levner/pdf-merge.pl
Thanks David,
Really like your Perl solution.
It can act as the basis of any number of PDF utilities... just code it up .
Link to PDF::API2 Docs
None of these utils allows manipulating pdf passwords, which is mostly what I use pdftk for.
So hopefully someone will update the spec file for the PDFtk to allow building under Fedora 21.