reportlab/lib/pagesizes.py
author andy_robinson
Wed, 26 Apr 2000 11:13:28 +0000
changeset 169 ddc05bdb0387
parent 44 2467c3df925e
child 270 01635bde618e
permissions -rw-r--r--
Fixed some broken pagesizes and added a landscape() function.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
40
19b843a1f8f6 initial checkin
andy_robinson
parents:
diff changeset
     1
#!/bin/env python
19b843a1f8f6 initial checkin
andy_robinson
parents:
diff changeset
     2
###############################################################################
19b843a1f8f6 initial checkin
andy_robinson
parents:
diff changeset
     3
#
19b843a1f8f6 initial checkin
andy_robinson
parents:
diff changeset
     4
#	ReportLab Public License Version 1.0
19b843a1f8f6 initial checkin
andy_robinson
parents:
diff changeset
     5
#
19b843a1f8f6 initial checkin
andy_robinson
parents:
diff changeset
     6
#   Except for the change of names the spirit and intention of this
19b843a1f8f6 initial checkin
andy_robinson
parents:
diff changeset
     7
#   license is the same as that of Python
19b843a1f8f6 initial checkin
andy_robinson
parents:
diff changeset
     8
#
19b843a1f8f6 initial checkin
andy_robinson
parents:
diff changeset
     9
#	(C) Copyright ReportLab Inc. 1998-2000.
19b843a1f8f6 initial checkin
andy_robinson
parents:
diff changeset
    10
#
19b843a1f8f6 initial checkin
andy_robinson
parents:
diff changeset
    11
#   adapted with permission from PIDDLE, original author Joe Strout
19b843a1f8f6 initial checkin
andy_robinson
parents:
diff changeset
    12
#
19b843a1f8f6 initial checkin
andy_robinson
parents:
diff changeset
    13
# All Rights Reserved
19b843a1f8f6 initial checkin
andy_robinson
parents:
diff changeset
    14
#
19b843a1f8f6 initial checkin
andy_robinson
parents:
diff changeset
    15
# Permission to use, copy, modify, and distribute this software and its
19b843a1f8f6 initial checkin
andy_robinson
parents:
diff changeset
    16
# documentation for any purpose and without fee is hereby granted, provided
19b843a1f8f6 initial checkin
andy_robinson
parents:
diff changeset
    17
# that the above copyright notice appear in all copies and that both that
19b843a1f8f6 initial checkin
andy_robinson
parents:
diff changeset
    18
# copyright notice and this permission notice appear in supporting
19b843a1f8f6 initial checkin
andy_robinson
parents:
diff changeset
    19
# documentation, and that the name of ReportLab not be used
19b843a1f8f6 initial checkin
andy_robinson
parents:
diff changeset
    20
# in advertising or publicity pertaining to distribution of the software
19b843a1f8f6 initial checkin
andy_robinson
parents:
diff changeset
    21
# without specific, written prior permission. 
19b843a1f8f6 initial checkin
andy_robinson
parents:
diff changeset
    22
# 
19b843a1f8f6 initial checkin
andy_robinson
parents:
diff changeset
    23
#
19b843a1f8f6 initial checkin
andy_robinson
parents:
diff changeset
    24
# Disclaimer
19b843a1f8f6 initial checkin
andy_robinson
parents:
diff changeset
    25
#
19b843a1f8f6 initial checkin
andy_robinson
parents:
diff changeset
    26
# ReportLab Inc. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
19b843a1f8f6 initial checkin
andy_robinson
parents:
diff changeset
    27
# SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS,
19b843a1f8f6 initial checkin
andy_robinson
parents:
diff changeset
    28
# IN NO EVENT SHALL ReportLab BE LIABLE FOR ANY SPECIAL, INDIRECT
19b843a1f8f6 initial checkin
andy_robinson
parents:
diff changeset
    29
# OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
19b843a1f8f6 initial checkin
andy_robinson
parents:
diff changeset
    30
# OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
19b843a1f8f6 initial checkin
andy_robinson
parents:
diff changeset
    31
# OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
19b843a1f8f6 initial checkin
andy_robinson
parents:
diff changeset
    32
# PERFORMANCE OF THIS SOFTWARE. 
19b843a1f8f6 initial checkin
andy_robinson
parents:
diff changeset
    33
#
19b843a1f8f6 initial checkin
andy_robinson
parents:
diff changeset
    34
###############################################################################
19b843a1f8f6 initial checkin
andy_robinson
parents:
diff changeset
    35
#	$Log: pagesizes.py,v $
169
ddc05bdb0387 Fixed some broken pagesizes and added a
andy_robinson
parents: 44
diff changeset
    36
#	Revision 1.3  2000/04/26 11:13:28  andy_robinson
ddc05bdb0387 Fixed some broken pagesizes and added a
andy_robinson
parents: 44
diff changeset
    37
#	Fixed some broken pagesizes and added a
ddc05bdb0387 Fixed some broken pagesizes and added a
andy_robinson
parents: 44
diff changeset
    38
#	landscape() function.
ddc05bdb0387 Fixed some broken pagesizes and added a
andy_robinson
parents: 44
diff changeset
    39
#
44
2467c3df925e Added DEFAULT_PAGE_SIZE at end
rgbecker
parents: 40
diff changeset
    40
#	Revision 1.2  2000/03/08 13:40:49  rgbecker
2467c3df925e Added DEFAULT_PAGE_SIZE at end
rgbecker
parents: 40
diff changeset
    41
#	Added DEFAULT_PAGE_SIZE at end
169
ddc05bdb0387 Fixed some broken pagesizes and added a
andy_robinson
parents: 44
diff changeset
    42
