Applied (mostly) as r3203 and r3201
[PyX/mjg.git] / faq / general_aspects_plotting.rst
blobf209ad9acba94994bd6eba0460b3d2860cae4b2b
1 ====================================
2 General aspects of plotting with PyX
3 ====================================
5 How do I generate multipage output?
6 ===================================
8 With versions 0.8 and higher it is possible to produce multipage output,
9 i.e. a Postscript or PDF file containing more than one page. In order to
10 achieve this, one creates pages by drawing on a canvas as usual and 
11 appends them in the desired order to a document from which Postscript or
12 PDF output is produced. The following example serves as an illustration::
14    from pyx import *
16    d = document.document()
17    for i in range(3):
18        c = canvas.canvas()
19        c.text(0, 0, "page %i" % (i+1))
20        d.append(document.page(c, paperformat=document.paperformat.A4,
21                                  margin=3*unit.t\_cm,
22                                  fittosize=1))
23    d.writePSfile("multipage")
25 Here, ``d`` is the document into which pages are inserted by means of the
26 ``append`` method. When converting from a canvas to a document page, the page
27 properties like the paperformat are specified. In the last line, output is
28 produced from document ``d``.