;;; paper-size-iso-us.el --- -*- lexical-binding: t; -*- ;; This program is free software; you can redistribute it and/or modify ;; it under the terms of the GNU General Public License as published by ;; the Free Software Foundation, either version 3 of the License, or ;; (at your option) any later version. ;; This program is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;; GNU General Public License for more details. ;; You should have received a copy of the GNU General Public License ;; along with this program. If not, see . ;;; Commentary: ;; ;;; References: ;; http://www.printernational.org/iso-paper-sizes.php ;; https://papersizes.io/a/ ;; https://en.wikipedia.org/wiki/Pixel_density ;; https://blog.gimm.io/difference-between-pixel-px-and-point-pt-font-sizes-in-email-signatures/ ;; https://honeywellaidc.force.com/supportppr/s/article/How-to-convert-inches-in-dots ;; https://www.shutterstock.com/blog/inches-to-pixels-resize-image-quality ;; https://www.shutterstock.com/blog/ppi-vs-dpi-resolution-guidex ;; https://www.pixelsconverter.com/ (defvar paper-size-iso '(;; Size Width x Height(mm) Width x Height(in) (4A0 . [1682 2378 66.2 93.6 ]) (2A0 . [1189 1682 46.8 66.2 ]) (A0 . [841 1189 33.1 46.8 ]) (A1 . [594 841 23.4 33.1 ]) (A2 . [420 594 16.5 23.4 ]) (A3 . [297 420 11.7 16.5 ]) (A4 . [210 297 8.3 11.7 ]) (A5 . [148 210 5.8 8.3 ]) (A6 . [105 148 4.1 5.8 ]) (A7 . [74 105 2.9 4.1 ]) (A8 . [52 74 2.0 2.9 ]) (A9 . [37 52 1.5 2.0 ]) (A10 . [26 37 1.0 1.5 ]) (A11 . [18 26 0.7 1 ]) (A12 . [13 18 0.5 0.7 ]) (A13 . [9 13 0.4 0.5 ]) (2A0 . [1189 1682 46.8 66.2 ]) (4A0 . [1682 2378 66.2 93.6 ]) (A0+ . [914 1292 36 50.9 ]) (A1+ . [609 914 24 36 ]) (A3+ . [329 483 13 19 ]) (A2-extra . [445 619 17.51 24.3 ]) (A3-extra . [322 445 12.67 17.51]) (A3-Super . [305 508 12 20 ]) (Super-A3 . [305 487 12 19.17]) (A4-extra . [235 322 9.25 12.67]) (A4-Super . [229 322 9.25 12.67]) (Super-A4 . [227 356 8.93 14.01]) (A4-Long . [210 348 8.26 13.7 ]) (A5-extra . [173 235 8.26 9.25 ]) (SO-B5-extra . [202 276 7.95 10.86]) (B0 . [1000 1414 33.37 55.67]) (B1 . [707 1000 27.84 39.37]) (B2 . [500 707 19.69 27.84]) (B3 . [353 500 13.9 19.69]) (B4 . [250 352 9.84 13.9 ]) (B5 . [176 250 6.93 9.84 ]) (B6 . [125 176 4.92 6.93 ]) (B7 . [88 125 3.47 4.92 ]) (B8 . [62 88 2.44 3.47 ]) (B9 . [44 62 1.73 2.44 ]) (B10 . [31 44 1.22 1.73 ]) (B11 . [22 31 0.9 1.2 ]) (B12 . [15 22 0.6 0.9 ]) (B13 . [11 15 0.4 0.6 ]) (B0+ . [1118 1580 44 62.2 ]) (B1+ . [720 1020 28.3 40.2 ]) (B2+ . [520 720 20.5 28.3 ]) (C0 . [917 1297 36.12 51.6 ]) (C1 . [648 917 25.50 36.12]) (C2 . [458 648 18 25.50]) (C3 . [324 458 12.75 18 ]) (C4 . [229 324 9 12.75]) (C5 . [162 229 6.38 9 ]) (C6 . [114 162 4.5 6.38 ]) (C7 . [81 114 3.19 4.5 ]) (C8 . [57 81 2.2 3.2 ]) (C9 . [40 57 1.6 2.2 ]) (C10 . [28 40 1.1 1.6 ]) (C6/C5 . [229 114 9 4.5 ]) (C7/C6 . [81 162 3.19 6.38 ]) (DL . [110 220 4.32 8.69 ]) (E4 . [400 280 15.7 11 ]) )) (defun paper-size-dimensions (format) "Return dimensions in inch for given FORMAT as specified in ISO standard for paper sizes." (cdr (assoc format paper-size-iso))) (defun paper-size-iso-mm-to-pixels (format resolution) (let* ((dims (paper-size-dimensions format)) (width (aref dims 0)) (height (aref dims 1))) (paper-size-pixels width height 'mm resolution))) (defun paper-size-iso-in-to-pixels (format resolution) (let* ((dims (paper-size-dimensions format)) (width (aref dims 2)) (height (aref dims 3))) (paper-size-pixels width height 'in resolution))) (defun paper-size-pixels (width height unit resolution) "Return size in pixels from width and height. UNIT is unit of dimension measurement, either millimmeter or inches. For millimeter pass 'mm, for inches pass 'in. Resolution is number of either pixels per inches for the screen, or dots per inches for printers. Resolution-unit is either 'ppi for the screen or 'dpi for printers" (when (equal unit 'mm) (setq width (/ width 25.4)) (setq height (/ height 25.4))) (setq width (fround (* width resolution))) (setq height (fround (* height resolution))) (cons (ftruncate width) (ftruncate height))) (provide 'paper-size-iso)