#	
40
19b843a1f8f6 initial checkin
andy_robinson
parents:
diff changeset
    43
#	Revision 1.1  2000/03/08 12:55:07  andy_robinson
19b843a1f8f6 initial checkin
andy_robinson
parents:
diff changeset
    44
#	initial checkin
44
2467c3df925e Added DEFAULT_PAGE_SIZE at end
rgbecker
parents: 40
diff changeset
    45
#	
40
19b843a1f8f6 initial checkin
andy_robinson
parents:
diff changeset
    46
19b843a1f8f6 initial checkin
andy_robinson
parents:
diff changeset
    47
"""This module defines a few common page sizes in points (1/72 inch).
19b843a1f8f6 initial checkin
andy_robinson
parents:
diff changeset
    48
To be expanded to include things like label sizes, envelope windows
19b843a1f8f6 initial checkin
andy_robinson
parents:
diff changeset
    49
etc."""
169
ddc05bdb0387 Fixed some broken pagesizes and added a
andy_robinson
parents: 44
diff changeset
    50
__version__=''' $Id: pagesizes.py,v 1.3 2000/04/26 11:13:28 andy_robinson Exp $ '''
40
19b843a1f8f6 initial checkin
andy_robinson
parents:
diff changeset
    51
19b843a1f8f6 initial checkin
andy_robinson
parents:
diff changeset
    52
from units import cm, inch
19b843a1f8f6 initial checkin
andy_robinson
parents:
diff changeset
    53
19b843a1f8f6 initial checkin
andy_robinson
parents:
diff changeset
    54
_W, _H = (21*cm, 29.7*cm)
19b843a1f8f6 initial checkin
andy_robinson
parents:
diff changeset
    55
19b843a1f8f6 initial checkin
andy_robinson
parents:
diff changeset
    56
A6 = (_W*.5, _H*.5)
19b843a1f8f6 initial checkin
andy_robinson
parents:
diff changeset
    57
A5 = (_H*.5, _W)
19b843a1f8f6 initial checkin
andy_robinson
parents:
diff changeset
    58
A4 = (_W, _H)
169
ddc05bdb0387 Fixed some broken pagesizes and added a
andy_robinson
parents: 44
diff changeset
    59
A3 = (_H, _W*2)
40
19b843a1f8f6 initial checkin
andy_robinson
parents:
diff changeset
    60
A2 = (_W*2, _H*2)
169
ddc05bdb0387 Fixed some broken pagesizes and added a
andy_robinson
parents: 44
diff changeset
    61
A1 = (_H*2, _W*4)
40
19b843a1f8f6 initial checkin
andy_robinson
parents:
diff changeset
    62
A0 = (_W*4, _H*4)
19b843a1f8f6 initial checkin
andy_robinson
parents:
diff changeset
    63
19b843a1f8f6 initial checkin
andy_robinson
parents:
diff changeset
    64
letter = (8.5*inch, 11*inch)
19b843a1f8f6 initial checkin
andy_robinson
parents:
diff changeset
    65
legal = (8.5*inch, 17*inch)
19b843a1f8f6 initial checkin
andy_robinson
parents:
diff changeset
    66
elevenSeventeen = (11*inch, 17*inch)
19b843a1f8f6 initial checkin
andy_robinson
parents:
diff changeset
    67
19b843a1f8f6 initial checkin
andy_robinson
parents:
diff changeset
    68
_BW, _BH = (25*cm, 35.3*cm)
19b843a1f8f6 initial checkin
andy_robinson
parents:
diff changeset
    69
B6 = (_BW*.5, _BH*.5)
19b843a1f8f6 initial checkin
andy_robinson
parents:
diff changeset
    70
B5 = (_BH*.5, _BW)
19b843a1f8f6 initial checkin
andy_robinson
parents:
diff changeset
    71
B4 = (_BW, _BH)
19b843a1f8f6 initial checkin
andy_robinson
parents:
diff changeset
    72
B3 = (_BH*2, _BW)
19b843a1f8f6 initial checkin
andy_robinson
parents:
diff changeset
    73
B2 = (_BW*2, _BH*2)
19b843a1f8f6 initial checkin
andy_robinson
parents:
diff changeset
    74
B1 = (_BH*4, _BW*2)
19b843a1f8f6 initial checkin
andy_robinson
parents:
diff changeset
    75
B0 = (_BW*4, _BH*4)
19b843a1f8f6 initial checkin
andy_robinson
parents:
diff changeset
    76
44
2467c3df925e Added DEFAULT_PAGE_SIZE at end
rgbecker
parents: 40
diff changeset
    77
#change this to suit your average needs
2467c3df925e Added DEFAULT_PAGE_SIZE at end
rgbecker
parents: 40
diff changeset
    78
DEFAULT_PAGE_SIZE = A4
169
ddc05bdb0387 Fixed some broken pagesizes and added a
andy_robinson
parents: 44
diff changeset
    79
ddc05bdb0387 Fixed some broken pagesizes and added a
andy_robinson
parents: 44
diff changeset
    80
def landscape(pagesize):
ddc05bdb0387 Fixed some broken pagesizes and added a
andy_robinson
parents: 44
diff changeset
    81
    """Use this to invert any pagesize"""
ddc05bdb0387 Fixed some broken pagesizes and added a
andy_robinson
parents: 44
diff changeset
    82
    return (pagesize[1], pagesize[0])
ddc05bdb0387 Fixed some broken pagesizes and added a
andy_robinson
parents: 44
diff changeset
    83