/ Published in: Perl
Merges one page of each PDFs after one another into a new PDF file
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
#!/usr/bin/env perl use strict; use warnings; use List::Util 'min'; use PDF::API2; die "usage: pdfmixmerge file1 [file2 ... fileN] \n" my @filenames = @ARGV; my $output_pdf = PDF::API2->new; for my $page_nb (1..$min ) { for my $pdf (@pdfs) { $output_pdf->importpage($pdf, $page_nb); } } # There might be some pages left, let's add them at the end $min++; for my $pdf (@pdfs) { for my $page_nb ($min .. $pdf->pages) { $output_pdf->importpage($pdf, $_) } } $output_pdf->saveas('bundle.pdf');