G'day James,
I used the following to create a minimal, 9-page, PDF document:
#!/usr/bin/env perl
use strict;
use warnings;
use PDF::API2;
my $pdf = PDF::API2::->new();
my $font = $pdf->font('Helvetica-Bold');
for my $content ('A' .. 'I') {
my $page = $pdf->page();
my $text = $page->text();
$text->font($font, 20);
$text->position(200, 700);
$text->text($content);
}
$pdf->save('DX.pdf');
A visual check of "DX.pdf", with Foxit Reader, showed nine pages with "A", "B", ..., "H", "I".
I pretty much copied your posted code. Here's my exact script:
#!/usr/bin/env perl
use strict;
use warnings;
use CAM::PDF;
my $pdf = CAM::PDF->new('DX.pdf');
my $np = $pdf->numPages();
print "Number of pages: $np\n";
$pdf->extractPages( 2..8 );
$pdf->cleanoutput('DXout.pdf');
When I ran this, the only output was:
Number of pages: 9
A visual check of "DXout.pdf", with Foxit Reader, showed seven pages with "B", ..., "H".
So, your code is behaving as expected.
This suggests a problem with your source PDF.
There could also be a problem with CAM::PDF itself:
there are currently 52 active bugs;
I did a quick scan but didn't see anything obvious; you may want to look more closely;
updating to the latest version might be warranted.
Thanks for posting your environment information.
I'm using Cygwin on Win10 (both updated less than 24 hours ago); Perl 5.36.0 (via Perlbrew); CAM::PDF 1.60 (latest version, newly installed as I haven't used that module previously); PDF::API2 2.043 (that's what I had, latest is 2.044).
As an afterthought, I did `perlbrew switch perl-5.34.0` and repeated the above tests.
I got the same successful results: your Perl version doesn't appear to be an issue.
For your PDF::API2 installation issue,
I suggest you post that separately
and include verbatim error & warning messages.
|