Skip to content

pdfinfo: improved paper size recognition

Paper sizes of ISO 216, A Series were originally defined in millimeters. For example, A3 is defined to be 297mm x 420mm. However, depending on source, the corresponding size in pts may vary between 1190pt and 1191pt for the longer edge.

pdfinfo's formula to compute the length of the longer edge of an A3 paper determines this length to be 1191.82pt. As the error margin so far was set to 1pt, A3 papers with edge length of 1190.8pt were not recognized as A3.

This patch makes the error margin depending on the paper size, setting it at 0.2% of the longer edge's length. For A3 paper, the error marging (variable 'isoThreshold') thus becomes 2.38pt.

Accordingly, the threshold for 'letter' paper has been raised from 0.1pt to 1pt.

This commit also beautifies printing the paper size further by adding the output of 'landscape', 'portrait', or 'square' in parenthesises after the paper size, depending on the ratio between 'w' (width) and 'h' (height). This output is made for all paper sizes, not just A Series paper.

Edited by Thomas Fischer

Merge request reports