Top-rated recipes tagged "a4"http://code.activestate.com/recipes/tags/a4/top/2016-05-05T23:47:49-07:00ActiveState Code RecipesFind Paper Format of based on Pixel Width and Height of a (PDF) Page (Python)
2016-05-05T23:47:49-07:00Harald Liederhttp://code.activestate.com/recipes/users/4191581/http://code.activestate.com/recipes/580659-find-paper-format-of-based-on-pixel-width-and-heig/
<p style="color: grey">
Python
recipe 580659
by <a href="/recipes/users/4191581/">Harald Lieder</a>
(<a href="/recipes/tags/a4/">a4</a>, <a href="/recipes/tags/format/">format</a>, <a href="/recipes/tags/letter/">letter</a>, <a href="/recipes/tags/paper/">paper</a>).
</p>
<p>A simple function to determine what format page a page in document has. Parameters provided are width and height in float or integer format.</p>
<p>Return is a string like "A4-P" or "Letter-L" when an exact fit is found. If not, information is provided as a string like "width x height (other), closest <format> width x height". The closest format in this case is determined by minimizing the sum of absolute differences of width and height with a table of official formats.</p>