src/reportlab/lib/pagesizes.py
author robin <robin@reportlab.com>
Tue, 07 Mar 2017 10:00:34 +0000
changeset 4330 617ffa6bbdc8
parent 4327 b086b4e60ed7
child 4370 823a8c33ce43
permissions -rw-r--r--
changes for release 3.4.0
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
40
19b843a1f8f6 initial checkin
andy_robinson
parents:
diff changeset
     1
#!/bin/env python
4330
617ffa6bbdc8 changes for release 3.4.0
robin <robin@reportlab.com>
parents: 4327
diff changeset
     2
#Copyright ReportLab Europe Ltd. 2000-2017
494
54257447cfe9 Changed to indirect copyright
rgbecker
parents: 270
diff changeset
     3
#see license.txt for license details
2332
2a7ab4405e18 Remove $Header:, fix CopyRight & history
rgbecker
parents: 1683
diff changeset
     4
#history http://www.reportlab.co.uk/cgi-bin/viewcvs.cgi/public/reportlab/trunk/reportlab/lib/pagesizes.py
40
19b843a1f8f6 initial checkin
andy_robinson
parents:
diff changeset
     5
19b843a1f8f6 initial checkin
andy_robinson
parents:
diff changeset
     6
"""This module defines a few common page sizes in points (1/72 inch).
19b843a1f8f6 initial checkin
andy_robinson
parents:
diff changeset
     7
To be expanded to include things like label sizes, envelope windows
19b843a1f8f6 initial checkin
andy_robinson
parents:
diff changeset
     8
etc."""
4252
fe660f227cac changes for release 3.3.0
robin
parents: 3617
diff changeset
     9
__version__='3.3.0'
40
19b843a1f8f6 initial checkin
andy_robinson
parents:
diff changeset
    10
270
01635bde618e Some relative imports fixed
andy_robinson
parents: 169
diff changeset
    11
from reportlab.lib.units import cm, inch
40
19b843a1f8f6 initial checkin
andy_robinson
parents:
diff changeset
    12
19b843a1f8f6 initial checkin
andy_robinson
parents:
diff changeset
    13
_W, _H = (21*cm, 29.7*cm)
19b843a1f8f6 initial checkin
andy_robinson
parents:
diff changeset
    14
19b843a1f8f6 initial checkin
andy_robinson
parents:
diff changeset
    15
A6 = (_W*.5, _H*.5)
19b843a1f8f6 initial checkin
andy_robinson
parents:
diff changeset
    16
A5 = (_H*.5, _W)
19b843a1f8f6 initial checkin
andy_robinson
parents:
diff changeset
    17
A4 = (_W, _H)
169
ddc05bdb0387 Fixed some broken pagesizes and added a
andy_robinson
parents: 44
diff changeset
    18
A3 = (_H, _W*2)
40
19b843a1f8f6 initial checkin
andy_robinson
parents:
diff changeset
    19
A2 = (_W*2, _H*2)
169
ddc05bdb0387 Fixed some broken pagesizes and added a
andy_robinson
parents: 44
diff changeset
    20
A1 = (_H*2, _W*4)
40
19b843a1f8f6 initial checkin
andy_robinson
parents:
diff changeset
    21
A0 = (_W*4, _H*4)
19b843a1f8f6 initial checkin
andy_robinson
parents:
diff changeset
    22
1463
d434a14ed2ac portrait/landscape functions fixed
andy_robinson
parents: 843
diff changeset
    23
LETTER = (8.5*inch, 11*inch)
d434a14ed2ac portrait/landscape functions fixed
andy_robinson
parents: 843
diff changeset
    24
LEGAL = (8.5*inch, 14*inch)
d434a14ed2ac portrait/landscape functions fixed
andy_robinson
parents: 843
diff changeset
    25
