Reportlab源码阅读之常见纸张大小含A0至A10等
根据ISO 216规定下面纸张大小如下
A0 = (841毫米,1189毫米)
A1 = (594毫米,841毫米)
A2 = (420毫米,594毫米)
A3 = (297毫米,420毫米)
A4 = (210毫米,297毫米)
A5 = (148毫米,210毫米)
A6 = (105毫米,148毫米)
A7 = (74毫米,105毫米)
A8 = (52毫米,74毫米)
A9 = (37毫米,52毫米)
A10 = (26毫米,37毫米)
B0 = (1000毫米,1414毫米)
B1 = (707毫米,1000毫米)
B2 = (500毫米,707毫米)
B3 = (353毫米,500毫米)
B4 = (250毫米,353毫米)
B5 = (176毫米,250毫米)
B6 = (125毫米,176毫米)
B7 = (88毫米,125毫米)
B8 = (62毫米,88毫米)
B9 = (44毫米,62毫米)
B10 = (31毫米,44毫米)
C0 = (917毫米,1297毫米)
C1 = (648毫米,917毫米)
C2 = (458毫米,648毫米)
C3 = (324毫米,458毫米)
C4 = (229毫米,324毫米)
C5 = (162毫米,229毫米)
C6 = (114毫米,162毫米)
C7 = (81毫米,114毫米)
C8 = (57毫米,81毫米)
C9 = (40毫米,57毫米)
C10 = (28毫米,40毫米)
源码如下
__version__='3.4.18'
from reportlab.lib.units import mm, inch
#ISO 216 standard paer sizes; see eg https://en.wikipedia.org/wiki/ISO_216
A0 = (841*mm,1189*mm)
A1 = (594*mm,841*mm)
A2 = (420*mm,594*mm)
A3 = (297*mm,420*mm)
A4 = (210*mm,297*mm)
A5 = (148*mm,210*mm)
A6 = (105*mm,148*mm)
A7 = (74*mm,105*mm)
A8 = (52*mm,74*mm)
A9 = (37*mm,52*mm)
A10 = (26*mm,37*mm)
B0 = (1000*mm,1414*mm)
B1 = (707*mm,1000*mm)
B2 = (500*mm,707*mm)
B3 = (353*mm,500*mm)
B4 = (250*mm,353*mm)
B5 = (176*mm,250*mm)
B6 = (125*mm,176*mm)
B7 = (88*mm,125*mm)
B8 = (62*mm,88*mm)
B9 = (44*mm,62*mm)
B10 = (31*mm,44*mm)
C0 = (917*mm,1297*mm)
C1 = (648*mm,917*mm)
C2 = (458*mm,648*mm)
C3 = (324*mm,458*mm)
C4 = (229*mm,324*mm)
C5 = (162*mm,229*mm)
C6 = (114*mm,162*mm)
C7 = (81*mm,114*mm)
C8 = (57*mm,81*mm)
C9 = (40*mm,57*mm)
C10 = (28*mm,40*mm)
#American paper sizes
LETTER = (8.5*inch, 11*inch)
LEGAL = (8.5*inch, 14*inch)
ELEVENSEVENTEEN = (11*inch, 17*inch)
# From https://en.wikipedia.org/wiki/Paper_size
JUNIOR_LEGAL = (5*inch, 8*inch)
HALF_LETTER = (5.5*inch, 8*inch)
GOV_LETTER = (8*inch, 10.5*inch)
GOV_LEGAL = (8.5*inch, 13*inch)
TABLOID = ELEVENSEVENTEEN
LEDGER = (17*inch, 11*inch)
# lower case is deprecated as of 12/2001, but here
# for compatability
letter=LETTER
legal=LEGAL
elevenSeventeen = ELEVENSEVENTEEN
#functions to mess with pagesizes
def landscape(pagesize):
"""Use this to get page orientation right"""
a, b = pagesize
if a < b:
return (b, a)
else:
return (a, b)
def portrait(pagesize):
"""Use this to get page orientation right"""
a, b = pagesize
if a >= b:
return (b, a)
else:
return (a, b)
网友评论