about summary refs log tree commit diff
path: root/.venv/lib/python3.12/site-packages/PyPDF2/papersizes.py
diff options
context:
space:
mode:
authorS. Solomon Darnell2025-03-28 21:52:21 -0500
committerS. Solomon Darnell2025-03-28 21:52:21 -0500
commit4a52a71956a8d46fcb7294ac71734504bb09bcc2 (patch)
treeee3dc5af3b6313e921cd920906356f5d4febc4ed /.venv/lib/python3.12/site-packages/PyPDF2/papersizes.py
parentcc961e04ba734dd72309fb548a2f97d67d578813 (diff)
downloadgn-ai-4a52a71956a8d46fcb7294ac71734504bb09bcc2.tar.gz
two version of R2R are here HEAD master
Diffstat (limited to '.venv/lib/python3.12/site-packages/PyPDF2/papersizes.py')
-rw-r--r--.venv/lib/python3.12/site-packages/PyPDF2/papersizes.py48
1 files changed, 48 insertions, 0 deletions
diff --git a/.venv/lib/python3.12/site-packages/PyPDF2/papersizes.py b/.venv/lib/python3.12/site-packages/PyPDF2/papersizes.py
new file mode 100644
index 00000000..51aa2de5
--- /dev/null
+++ b/.venv/lib/python3.12/site-packages/PyPDF2/papersizes.py
@@ -0,0 +1,48 @@
+"""Helper to get paper sizes."""
+
+from collections import namedtuple
+
+Dimensions = namedtuple("Dimensions", ["width", "height"])
+
+
+class PaperSize:
+    """(width, height) of the paper in portrait mode in pixels at 72 ppi."""
+
+    # Notes how to calculate it:
+    # 1. Get the size of the paper in mm
+    # 2. Convert it to inches (25.4 millimeters are equal to 1 inches)
+    # 3. Convert it to pixels ad 72dpi (1 inch is equal to 72 pixels)
+
+    # All Din-A paper sizes follow this pattern:
+    # 2xA(n-1) = A(n)
+    # So the height of the next bigger one is the width of the smaller one
+    # The ratio is always approximately the ratio 1:2**0.5
+    # Additionally, A0 is defined to have an area of 1 m**2
+    # Be aware of rounding issues!
+    A0 = Dimensions(2384, 3370)  # 841mm x 1189mm
+    A1 = Dimensions(1684, 2384)
+    A2 = Dimensions(1191, 1684)
+    A3 = Dimensions(842, 1191)
+    A4 = Dimensions(
+        595, 842
+    )  # Printer paper, documents - this is by far the most common
+    A5 = Dimensions(420, 595)  # Paperback books
+    A6 = Dimensions(298, 420)  # Post cards
+    A7 = Dimensions(210, 298)
+    A8 = Dimensions(147, 210)
+
+    # Envelopes
+    C4 = Dimensions(649, 918)
+
+
+_din_a = (
+    PaperSize.A0,
+    PaperSize.A1,
+    PaperSize.A2,
+    PaperSize.A3,
+    PaperSize.A4,
+    PaperSize.A5,
+    PaperSize.A6,
+    PaperSize.A7,
+    PaperSize.A8,
+)