Closed dasyurid closed 1 year ago
Take a look at ticket RT 106020 (rejected in PDF::API2, fixed in PDF::Builder). It sounds like the same thing.
This is indeed the same issue as RT 106020. The current PDF specification explicitly forbids extra characters on the first line of the PDF.
2.0:
The file header shall consist of “%PDF–1.n” or “%PDF–2.n” followed by a single EOL marker, where ‘n’ is a single digit number between 0 (30h) and 9 (39h).
Compare 1.7 (which in my opinion is also clear, but not quite as explicit):
The first line of a PDF file shall be a header consisting of the 5 characters %PDF– followed by a version number of the form 1.N, where N is a digit between 0 and 7.
Because of this, I'm opting to have PDF::API2 continue to consider these files as invalid PDFs, with the thought that generators that don't follow easy parts of the spec are likely to have issues with harder parts of the spec. That said, the workaround given in the RT ticket should still be valid if you want to take that chance. You can also write a script to turn the invalid PDF into a maybe-valid one by replacing the ninth and tenth characters with \n#
(inserting the required newline and ignoring anything else that was on that line) as long as there are at least ten characters before the first newline.
Some devices - notably Sharp MFDs - add extra text after the PDF version in the header line. While the standard doesn't forbid this, it doesn't explicitly allow it either. Nonetheless, most readers will open these files without comment. PDF::API2::Basic::PDF::File.pm rejects these files as invalid.
This change allows extra text on the header line to allow PDF::API2 to match generally accepted functionality. I've been using this patch in production for some time now with no problems.