ssimms / pdfapi2

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

More forgiving header parser #19

Closed gvsyn closed 4 years ago

gvsyn commented 6 years ago

When trying to open PDFs from Sharp scanners, open fails reporting invalid PDF version. The header is as follows:

%PDF-1.4 Sharp Scanned ImagePDF
%Sharp Non-Encryption
3 0 obj

From the PDF spec there are no restrictions stating that after the minor version there should be a newline or similar. Adjusted the code to not care what there is after the 1.x

coveralls commented 6 years ago

Coverage Status

Coverage decreased (-3.2%) to 56.734% when pulling 3bb732aa6b42e117b309abaca54a9817dc194e23 on gvsyn:pdf-header-parse into 4f48cd1e1676d28d453e29466b446032ab07a0ac on ssimms:master.

coveralls commented 6 years ago

Coverage Status

Coverage decreased (-3.2%) to 56.734% when pulling 3bb732aa6b42e117b309abaca54a9817dc194e23 on gvsyn:pdf-header-parse into 4f48cd1e1676d28d453e29466b446032ab07a0ac on ssimms:master.

dasyurid commented 4 years ago

Came here to do just this, nice to be beaten to it. I have this exact change patched into our systems, would love to see it merged.

My testing has not identified any problems, and on the upside, it fixes the problem failing to open valid PDFs.

gvsyn commented 4 years ago

@dasyurid It's probably worth re-doing, I thought I'd closed this whilst trying to look at the coverage problem (also it seems I nuked my fork).

Similarly, had to put this patch in at work. There are a slew of other font loading ones I've put in there, but they need cleaning up for more general use.