1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111
|
.. module:: document
======================
Module :mod:`document`
======================
.. sectionauthor:: Jörg Lehmann <joergl@users.sourceforge.net>
The document module contains two classes: :class:`document` and :class:`page`. A
:class:`document` consists of one or several :class:`page`\ s.
Class :class:`page`
-------------------
A :class:`page` is a thin wrapper around a :class:`canvas`, which defines some
additional properties of the page.
.. class:: page(canvas, pagename=None, paperformat=None, rotated=0, centered=1, fittosize=0, margin=1 * unit.t_cm, bboxenlarge=1 * unit.t_pt, bbox=None)
Construct a new :class:`page` from the given :class:`canvas` instance. A string
*pagename* and the *paperformat* can be defined. See below, for a list of known
paper formats. If *rotated* is set, the output is rotated by 90 degrees on the
page. If *centered* is set, the output is centered on the given paperformat. If
*fittosize* is set, the output is scaled to fill the full page except for a
given *margin*. Normally, the bounding box of the canvas is calculated
automatically from the bounding box of its elements. Alternatively, you may
specify the *bbox* manually. In any case, the bounding box is enlarged on all
sides by *bboxenlarge*.
Class :class:`document`
-----------------------
.. class:: document(pages=[])
Construct a :class:`document` consisting of a given list of *pages*.
A :class:`document` can be written to a file using one of the following methods:
.. method:: document.writeEPSfile(file, title=None, strip_fonts=True, text_as_path=False, mesh_as_bitmap=False, mesh_as_bitmap_resolution=300)
Write a single page :class:`document` to an EPS file. *title* is used as the
document title, *strip_fonts* enabled font stripping (removal of unused glyphs),
*text_as_path* converts all text to paths instead of using fonts in the output,
*mesh_as_bitmap* converts meshs (like 3d surface plots) to bitmaps (to reduce
complexity in the output) and *mesh_as_bitmap_resolution* is the resolution of
this conversion in dots per inch.
.. method:: document.writePSfile(file, writebbox=False, title=None, strip_fonts=True, text_as_path=False, mesh_as_bitmap=False, mesh_as_bitmap_resolution=300)
Write :class:`document` to a PS file. *writebbox* add the page bounding boxes to
the output. All other parameters are identical to the :meth:`writeEPSfile`
method.
.. method:: document.writePDFfile(file, title=None, author=None, subject=None, keywords=None, fullscreen=False, writebbox=False, compress=True, compresslevel=6, strip_fonts=True, text_as_path=False, mesh_as_bitmap=False, mesh_as_bitmap_resolution=300)
Write :class:`document` to a PDF file. *author*, *subject*, and *keywords* are
used for the document author, subject, and keyword information, respectively.
*fullscreen* enabled fullscreen mode when the document is opened, *writebbox*
enables writing of the crop box to each page, *compress* enables output stream
compression and *compresslevel* sets the compress level to be used (from 1 to
9). All other parameters are identical to the :meth:`writeEPSfile`.
.. method:: document.writetofile(filename, *args, **kwargs)
Determine the file type (EPS, PS, or PDF) from the file extension of *filename*
and call the corresponding write method with the given arguments *arg* and
*kwargs*.
Class :class:`paperformat`
--------------------------
.. class:: paperformat(width, height, name=None)
Define a :class:`paperformat` with the given *width* and *height* and the
optional *name*.
Predefined paperformats are listed in the following table
+--------------------------------------+--------+----------+---------+
| instance | name | width | height |
+======================================+========+==========+=========+
| :const:`document.paperformat.A0` | A0 | 840 mm | 1188 mm |
+--------------------------------------+--------+----------+---------+
| :const:`document.paperformat.A0b` | | 910 mm | 1370 mm |
+--------------------------------------+--------+----------+---------+
| :const:`document.paperformat.A1` | A1 | 594 mm | 840 mm |
+--------------------------------------+--------+----------+---------+
| :const:`document.paperformat.A2` | A2 | 420 mm | 594 mm |
+--------------------------------------+--------+----------+---------+
| :const:`document.paperformat.A3` | A3 | 297 mm | 420 mm |
+--------------------------------------+--------+----------+---------+
| :const:`document.paperformat.A4` | A4 | 210 mm | 297 mm |
+--------------------------------------+--------+----------+---------+
| :const:`document.paperformat.A5` | A5 | 148.5 mm | 210 mm |
+--------------------------------------+--------+----------+---------+
| :const:`document.paperformat.Letter` | Letter | 8.5 inch | 11 inch |
+--------------------------------------+--------+----------+---------+
| :const:`document.paperformat.Legal` | Legal | 8.5 inch | 14 inch |
+--------------------------------------+--------+----------+---------+
|