4252
|
1 |
#Copyright ReportLab Europe Ltd. 2000-2016
|
2963
|
2 |
#see license.txt for license details
|
|
3 |
#history http://www.reportlab.co.uk/cgi-bin/viewcvs.cgi/public/reportlab/trunk/reportlab/docs/userguide/app_demos.py
|
2966
|
4 |
from tools.docco.rl_doc_utils import *
|
2963
|
5 |
|
|
6 |
Appendix1("ReportLab Demos")
|
|
7 |
disc("""In the subdirectories of $reportlab/demos$ there are a number of working examples showing
|
|
8 |
almost all aspects of reportlab in use.""")
|
|
9 |
|
|
10 |
heading2("""Odyssey""")
|
|
11 |
disc("""
|
|
12 |
The three scripts odyssey.py, dodyssey.py and fodyssey.py all take the file odyssey.txt
|
|
13 |
and produce PDF documents. The included odyssey.txt is short; a longer and more testing version
|
|
14 |
can be found at ftp://ftp.reportlab.com/odyssey.full.zip.
|
|
15 |
""")
|
|
16 |
eg("""
|
|
17 |
Windows
|
|
18 |
cd reportlab\\demos\\odyssey
|
|
19 |
python odyssey.py
|
|
20 |
start odyssey.pdf
|
|
21 |
|
|
22 |
Linux
|
|
23 |
cd reportlab/demos/odyssey
|
|
24 |
python odyssey.py
|
|
25 |
acrord odyssey.pdf
|
|
26 |
""")
|
|
27 |
disc("""Simple formatting is shown by the odyssey.py script. It runs quite fast,
|
|
28 |
but all it does is gather the text and force it onto the canvas pages. It does no paragraph
|
|
29 |
manipulation at all so you get to see the XML < & > tags.
|
|
30 |
""")
|
|
31 |
disc("""The scripts fodyssey.py and dodyssey.py handle paragraph formatting so you get
|
|
32 |
to see colour changes etc. Both scripts
|
|
33 |
use the document template class and the dodyssey.py script shows the ability to do dual column
|
|
34 |
layout and uses multiple page templates.
|
|
35 |
""")
|
|
36 |
|
|
37 |
heading2("""Standard Fonts and Colors""")
|
|
38 |
disc("""In $reportlab/demos/stdfonts$ the script stdfonts.py can be used to illustrate
|
|
39 |
ReportLab's standard fonts. Run the script using""")
|
|
40 |
eg("""
|
|
41 |
cd reportlab\\demos\\stdfonts
|
|
42 |
python stdfonts.py
|
|
43 |
""")
|
|
44 |
disc("""
|
|
45 |
to produce two PDF documents, StandardFonts_MacRoman.pdf &
|
|
46 |
StandardFonts_WinAnsi.pdf which show the two most common built in
|
|
47 |
font encodings.
|
|
48 |
""")
|
|
49 |
disc("""The colortest.py script in $reportlab/demos/colors$ demonstrates the different ways in which
|
|
50 |
reportlab can set up and use colors.""")
|
|
51 |
disc("""Try running the script and viewing the output document, colortest.pdf. This shows
|
|
52 |
different color spaces and a large selection of the colors which are named
|
|
53 |
in the $reportlab.lib.colors$ module.
|
|
54 |
""")
|
|
55 |
heading2("""Py2pdf""")
|
3015
|
56 |
disc("""Dinu Gherman contributed this useful script
|
2963
|
57 |
which uses reportlab to produce nicely colorized PDF documents from Python
|
|
58 |
scripts including bookmarks for classes, methods and functions.
|
|
59 |
To get a nice version of the main script try""")
|
|
60 |
eg("""
|
|
61 |
cd reportlab/demos/py2pdf
|
|
62 |
python py2pdf.py py2pdf.py
|
|
63 |
acrord py2pdf.pdf
|
|
64 |
""")
|
|
65 |
disc("""i.e. we used py2pdf to produce a nice version of py2pdf.py in
|
|
66 |
the document with the same rootname and a .pdf extension.
|
|
67 |
""")
|
|
68 |
disc("""
|
|
69 |
The py2pdf.py script has many options which are beyond the scope of this
|
|
70 |
simple introduction; consult the comments at the start of the script.
|
|
71 |
""")
|
|
72 |
heading2("Gadflypaper")
|
|
73 |
disc("""
|
|
74 |
The Python script, gfe.py, in $reportlab/demos/gadflypaper$ uses an inline style of
|
|
75 |
document preparation. The script almost entirely produced by Aaron Watters produces a document
|
|
76 |
describing Aaron's $gadfly$ in memory database for Python. To generate the document use
|
|
77 |
""")
|
|
78 |
eg("""
|
|
79 |
cd reportlab\\gadflypaper
|
|
80 |
python gfe.py
|
|
81 |
start gfe.pdf
|
|
82 |
""")
|
|
83 |
disc("""
|
|
84 |
everything in the PDF document was produced by the script which is why this is an inline style
|
|
85 |
of document production. So, to produce a header followed by some text the script uses functions
|
|
86 |
$header$ and $p$ which take some text and append to a global story list.
|
|
87 |
""")
|
|
88 |
eg('''
|
|
89 |
header("Conclusion")
|
|
90 |
|
|
91 |
p("""The revamped query engine design in Gadfly 2 supports
|
|
92 |
..........
|
|
93 |
and integration.""")
|
|
94 |
''')
|
|
95 |
heading2("""Pythonpoint""")
|
|
96 |
disc("""Andy Robinson has refined the pythonpoint.py script (in $reportlab\\demos\\pythonpoint$)
|
|
97 |
until it is a really useful script. It takes an input file containing an XML markup
|
|
98 |
and uses an xmllib style parser to map the tags into PDF slides. When run in its own directory
|
|
99 |
pythonpoint.py takes as a default input the file pythonpoint.xml and produces pythonpoint.pdf
|
|
100 |
which is documentation for Pythonpoint! You can also see it in action with an older paper
|
|
101 |
""")
|
|
102 |
eg("""
|
|
103 |
cd reportlab\\demos\\pythonpoint
|
|
104 |
python pythonpoint.py monterey.xml
|
|
105 |
start monterey.pdf
|
|
106 |
""")
|
|
107 |
disc("""
|
|
108 |
Not only is pythonpoint self documenting, but it also demonstrates reportlab and PDF. It uses
|
|
109 |
many features of reportlab (document templates, tables etc).
|
|
110 |
Exotic features of PDF such as fadeins and bookmarks are also shown to good effect. The use of
|
|
111 |
an XML document can be contrasted with the <i>inline</i> style of the gadflypaper demo; the
|
|
112 |
content is completely separate from the formatting
|
2966
|
113 |
""")
|