Deep recursion on subroutine "PDF::API2::Basic::PDF::Objind::release" at C:/Perl64/site/lib/PDF/API2/Basic/PDF/Objind.pm line 123.
Deep recursion on subroutine "PDF::API2::Basic::PDF::Objind::release" at C:/Perl64/site/lib/PDF/API2/Basic/PDF/Objind.pm line 123.
Deep recursion on subroutine "PDF::API2::Basic::PDF::Objind::release" at C:/Perl64/site/lib/PDF/API2/Basic/PDF/Objind.pm line 123.
...
####
#!/usr/bin/perl
use 5.018;
use PDF::API2;
use strict;
use warnings;
my $path = "./pdfs/";
my $out_pdf_file = 'merged.pdf';
my $out_pdf;
opendir (my $DIR, $path) or die "Could not open $path:\n$!\n$^E";
chdir $path;
while ( my $in_pdf_file = readdir $DIR ) {
next if $in_pdf_file =~ /^\./;
my $in_pdf = PDF::API2->open($in_pdf_file) or die "Error opening PDF file [$in_pdf_file]:\n$!\n$^E";
# Append to output if PDF already exists
if ( -e $out_pdf_file ) {
$out_pdf = PDF::API2->open($out_pdf_file);
}
# Create new PDF if output does not exist
else {
$out_pdf = PDF::API2->new(-file => $out_pdf_file);
}
foreach my $page ( 1 .. $in_pdf->pages() ) {
$out_pdf->import_page($in_pdf, $page, 0);
}
$out_pdf->update();
}
closedir $DIR;
####
perl -v
This is perl 5, version 18, subversion 2 (v5.18.2) built for MSWin32-x64-multi-thread
(with 1 registered patch, see perl -V for more detail)
Copyright 1987-2013, Larry Wall
Binary build 1802 [298023] provided by ActiveState http://www.ActiveState.com
Built Apr 15 2014 10:38:37
####
perl -MPDF::API2 -E "say $PDF::API2::VERSION;"
2.023
####
#!/usr/bin/perl
use 5.018;
use strict;
use warnings;
for my $i ( 1 .. 2_000 ) {
my $name = sprintf '%04d', $i;
my @args = (
'perl -E "for my $j (1..20) { print qq[PDF '.$name.' page $j\f\n]; }"',
'|',
'pcl6.exe -dNOPAUSE -sDEVICE=pdfwrite -sOutputFile=./pdfs/pdf_'.$name.'.pdf -',
);
system "@args";
}