ssimms / pdfapi2

Create, modify, and examine PDF files in Perl
Other
15 stars 20 forks source link

RT121911 re-open/fix -- off-by-one error #70

Closed vadim-160102 closed 3 months ago

vadim-160102 commented 9 months ago

Hi, looks like off-by-one error at

https://metacpan.org/dist/PDF-API2/source/lib/PDF/API2/Basic/PDF/Pages.pm#L183

where it should be "0", not "1" (rather, condition should be == -1, to the same effect). Currently, $pdf->page(1); adds a new page at the end for sample.pdf attached there. Alternatively, see Perl-PDF-Builder/issues/203 for a sample -- more interesting tree => curiouser bugs for positions other than "1". No bugs with fix as proposed

aaminoff commented 9 months ago

Thank you very much for fixing this. If you are ever in the Boston area NBER would be happy to treat you to lunch. We use PDF::API2 (which I will now transition to the patched version of PDF::Builder) to add the first 2 pages of all our working papers, see https://www.nber.org/papers