ELEVENSEVENTEEN = (11*inch, 17*inch)
4327
b086b4e60ed7 more page sizes; contribution from alain chiasson @ bitbucket (from https://en.wikipedia.org/wiki/Paper_size)
robin <robin@reportlab.com>
parents: 4252
diff changeset
    26
b086b4e60ed7 more page sizes; contribution from alain chiasson @ bitbucket (from https://en.wikipedia.org/wiki/Paper_size)
robin <robin@reportlab.com>
parents: 4252
diff changeset
    27
# From https://en.wikipedia.org/wiki/Paper_size
b086b4e60ed7 more page sizes; contribution from alain chiasson @ bitbucket (from https://en.wikipedia.org/wiki/Paper_size)
robin <robin@reportlab.com>
parents: 4252
diff changeset
    28
JUNIOR_LEGAL = (5*inch, 8*inch)
b086b4e60ed7 more page sizes; contribution from alain chiasson @ bitbucket (from https://en.wikipedia.org/wiki/Paper_size)
robin <robin@reportlab.com>
parents: 4252
diff changeset
    29
HALF_LETTER = (5.5*inch, 8*inch)
b086b4e60ed7 more page sizes; contribution from alain chiasson @ bitbucket (from https://en.wikipedia.org/wiki/Paper_size)
robin <robin@reportlab.com>
parents: 4252
diff changeset
    30
GOV_LETTER = (8*inch, 10.5*inch)
b086b4e60ed7 more page sizes; contribution from alain chiasson @ bitbucket (from https://en.wikipedia.org/wiki/Paper_size)
robin <robin@reportlab.com>
parents: 4252
diff changeset
    31
GOV_LEGAL = (8.5*inch, 13*inch)
b086b4e60ed7 more page sizes; contribution from alain chiasson @ bitbucket (from https://en.wikipedia.org/wiki/Paper_size)
robin <robin@reportlab.com>
parents: 4252
diff changeset
    32
TABLOID = ELEVENSEVENTEEN
b086b4e60ed7 more page sizes; contribution from alain chiasson @ bitbucket (from https://en.wikipedia.org/wiki/Paper_size)
robin <robin@reportlab.com>
parents: 4252
diff changeset
    33
LEDGER = (17*inch, 11*inch)
b086b4e60ed7 more page sizes; contribution from alain chiasson @ bitbucket (from https://en.wikipedia.org/wiki/Paper_size)
robin <robin@reportlab.com>
parents: 4252
diff changeset
    34
1463
d434a14ed2ac portrait/landscape functions fixed
andy_robinson
parents: 843
diff changeset
    35
# lower case is deprecated as of 12/2001, but here
d434a14ed2ac portrait/landscape functions fixed
andy_robinson
parents: 843
diff changeset
    36
# for compatability
d434a14ed2ac portrait/landscape functions fixed
andy_robinson
parents: 843
diff changeset
    37
letter=LETTER
d434a14ed2ac portrait/landscape functions fixed
andy_robinson
parents: 843
diff changeset
    38
legal=LEGAL
d434a14ed2ac portrait/landscape functions fixed
andy_robinson
parents: 843
diff changeset
    39
elevenSeventeen = ELEVENSEVENTEEN
40
19b843a1f8f6 initial checkin
andy_robinson
parents:
diff changeset
    40
19b843a1f8f6 initial checkin
andy_robinson
parents:
diff changeset
    41
_BW, _BH = (25*cm, 35.3*cm)
19b843a1f8f6 initial checkin
andy_robinson
parents:
diff changeset
    42
B6 = (_BW*.5, _BH*.5)
19b843a1f8f6 initial checkin
andy_robinson
parents:
diff changeset
    43
B5 = (_BH*.5, _BW)
19b843a1f8f6 initial checkin
andy_robinson
parents:
diff changeset
    44
B4 = (_BW, _BH)
19b843a1f8f6 initial checkin
andy_robinson
parents:
diff changeset
    45
B3 = (_BH*2, _BW)
19b843a1f8f6 initial checkin
andy_robinson
parents:
diff changeset
    46
B2 = (_BW*2, _BH*2)
19b843a1f8f6 initial checkin
andy_robinson
parents:
diff changeset
    47
B1 = (_BH*4, _BW*2)
19b843a1f8f6 initial checkin
andy_robinson
parents:
diff changeset
    48
B0 = (_BW*4, _BH*4)
19b843a1f8f6 initial checkin
andy_robinson
parents:
diff changeset
    49
169
ddc05bdb0387 Fixed some broken pagesizes and added a
andy_robinson
parents: 44
diff changeset
    50
def landscape(pagesize):
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1463
diff changeset
    51
    """Use this to get page orientation right"""
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1463
diff changeset
    52
    a, b = pagesize
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1463
diff changeset
    53
    if a < b:
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1463
diff changeset
    54
        return (b, a)
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1463
diff changeset
    55
    else:
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1463
diff changeset
    56
        return (a, b)
1463
d434a14ed2ac portrait/landscape functions fixed
andy_robinson
parents: 843
diff changeset
    57
d434a14ed2ac portrait/landscape functions fixed
andy_robinson
parents: 843
diff changeset
    58
def portrait(pagesize):
1677
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1463
diff changeset
    59
    """Use this to get page orientation right"""
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1463
diff changeset
    60
    a, b = pagesize
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1463
diff changeset
    61
    if a >= b:
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1463
diff changeset
    62
        return (b, a)
1450177dd19e Exterminated all tab characters and added a test to make sure
andy_robinson
parents: 1463
diff changeset
    63
    else:
1683
7fa753e4420a Removed all trailing whitespace
andy_robinson
parents: 1677
diff changeset
    64
        return (a, b)