ssimms / pdfapi2

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

Page numbers in page_labels #61

Open sciurius opened 1 year ago

sciurius commented 1 year ago

2.042 introduced a new method to specify page labels, page_labels, deprecating the old pageLabels method. Simultaneously the page number parameter changed from 0-based to 1-based. Even though documented, it can be easily overlooked, as I did, and, in my case it led to PDF documents that were not correctly dealt with by certain viewers.

Would it be possible to add a warning in page_labels when the page parameter is less than 1?

ssimms commented 1 year ago

Are you aware of anywhere in the spec that says page numbers can't be negative? 7.9.7 Number Trees only says "integers", and 7.7.2 Document Catalog only says that index 0 must be present.

If index -1 (i.e. page_labels(0) isn't allowed, I'll make it an error rather than a warning. If it's allowed, though, I worry that if the code throws a warning, someone's going to complain that they meant to do that. That said, it's probably still better to throw a warning in that case (along with asking the person why they're doing that) and remove it later...

sciurius commented 1 year ago

Even if the spec doesn't explicitly forbid negative numbers apparently there are PDF viewers that complain. A warning is much appreciated.