Tharg has asked for the wisdom of the Perl Monks concerning the following question:
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.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: PDF::API2, $pdf->end
by johnny_carlos (Scribe) on Nov 04, 2011 at 20:09 UTC | |
by Tharg (Scribe) on Nov 07, 2011 at 09:55 UTC | |
|
Re: PDF::API2, $pdf->end
by pvaldes (Chaplain) on Nov 04, 2011 at 20:09 UTC | |
by Tharg (Scribe) on Nov 07, 2011 at 10:02 UTC |