except that there is a lot of other code and all of the above is in several other loops etc. There're a lot of source pdfs. The "$pdf_s->end();" will cause the error in the bad cases.use strict; use PDF::API2; my $source_pdf = $ARGV[0]; my $dest_pdf = $ARGV[1]; my $pdf_d = PDF::API2->new(); my $pdf_s = PDF::API2->open($source_pdf); for ( my $pdf_page = 1 ; $pdf_page <= $pdf_s->pages ; $pdf_page++ ){ my $pdf_d_page = $pdf_d->page(); my $pdf_d_pageform = $pdf_d->importPageIntoForm($pdf_s, $pdf_page); my $pdf_d_gfx = $pdf_d_page->gfx; $pdf_d_gfx->formimage($pdf_d_pageform, 0, 0, 1); } $pdf_s->end(); $pdf_d->saveas($dest_pdf); $pdf_d->end();
I'm afraid that I'm unable to supply the actual code or the source, problem pdfs.
While I can duplicate this 100% when it happens (perhaps with 1 in 100,000 source pdfs) with the actual script and I have isolated that the "$pdf_s->end()" is the problem line, I have not been able to replicate it in smaller test scripts using the same source pdfs yet. However I have found that if I replace the $pdf_s->end() with undef($pdf_s) everything seems to go perfectly in the production script with the problem source pdfs.
So I ask for your wisdom, Monks. Is replacing $pdf_s->end() as described a bad idea for some reason that I'm unaware of? Thanks.In reply to PDF::API2, $pdf->end by Tharg
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |