author  andy_robinson 
Mon, 03 Jul 2000 15:50:31 +0000  
changeset 317  fce6dad947c3 
parent 314  72c75740504b 
child 318  03c9f114c621 
permissions  rwrr 
273
cd705b27b6a5
initial checkin. user guide generation framework.
aaron_watters
parents:
diff
changeset

1 
#!/bin/env python 
cd705b27b6a5
initial checkin. user guide generation framework.
aaron_watters
parents:
diff
changeset

2 
############################################################################### 
cd705b27b6a5
initial checkin. user guide generation framework.
aaron_watters
parents:
diff
changeset

3 
# 
317
fce6dad947c3
Pushed down most existing lessons one level; added
andy_robinson
parents:
314
diff
changeset

4 
# ReportLab Public License Version 1.0 
273
cd705b27b6a5
initial checkin. user guide generation framework.
aaron_watters
parents:
diff
changeset

5 
# 
cd705b27b6a5
initial checkin. user guide generation framework.
aaron_watters
parents:
diff
changeset

6 
# Except for the change of names the spirit and intention of this 
cd705b27b6a5
initial checkin. user guide generation framework.
aaron_watters
parents:
diff
changeset

7 
# license is the same as that of Python 
cd705b27b6a5
initial checkin. user guide generation framework.
aaron_watters
parents:
diff
changeset

8 
# 
317
fce6dad947c3
Pushed down most existing lessons one level; added
andy_robinson
parents:
314
diff
changeset

9 
# (C) Copyright ReportLab Inc. 19982000. 
273
cd705b27b6a5
initial checkin. user guide generation framework.
aaron_watters
parents:
diff
changeset

10 
# 
cd705b27b6a5
initial checkin. user guide generation framework.
aaron_watters
parents:
diff
changeset

11 
# 
cd705b27b6a5
initial checkin. user guide generation framework.
aaron_watters
parents:
diff
changeset

12 
# All Rights Reserved 
cd705b27b6a5
initial checkin. user guide generation framework.
aaron_watters
parents:
diff
changeset

13 
# 
cd705b27b6a5
initial checkin. user guide generation framework.
aaron_watters
parents:
diff
changeset

14 
# Permission to use, copy, modify, and distribute this software and its 
cd705b27b6a5
initial checkin. user guide generation framework.
aaron_watters
parents:
diff
changeset

15 
# documentation for any purpose and without fee is hereby granted, provided 
cd705b27b6a5
initial checkin. user guide generation framework.
aaron_watters
parents:
diff
changeset

16 
# that the above copyright notice appear in all copies and that both that 
cd705b27b6a5
initial checkin. user guide generation framework.
aaron_watters
parents:
diff
changeset

17 
# copyright notice and this permission notice appear in supporting 
cd705b27b6a5
initial checkin. user guide generation framework.
aaron_watters
parents:
diff
changeset

18 
# documentation, and that the name of ReportLab not be used 
cd705b27b6a5
initial checkin. user guide generation framework.
aaron_watters
parents:
diff
changeset

19 
# in advertising or publicity pertaining to distribution of the software 
cd705b27b6a5
initial checkin. user guide generation framework.
aaron_watters
parents:
diff
changeset

20 
# without specific, written prior permission. 
cd705b27b6a5
initial checkin. user guide generation framework.
aaron_watters
parents:
diff
changeset

21 
# 
cd705b27b6a5
initial checkin. user guide generation framework.
aaron_watters
parents:
diff
changeset

22 
# 
cd705b27b6a5
initial checkin. user guide generation framework.
aaron_watters
parents:
diff
changeset

23 
# Disclaimer 
cd705b27b6a5
initial checkin. user guide generation framework.
aaron_watters
parents:
diff
changeset

24 
# 
cd705b27b6a5
initial checkin. user guide generation framework.
aaron_watters
parents:
diff
changeset

25 
# ReportLab Inc. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS 
cd705b27b6a5
initial checkin. user guide generation framework.
aaron_watters
parents:
diff
changeset

26 
# SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, 
cd705b27b6a5
initial checkin. user guide generation framework.
aaron_watters
parents:
diff
changeset

27 
# IN NO EVENT SHALL ReportLab BE LIABLE FOR ANY SPECIAL, INDIRECT 
cd705b27b6a5
initial checkin. user guide generation framework.
aaron_watters
parents:
diff
changeset

28 
# OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS 
cd705b27b6a5
initial checkin. user guide generation framework.
aaron_watters
parents:
diff
changeset

29 
# OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR 
cd705b27b6a5
initial checkin. user guide generation framework.
aaron_watters
parents:
diff
changeset

30 
# OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR 
cd705b27b6a5
initial checkin. user guide generation framework.
aaron_watters
parents:
diff
changeset

31 
# PERFORMANCE OF THIS SOFTWARE. 
cd705b27b6a5
initial checkin. user guide generation framework.
aaron_watters
parents:
diff
changeset

32 
# 
cd705b27b6a5
initial checkin. user guide generation framework.
aaron_watters
parents:
diff
changeset

33 
############################################################################### 
317
fce6dad947c3
Pushed down most existing lessons one level; added
andy_robinson
parents:
314
diff
changeset

34 
# $Log: genuserguide.py,v $ 
fce6dad947c3
Pushed down most existing lessons one level; added
andy_robinson
parents:
314
diff
changeset

35 
# Revision 1.14 2000/07/03 15:50:31 andy_robinson 
fce6dad947c3
Pushed down most existing lessons one level; added
andy_robinson
parents:
314
diff
changeset

36 
# Pushed down most existing lessons one level; added 
fce6dad947c3
Pushed down most existing lessons one level; added
andy_robinson
parents:
314
diff
changeset

37 
# functions heading1..heading3 for building story 
fce6dad947c3
Pushed down most existing lessons one level; added
andy_robinson
parents:
314
diff
changeset

38 
# unambiguously; spelled Hugh Hefner right! 
314  39 
# 
317
fce6dad947c3
Pushed down most existing lessons one level; added
andy_robinson
parents:
314
diff
changeset

40 
# Revision 1.13 2000/07/03 09:51:38 rgbecker 
fce6dad947c3
Pushed down most existing lessons one level; added
andy_robinson
parents:
314
diff
changeset

41 
# abspath is 1.5.2 only 
fce6dad947c3
Pushed down most existing lessons one level; added
andy_robinson
parents:
314
diff
changeset

42 
# 
fce6dad947c3
Pushed down most existing lessons one level; added
andy_robinson
parents:
314
diff
changeset

43 
# Revision 1.12 2000/06/28 16:10:00 rgbecker 
fce6dad947c3
Pushed down most existing lessons one level; added
andy_robinson
parents:
314
diff
changeset

44 
# Fix unwanted 'i' 
fce6dad947c3
Pushed down most existing lessons one level; added
andy_robinson
parents:
314
diff
changeset

45 
# 
fce6dad947c3
Pushed down most existing lessons one level; added
andy_robinson
parents:
314
diff
changeset

46 
# Revision 1.11 2000/06/28 14:52:43 rgbecker 
fce6dad947c3
Pushed down most existing lessons one level; added
andy_robinson
parents:
314
diff
changeset

47 
# Documentation changes 
fce6dad947c3
Pushed down most existing lessons one level; added
andy_robinson
parents:
314
diff
changeset

48 
# 
fce6dad947c3
Pushed down most existing lessons one level; added
andy_robinson
parents:
314
diff
changeset

49 
# Revision 1.10 2000/06/27 10:09:48 rgbecker 
fce6dad947c3
Pushed down most existing lessons one level; added
andy_robinson
parents:
314
diff
changeset

50 
# Minor cosmetic changes 
fce6dad947c3
Pushed down most existing lessons one level; added
andy_robinson
parents:
314
diff
changeset

51 
# 
fce6dad947c3
Pushed down most existing lessons one level; added
andy_robinson
parents:
314
diff
changeset

52 
# Revision 1.9 2000/06/23 21:09:03 aaron_watters 
fce6dad947c3
Pushed down most existing lessons one level; added
andy_robinson
parents:
314
diff
changeset

53 
# text text and more text 
fce6dad947c3
Pushed down most existing lessons one level; added
andy_robinson
parents:
314
diff
changeset

54 
# 
fce6dad947c3
Pushed down most existing lessons one level; added
andy_robinson
parents:
314
diff
changeset

55 
# Revision 1.8 2000/06/22 19:05:24 aaron_watters 
fce6dad947c3
Pushed down most existing lessons one level; added
andy_robinson
parents:
314
diff
changeset

56 
# added quickhack for font changes in paragraphs and lots of new text 
fce6dad947c3
Pushed down most existing lessons one level; added
andy_robinson
parents:
314
diff
changeset

57 
# 
fce6dad947c3
Pushed down most existing lessons one level; added
andy_robinson
parents:
314
diff
changeset

58 
# Revision 1.7 2000/06/22 13:55:59 aaron_watters 
fce6dad947c3
Pushed down most existing lessons one level; added
andy_robinson
parents:
314
diff
changeset

59 
# showPage resets all state parameters warning. 
fce6dad947c3
Pushed down most existing lessons one level; added
andy_robinson
parents:
314
diff
changeset

60 
# 
fce6dad947c3
Pushed down most existing lessons one level; added
andy_robinson
parents:
314
diff
changeset

61 
# Revision 1.6 2000/06/22 13:35:28 aaron_watters 
fce6dad947c3
Pushed down most existing lessons one level; added
andy_robinson
parents:
314
diff
changeset

62 
# textobject and pathobject methods, among other things 
fce6dad947c3
Pushed down most existing lessons one level; added
andy_robinson
parents:
314
diff
changeset

63 
# 
fce6dad947c3
Pushed down most existing lessons one level; added
andy_robinson
parents:
314
diff
changeset

64 
# Revision 1.5 2000/06/21 21:19:29 aaron_watters 
fce6dad947c3
Pushed down most existing lessons one level; added
andy_robinson
parents:
314
diff
changeset

65 
# colors, line styles, more examples 
fce6dad947c3
Pushed down most existing lessons one level; added
andy_robinson
parents:
314
diff
changeset

66 
# 
fce6dad947c3
Pushed down most existing lessons one level; added
andy_robinson
parents:
314
diff
changeset

67 
# Revision 1.4 2000/06/21 15:16:05 aaron_watters 
fce6dad947c3
Pushed down most existing lessons one level; added
andy_robinson
parents:
314
diff
changeset

68 
# Lots of graphical examples added 
fce6dad947c3
Pushed down most existing lessons one level; added
andy_robinson
parents:
314
diff
changeset

69 
# 
fce6dad947c3
Pushed down most existing lessons one level; added
andy_robinson
parents:
314
diff
changeset

70 
# Revision 1.3 2000/06/20 20:31:42 aaron_watters 
fce6dad947c3
Pushed down most existing lessons one level; added
andy_robinson
parents:
314
diff
changeset

71 
# typos and more examples 
fce6dad947c3
Pushed down most existing lessons one level; added
andy_robinson
parents:
314
diff
changeset

72 
# 
fce6dad947c3
Pushed down most existing lessons one level; added
andy_robinson
parents:
314
diff
changeset

73 
# Revision 1.2 2000/06/19 21:13:02 aaron_watters 
fce6dad947c3
Pushed down most existing lessons one level; added
andy_robinson
parents:
314
diff
changeset

74 
# 2nd try. more text 
fce6dad947c3
Pushed down most existing lessons one level; added
andy_robinson
parents:
314
diff
changeset

75 
# 
fce6dad947c3
Pushed down most existing lessons one level; added
andy_robinson
parents:
314
diff
changeset

76 
# Revision 1.1 2000/06/17 02:57:56 aaron_watters 
fce6dad947c3
Pushed down most existing lessons one level; added
andy_robinson
parents:
314
diff
changeset

77 
# initial checkin. user guide generation framework. 
fce6dad947c3
Pushed down most existing lessons one level; added
andy_robinson
parents:
314
diff
changeset

78 
# 
fce6dad947c3
Pushed down most existing lessons one level; added
andy_robinson
parents:
314
diff
changeset

79 
__version__=''' $Id: genuserguide.py,v 1.14 2000/07/03 15:50:31 andy_robinson Exp $ ''' 
273
cd705b27b6a5
initial checkin. user guide generation framework.
aaron_watters
parents:
diff
changeset

80 

cd705b27b6a5
initial checkin. user guide generation framework.
aaron_watters
parents:
diff
changeset

81 

cd705b27b6a5
initial checkin. user guide generation framework.
aaron_watters
parents:
diff
changeset

82 
__doc__ = """ 
cd705b27b6a5
initial checkin. user guide generation framework.
aaron_watters
parents:
diff
changeset

83 
This module contains the script for building the user guide. 
cd705b27b6a5
initial checkin. user guide generation framework.
aaron_watters
parents:
diff
changeset

84 
""" 
cd705b27b6a5
initial checkin. user guide generation framework.
aaron_watters
parents:
diff
changeset

85 

317
fce6dad947c3
Pushed down most existing lessons one level; added
andy_robinson
parents:
314
diff
changeset

86 
_oldStyle=0 #change to 1 to get Aaron's original 
310  87 
if _oldStyle: 
317
fce6dad947c3
Pushed down most existing lessons one level; added
andy_robinson
parents:
314
diff
changeset

88 
from reportlab.lib.styles import getSampleStyleSheet 
fce6dad947c3
Pushed down most existing lessons one level; added
andy_robinson
parents:
314
diff
changeset

89 
styleSheet = getSampleStyleSheet() 
310  90 
else: 
317
fce6dad947c3
Pushed down most existing lessons one level; added
andy_robinson
parents:
314
diff
changeset

91 
import os, sys 
fce6dad947c3
Pushed down most existing lessons one level; added
andy_robinson
parents:
314
diff
changeset

92 
sys.path.insert(0,os.path.join(os.path.dirname(sys.argv[0]),'..','tools')) 
fce6dad947c3
Pushed down most existing lessons one level; added
andy_robinson
parents:
314
diff
changeset

93 
from rltemplate import RLDocTemplate 
fce6dad947c3
Pushed down most existing lessons one level; added
andy_robinson
parents:
314
diff
changeset

94 
from stylesheet import getStyleSheet 
fce6dad947c3
Pushed down most existing lessons one level; added
andy_robinson
parents:
314
diff
changeset

95 
styleSheet = getStyleSheet() 
310  96 

273
cd705b27b6a5
initial checkin. user guide generation framework.
aaron_watters
parents:
diff
changeset

97 
from reportlab.platypus.doctemplate import SimpleDocTemplate 
cd705b27b6a5
initial checkin. user guide generation framework.
aaron_watters
parents:
diff
changeset

98 
from reportlab.platypus.flowables import Flowable 
cd705b27b6a5
initial checkin. user guide generation framework.
aaron_watters
parents:
diff
changeset

99 
from reportlab.lib.units import inch 
cd705b27b6a5
initial checkin. user guide generation framework.
aaron_watters
parents:
diff
changeset

100 
from reportlab.lib.pagesizes import letter 
308  101 
from reportlab.platypus import Paragraph, Spacer, Preformatted, PageBreak, CondPageBreak 
310  102 
from reportlab.lib.styles import ParagraphStyle 
273
cd705b27b6a5
initial checkin. user guide generation framework.
aaron_watters
parents:
diff
changeset

103 
from reportlab.lib import colors 
317
fce6dad947c3
Pushed down most existing lessons one level; added
andy_robinson
parents:
314
diff
changeset

104 
from reportlab.lib.sequencer import getSequencer 
273
cd705b27b6a5
initial checkin. user guide generation framework.
aaron_watters
parents:
diff
changeset

105 
import examples 
cd705b27b6a5
initial checkin. user guide generation framework.
aaron_watters
parents:
diff
changeset

106 

cd705b27b6a5
initial checkin. user guide generation framework.
aaron_watters
parents:
diff
changeset

107 
from reportlab.lib.corp import ReportLabLogo 
cd705b27b6a5
initial checkin. user guide generation framework.
aaron_watters
parents:
diff
changeset

108 
LOGO = ReportLabLogo(0.25*inch, 0.25*inch, inch, 0.75*inch) 
cd705b27b6a5
initial checkin. user guide generation framework.
aaron_watters
parents:
diff
changeset

109 

301
5ad57f31ae75
added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents:
300
diff
changeset

110 
from t_parse import Template 
5ad57f31ae75
added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents:
300
diff
changeset

111 
QFcodetemplate = Template("X$X$", "X") 
5ad57f31ae75
added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents:
300
diff
changeset

112 
QFreptemplate = Template("X^X^", "X") 
310  113 
if _oldStyle: 
317
fce6dad947c3
Pushed down most existing lessons one level; added
andy_robinson
parents:
314
diff
changeset

114 
codesubst = "%s<font name=courier color=green>%s</font>" 
fce6dad947c3
Pushed down most existing lessons one level; added
andy_robinson
parents:
314
diff
changeset

115 
QFsubst = "%s<font name=Helvetica color=blue><i>%s</i></font>" 
310  116 
else: 
317
fce6dad947c3
Pushed down most existing lessons one level; added
andy_robinson
parents:
314
diff
changeset

117 
codesubst = "%s<b><font name=courier></b>%s</font>" 
fce6dad947c3
Pushed down most existing lessons one level; added
andy_robinson
parents:
314
diff
changeset

118 
QFsubst = "%s<font name=Helvetica><i>%s</i></font>" 
fce6dad947c3
Pushed down most existing lessons one level; added
andy_robinson
parents:
314
diff
changeset

119 

301
5ad57f31ae75
added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents:
300
diff
changeset

120 

5ad57f31ae75
added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents:
300
diff
changeset

121 
def quickfix(text): 
5ad57f31ae75
added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents:
300
diff
changeset

122 
"""inside text find any subsequence of form $subsequence$. 
5ad57f31ae75
added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents:
300
diff
changeset

123 
Format the subsequence as code. If similarly if text contains ^arg^ 
5ad57f31ae75
added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents:
300
diff
changeset

124 
format the arg as replaceable. The escape sequence for literal 
5ad57f31ae75
added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents:
300
diff
changeset

125 
$ is $\\$ (^ is ^\\^. 
5ad57f31ae75
added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents:
300
diff
changeset

126 
""" 
5ad57f31ae75
added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents:
300
diff
changeset

127 
from string import join 
5ad57f31ae75
added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents:
300
diff
changeset

128 
for (template,subst) in [(QFcodetemplate, codesubst), (QFreptemplate, QFsubst)]: 
5ad57f31ae75
added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents:
300
diff
changeset

129 
fragment = text 
5ad57f31ae75
added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents:
300
diff
changeset

130 
parts = [] 
5ad57f31ae75
added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents:
300
diff
changeset

131 
try: 
5ad57f31ae75
added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents:
300
diff
changeset

132 
while fragment: 
5ad57f31ae75
added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents:
300
diff
changeset

133 
try: 
5ad57f31ae75
added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents:
300
diff
changeset

134 
(matches, index) = template.PARSE(fragment) 
5ad57f31ae75
added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents:
300
diff
changeset

135 
except: raise ValueError 
5ad57f31ae75
added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents:
300
diff
changeset

136 
else: 
5ad57f31ae75
added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents:
300
diff
changeset

137 
[prefix, code] = matches 
5ad57f31ae75
added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents:
300
diff
changeset

138 
if code == "\\": 
5ad57f31ae75
added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents:
300
diff
changeset

139 
part = fragment[:index] 
5ad57f31ae75
added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents:
300
diff
changeset

140 
else: 
5ad57f31ae75
added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents:
300
diff
changeset

141 
part = subst % (prefix, code) 
5ad57f31ae75
added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents:
300
diff
changeset

142 
parts.append(part) 
5ad57f31ae75
added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents:
300
diff
changeset

143 
fragment = fragment[index:] 
5ad57f31ae75
added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents:
300
diff
changeset

144 
except ValueError: 
5ad57f31ae75
added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents:
300
diff
changeset

145 
parts.append(fragment) 
5ad57f31ae75
added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents:
300
diff
changeset

146 
text = join(parts, "") 
5ad57f31ae75
added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents:
300
diff
changeset

147 
return text 
5ad57f31ae75
added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents:
300
diff
changeset

148 
#print quickfix("$testing$ testing $one$ ^two^ $three(^four^)$") 
5ad57f31ae75
added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents:
300
diff
changeset

149 

310  150 
if _oldStyle: 
317
fce6dad947c3
Pushed down most existing lessons one level; added
andy_robinson
parents:
314
diff
changeset

151 
class PageAnnotations: 
fce6dad947c3
Pushed down most existing lessons one level; added
andy_robinson
parents:
314
diff
changeset

152 
""" "closure" containing onfirstpage, onnextpage actions 
fce6dad947c3
Pushed down most existing lessons one level; added
andy_robinson
parents:
314
diff
changeset

153 
and any data they might want to use. 
fce6dad947c3
Pushed down most existing lessons one level; added
andy_robinson
parents:
314
diff
changeset

154 
""" 
fce6dad947c3
Pushed down most existing lessons one level; added
andy_robinson
parents:
314
diff
changeset

155 
pagesize = letter 
fce6dad947c3
Pushed down most existing lessons one level; added
andy_robinson
parents:
314
diff
changeset

156 
pagenumber = 1 
fce6dad947c3
Pushed down most existing lessons one level; added
andy_robinson
parents:
314
diff
changeset

157 
def onFirstPage(self, canvas, doc): 
fce6dad947c3
Pushed down most existing lessons one level; added
andy_robinson
parents:
314
diff
changeset

158 
(xsize, ysize) = self.pagesize 
fce6dad947c3
Pushed down most existing lessons one level; added
andy_robinson
parents:
314
diff
changeset

159 
LOGO.draw(canvas) 
fce6dad947c3
Pushed down most existing lessons one level; added
andy_robinson
parents:
314
diff
changeset

160 
# width=6.25*inch,height=0.62*inch) 
fce6dad947c3
Pushed down most existing lessons one level; added
andy_robinson
parents:
314
diff
changeset

161 
canvas.setFont("Helvetica", 12) 
fce6dad947c3
Pushed down most existing lessons one level; added
andy_robinson
parents:
314
diff
changeset

162 
canvas.drawRightString(xsizeinch, ysize0.8*inch, "ReportLab User Guide") 
fce6dad947c3
Pushed down most existing lessons one level; added
andy_robinson
parents:
314
diff
changeset

163 
self.pagenumber = self.pagenumber+1 
fce6dad947c3
Pushed down most existing lessons one level; added
andy_robinson
parents:
314
diff
changeset

164 
def onNextPage(self, canvas, doc): 
fce6dad947c3
Pushed down most existing lessons one level; added
andy_robinson
parents:
314
diff
changeset

165 
canvas.saveState() 
fce6dad947c3
Pushed down most existing lessons one level; added
andy_robinson
parents:
314
diff
changeset

166 
(xsize, ysize) = self.pagesize 
fce6dad947c3
Pushed down most existing lessons one level; added
andy_robinson
parents:
314
diff
changeset

167 
canvas.setFont("Helvetica", 12) 
fce6dad947c3
Pushed down most existing lessons one level; added
andy_robinson
parents:
314
diff
changeset

168 
canvas.drawString(inch, ysize0.8*inch, "Page %s" % self.pagenumber) 
fce6dad947c3
Pushed down most existing lessons one level; added
andy_robinson
parents:
314
diff
changeset

169 
self.onFirstPage(canvas, doc) 
fce6dad947c3
Pushed down most existing lessons one level; added
andy_robinson
parents:
314
diff
changeset

170 
canvas.restoreState() 
273
cd705b27b6a5
initial checkin. user guide generation framework.
aaron_watters
parents:
diff
changeset

171 

cd705b27b6a5
initial checkin. user guide generation framework.
aaron_watters
parents:
diff
changeset

172 
class Guide: 
cd705b27b6a5
initial checkin. user guide generation framework.
aaron_watters
parents:
diff
changeset

173 
def __init__(self): 
310  174 
if _oldStyle: 
175 
self.myannotations = PageAnnotations() 

273
cd705b27b6a5
initial checkin. user guide generation framework.
aaron_watters
parents:
diff
changeset

176 
self.story = story() 
cd705b27b6a5
initial checkin. user guide generation framework.
aaron_watters
parents:
diff
changeset

177 
def go(self, filename="userguide.pdf"): 
cd705b27b6a5
initial checkin. user guide generation framework.
aaron_watters
parents:
diff
changeset

178 
# generate the doc... 
310  179 
doc = RLDocTemplate(filename,pagesize = letter) 
180 
story = self.story 

181 
if _oldStyle: 

182 
doc.build(story, self.myannotations.onFirstPage, self.myannotations.onNextPage) 

183 
else: 

184 
doc.build(story) 

317
fce6dad947c3
Pushed down most existing lessons one level; added
andy_robinson
parents:
314
diff
changeset

185 
seq = getSequencer() 
273
cd705b27b6a5
initial checkin. user guide generation framework.
aaron_watters
parents:
diff
changeset

186 

310  187 
H1 = styleSheet['Heading1'] 
188 
H2 = styleSheet['Heading2'] 

317
fce6dad947c3
Pushed down most existing lessons one level; added
andy_robinson
parents:
314
diff
changeset

189 
H3 = styleSheet['Heading3'] 
273
cd705b27b6a5
initial checkin. user guide generation framework.
aaron_watters
parents:
diff
changeset

190 
B = styleSheet['BodyText'] 
317
fce6dad947c3
Pushed down most existing lessons one level; added
andy_robinson
parents:
314
diff
changeset

191 
Comment = styleSheet['Comment'] 
fce6dad947c3
Pushed down most existing lessons one level; added
andy_robinson
parents:
314
diff
changeset

192 

310  193 
if _oldStyle: 
317
fce6dad947c3
Pushed down most existing lessons one level; added
andy_robinson
parents:
314
diff
changeset

194 
lessonnamestyle = ParagraphStyle("lessonname", parent=H2) 
fce6dad947c3
Pushed down most existing lessons one level; added
andy_robinson
parents:
314
diff
changeset

195 
lessonnamestyle.fontName = 'HelveticaBold' 
fce6dad947c3
Pushed down most existing lessons one level; added
andy_robinson
parents:
314
diff
changeset

196 
discussiontextstyle = ParagraphStyle("discussiontext", parent=B) 
fce6dad947c3
Pushed down most existing lessons one level; added
andy_robinson
parents:
314
diff
changeset

197 
discussiontextstyle.fontName= 'Helvetica' 
310  198 
else: 
317
fce6dad947c3
Pushed down most existing lessons one level; added
andy_robinson
parents:
314
diff
changeset

199 
lessonnamestyle = H2 
fce6dad947c3
Pushed down most existing lessons one level; added
andy_robinson
parents:
314
diff
changeset

200 
discussiontextstyle = B 
273
cd705b27b6a5
initial checkin. user guide generation framework.
aaron_watters
parents:
diff
changeset

201 
exampletextstyle = styleSheet['Code'] 
cd705b27b6a5
initial checkin. user guide generation framework.
aaron_watters
parents:
diff
changeset

202 
# size for every example 
283  203 
examplefunctionxinches = 5.5 
204 
examplefunctionyinches = 3 

205 
examplefunctiondisplaysizes = (examplefunctionxinches*inch, examplefunctionyinches*inch) 

273
cd705b27b6a5
initial checkin. user guide generation framework.
aaron_watters
parents:
diff
changeset

206 

cd705b27b6a5
initial checkin. user guide generation framework.
aaron_watters
parents:
diff
changeset

207 
# for testing 
cd705b27b6a5
initial checkin. user guide generation framework.
aaron_watters
parents:
diff
changeset

208 
def NOP(*x,**y): 
cd705b27b6a5
initial checkin. user guide generation framework.
aaron_watters
parents:
diff
changeset

209 
return None 
cd705b27b6a5
initial checkin. user guide generation framework.
aaron_watters
parents:
diff
changeset

210 

cd705b27b6a5
initial checkin. user guide generation framework.
aaron_watters
parents:
diff
changeset

211 
BODY = [] 
cd705b27b6a5
initial checkin. user guide generation framework.
aaron_watters
parents:
diff
changeset

212 
def story(): 
cd705b27b6a5
initial checkin. user guide generation framework.
aaron_watters
parents:
diff
changeset

213 
return BODY 
cd705b27b6a5
initial checkin. user guide generation framework.
aaron_watters
parents:
diff
changeset

214 

cd705b27b6a5
initial checkin. user guide generation framework.
aaron_watters
parents:
diff
changeset

215 
def disc(text, klass=Paragraph, style=discussiontextstyle): 
301
5ad57f31ae75
added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents:
300
diff
changeset

216 
text = quickfix(text) 
273
cd705b27b6a5
initial checkin. user guide generation framework.
aaron_watters
parents:
diff
changeset

217 
P = klass(text, style) 
cd705b27b6a5
initial checkin. user guide generation framework.
aaron_watters
parents:
diff
changeset

218 
BODY.append(P) 
cd705b27b6a5
initial checkin. user guide generation framework.
aaron_watters
parents:
diff
changeset

219 

cd705b27b6a5
initial checkin. user guide generation framework.
aaron_watters
parents:
diff
changeset

220 
def eg(text): 
cd705b27b6a5
initial checkin. user guide generation framework.
aaron_watters
parents:
diff
changeset

221 
BODY.append(Spacer(0.1*inch, 0.1*inch)) 
cd705b27b6a5
initial checkin. user guide generation framework.
aaron_watters
parents:
diff
changeset

222 
disc(text, klass=Preformatted, style=exampletextstyle) 
cd705b27b6a5
initial checkin. user guide generation framework.
aaron_watters
parents:
diff
changeset

223 

cd705b27b6a5
initial checkin. user guide generation framework.
aaron_watters
parents:
diff
changeset

224 
#eg(""" 
cd705b27b6a5
initial checkin. user guide generation framework.
aaron_watters
parents:
diff
changeset

225 
#this 
cd705b27b6a5
initial checkin. user guide generation framework.
aaron_watters
parents:
diff
changeset

226 
# is 
cd705b27b6a5
initial checkin. user guide generation framework.
aaron_watters
parents:
diff
changeset

227 
# an 
cd705b27b6a5
initial checkin. user guide generation framework.
aaron_watters
parents:
diff
changeset

228 
# example""") 
317
fce6dad947c3
Pushed down most existing lessons one level; added
andy_robinson
parents:
314
diff
changeset

229 

fce6dad947c3
Pushed down most existing lessons one level; added
andy_robinson
parents:
314
diff
changeset

230 
##def head(text,style=lessonnamestyle): 
fce6dad947c3
Pushed down most existing lessons one level; added
andy_robinson
parents:
314
diff
changeset

231 
## BODY.append(CondPageBreak(inch)) 
fce6dad947c3
Pushed down most existing lessons one level; added
andy_robinson
parents:
314
diff
changeset

232 
## disc(text, style=style) 
273
cd705b27b6a5
initial checkin. user guide generation framework.
aaron_watters
parents:
diff
changeset

233 

310  234 

235 
def title(text): 

317
fce6dad947c3
Pushed down most existing lessons one level; added
andy_robinson
parents:
314
diff
changeset

236 
"""Use this for the document title only""" 
fce6dad947c3
Pushed down most existing lessons one level; added
andy_robinson
parents:
314
diff
changeset

237 
disc(text,style=styleSheet['Title']) 
fce6dad947c3
Pushed down most existing lessons one level; added
andy_robinson
parents:
314
diff
changeset

238 

fce6dad947c3
Pushed down most existing lessons one level; added
andy_robinson
parents:
314
diff
changeset

239 
##def lesson(text): 
fce6dad947c3
Pushed down most existing lessons one level; added
andy_robinson
parents:
314
diff
changeset

240 
## BODY.append(PageBreak()) 
fce6dad947c3
Pushed down most existing lessons one level; added
andy_robinson
parents:
314
diff
changeset

241 
## heading3(text,style=H1) 
273
cd705b27b6a5
initial checkin. user guide generation framework.
aaron_watters
parents:
diff
changeset

242 

317
fce6dad947c3
Pushed down most existing lessons one level; added
andy_robinson
parents:
314
diff
changeset

243 
#heading3("this is a header") 
fce6dad947c3
Pushed down most existing lessons one level; added
andy_robinson
parents:
314
diff
changeset

244 

fce6dad947c3
Pushed down most existing lessons one level; added
andy_robinson
parents:
314
diff
changeset

245 
#AR 3/7/2000  defining three new levels of headings; code 
fce6dad947c3
Pushed down most existing lessons one level; added
andy_robinson
parents:
314
diff
changeset

246 
#should be swapped over to using them. 
fce6dad947c3
Pushed down most existing lessons one level; added
andy_robinson
parents:
314
diff
changeset

247 

fce6dad947c3
Pushed down most existing lessons one level; added
andy_robinson
parents:
314
diff
changeset

248 
def heading1(text): 
fce6dad947c3
Pushed down most existing lessons one level; added
andy_robinson
parents:
314
diff
changeset

249 
"""Use this for chapters. Lessons within a big chapter 
fce6dad947c3
Pushed down most existing lessons one level; added
andy_robinson
parents:
314
diff
changeset

250 
should now use heading2 instead. Chapters get numbered.""" 
273
cd705b27b6a5
initial checkin. user guide generation framework.
aaron_watters
parents:
diff
changeset

251 
BODY.append(PageBreak()) 
317
fce6dad947c3
Pushed down most existing lessons one level; added
andy_robinson
parents:
314
diff
changeset

252 
p = Paragraph('Chapter <seq id="Chapter"/>  ' + quickfix(text), H1) 
fce6dad947c3
Pushed down most existing lessons one level; added
andy_robinson
parents:
314
diff
changeset

253 
BODY.append(p) 
fce6dad947c3
Pushed down most existing lessons one level; added
andy_robinson
parents:
314
diff
changeset

254 

fce6dad947c3
Pushed down most existing lessons one level; added
andy_robinson
parents:
314
diff
changeset

255 
def heading2(text): 
fce6dad947c3
Pushed down most existing lessons one level; added
andy_robinson
parents:
314
diff
changeset

256 
"""Used to be 'lesson'""" 
fce6dad947c3
Pushed down most existing lessons one level; added
andy_robinson
parents:
314
diff
changeset

257 
BODY.append(CondPageBreak(inch)) 
fce6dad947c3
Pushed down most existing lessons one level; added
andy_robinson
parents:
314
diff
changeset

258 
p = Paragraph('<seq template="%(Chapter)s.%(Section+)s  "/>' + quickfix(text), H2) 
fce6dad947c3
Pushed down most existing lessons one level; added
andy_robinson
parents:
314
diff
changeset

259 
BODY.append(p) 
fce6dad947c3
Pushed down most existing lessons one level; added
andy_robinson
parents:
314
diff
changeset

260 

fce6dad947c3
Pushed down most existing lessons one level; added
andy_robinson
parents:
314
diff
changeset

261 
def heading3(text): 
fce6dad947c3
Pushed down most existing lessons one level; added
andy_robinson
parents:
314
diff
changeset

262 
"""Used to be most of the plain old 'head' sections""" 
fce6dad947c3
Pushed down most existing lessons one level; added
andy_robinson
parents:
314
diff
changeset

263 
BODY.append(CondPageBreak(inch)) 
fce6dad947c3
Pushed down most existing lessons one level; added
andy_robinson
parents:
314
diff
changeset

264 
p = Paragraph(quickfix(text), H3) 
fce6dad947c3
Pushed down most existing lessons one level; added
andy_robinson
parents:
314
diff
changeset

265 
BODY.append(p) 
fce6dad947c3
Pushed down most existing lessons one level; added
andy_robinson
parents:
314
diff
changeset

266 

fce6dad947c3
Pushed down most existing lessons one level; added
andy_robinson
parents:
314
diff
changeset

267 
def todo(text): 
fce6dad947c3
Pushed down most existing lessons one level; added
andy_robinson
parents:
314
diff
changeset

268 
"""Used for notes to ourselves""" 
fce6dad947c3
Pushed down most existing lessons one level; added
andy_robinson
parents:
314
diff
changeset

269 
BODY.append(Paragraph(quickfix(text), Comment)) 
fce6dad947c3
Pushed down most existing lessons one level; added
andy_robinson
parents:
314
diff
changeset

270 

273
cd705b27b6a5
initial checkin. user guide generation framework.
aaron_watters
parents:
diff
changeset

271 

cd705b27b6a5
initial checkin. user guide generation framework.
aaron_watters
parents:
diff
changeset

272 
def canvasdemo(function): 
cd705b27b6a5
initial checkin. user guide generation framework.
aaron_watters
parents:
diff
changeset

273 
BODY.append(Spacer(0.1*inch, 0.1*inch)) 
cd705b27b6a5
initial checkin. user guide generation framework.
aaron_watters
parents:
diff
changeset

274 
BODY.append(OperationWrapper(function)) 
cd705b27b6a5
initial checkin. user guide generation framework.
aaron_watters
parents:
diff
changeset

275 

cd705b27b6a5
initial checkin. user guide generation framework.
aaron_watters
parents:
diff
changeset

276 
class OperationWrapper(Flowable): 
cd705b27b6a5
initial checkin. user guide generation framework.
aaron_watters
parents:
diff
changeset

277 
"""wrap a drawing operation as a flowable. 
cd705b27b6a5
initial checkin. user guide generation framework.
aaron_watters
parents:
diff
changeset

278 
the operation should respect the examplefunctiondisplaysizes 
cd705b27b6a5
initial checkin. user guide generation framework.
aaron_watters
parents:
diff
changeset

279 
limitations. 
cd705b27b6a5
initial checkin. user guide generation framework.
aaron_watters
parents:
diff
changeset

280 
This example wraps a drawing operator f(pdfgen.canvas). 
cd705b27b6a5
initial checkin. user guide generation framework.
aaron_watters
parents:
diff
changeset

281 
Always enclosed in a rectangle. 
cd705b27b6a5
initial checkin. user guide generation framework.
aaron_watters
parents:
diff
changeset

282 
""" 
cd705b27b6a5
initial checkin. user guide generation framework.
aaron_watters
parents:
diff
changeset

283 
def __init__(self, operation): 
cd705b27b6a5
initial checkin. user guide generation framework.
aaron_watters
parents:
diff
changeset

284 
self.operation = operation 
cd705b27b6a5
initial checkin. user guide generation framework.
aaron_watters
parents:
diff
changeset

285 

cd705b27b6a5
initial checkin. user guide generation framework.
aaron_watters
parents:
diff
changeset

286 
def wrap(self, aw, ah): 
cd705b27b6a5
initial checkin. user guide generation framework.
aaron_watters
parents:
diff
changeset

287 
return examplefunctiondisplaysizes # always the same 
cd705b27b6a5
initial checkin. user guide generation framework.
aaron_watters
parents:
diff
changeset

288 

cd705b27b6a5
initial checkin. user guide generation framework.
aaron_watters
parents:
diff
changeset

289 
def draw(self): 
cd705b27b6a5
initial checkin. user guide generation framework.
aaron_watters
parents:
diff
changeset

290 
canvas = self.canv 
cd705b27b6a5
initial checkin. user guide generation framework.
aaron_watters
parents:
diff
changeset

291 
canvas.saveState() 
cd705b27b6a5
initial checkin. user guide generation framework.
aaron_watters
parents:
diff
changeset

292 
(x,y) = examplefunctiondisplaysizes 
cd705b27b6a5
initial checkin. user guide generation framework.
aaron_watters
parents:
diff
changeset

293 
self.operation(canvas) 
cd705b27b6a5
initial checkin. user guide generation framework.
aaron_watters
parents:
diff
changeset

294 
canvas.restoreState() 
cd705b27b6a5
initial checkin. user guide generation framework.
aaron_watters
parents:
diff
changeset

295 
canvas.rect(0,0,x,y) 
cd705b27b6a5
initial checkin. user guide generation framework.
aaron_watters
parents:
diff
changeset

296 

296  297 

298 
def pencilnote(): 

299 
BODY.append(examples.NoteAnnotation()) 

300 

273
cd705b27b6a5
initial checkin. user guide generation framework.
aaron_watters
parents:
diff
changeset

301 
###### testing... 
cd705b27b6a5
initial checkin. user guide generation framework.
aaron_watters
parents:
diff
changeset

302 
#canvasdemo(NOP) 
cd705b27b6a5
initial checkin. user guide generation framework.
aaron_watters
parents:
diff
changeset

303 

317
fce6dad947c3
Pushed down most existing lessons one level; added
andy_robinson
parents:
314
diff
changeset

304 
#heading2("this is a new lesson") 
273
cd705b27b6a5
initial checkin. user guide generation framework.
aaron_watters
parents:
diff
changeset

305 

cd705b27b6a5
initial checkin. user guide generation framework.
aaron_watters
parents:
diff
changeset

306 
#disc("this explains the example") 
cd705b27b6a5
initial checkin. user guide generation framework.
aaron_watters
parents:
diff
changeset

307 

cd705b27b6a5
initial checkin. user guide generation framework.
aaron_watters
parents:
diff
changeset

308 
#eg(""" 
cd705b27b6a5
initial checkin. user guide generation framework.
aaron_watters
parents:
diff
changeset

309 
#this 
cd705b27b6a5
initial checkin. user guide generation framework.
aaron_watters
parents:
diff
changeset

310 
# is the 
cd705b27b6a5
initial checkin. user guide generation framework.
aaron_watters
parents:
diff
changeset

311 
# example 
cd705b27b6a5
initial checkin. user guide generation framework.
aaron_watters
parents:
diff
changeset

312 
# code""") 
cd705b27b6a5
initial checkin. user guide generation framework.
aaron_watters
parents:
diff
changeset

313 

cd705b27b6a5
initial checkin. user guide generation framework.
aaron_watters
parents:
diff
changeset

314 
#disc("the execution of the example follows") 
cd705b27b6a5
initial checkin. user guide generation framework.
aaron_watters
parents:
diff
changeset

315 

cd705b27b6a5
initial checkin. user guide generation framework.
aaron_watters
parents:
diff
changeset

316 
#canvasdemo(NOP) # execute some code 
cd705b27b6a5
initial checkin. user guide generation framework.
aaron_watters
parents:
diff
changeset

317 

296  318 
#pencilnote() 
319 

310  320 
title("ReportLab User Guide") 
317
fce6dad947c3
Pushed down most existing lessons one level; added
andy_robinson
parents:
314
diff
changeset

321 

fce6dad947c3
Pushed down most existing lessons one level; added
andy_robinson
parents:
314
diff
changeset

322 
todo("""Todo items to authors, or points under discussion, 
fce6dad947c3
Pushed down most existing lessons one level; added
andy_robinson
parents:
314
diff
changeset

323 
appear in italics like this.""") 
fce6dad947c3
Pushed down most existing lessons one level; added
andy_robinson
parents:
314
diff
changeset

324 
todo("""The examples should go in slightly smaller boxes, 
fce6dad947c3
Pushed down most existing lessons one level; added
andy_robinson
parents:
314
diff
changeset

325 
centred in the frame, with a 'Figure 1.2...' style caption 
fce6dad947c3
Pushed down most existing lessons one level; added
andy_robinson
parents:
314
diff
changeset

326 
beneath them. We can just scale things down a little. 
fce6dad947c3
Pushed down most existing lessons one level; added
andy_robinson
parents:
314
diff
changeset

327 
A Figure widget can be found in platdemos.py; they should 
fce6dad947c3
Pushed down most existing lessons one level; added
andy_robinson
parents:
314
diff
changeset

328 
draw inside that.""") 
fce6dad947c3
Pushed down most existing lessons one level; added
andy_robinson
parents:
314
diff
changeset

329 

fce6dad947c3
Pushed down most existing lessons one level; added
andy_robinson
parents:
314
diff
changeset

330 

fce6dad947c3
Pushed down most existing lessons one level; added
andy_robinson
parents:
314
diff
changeset

331 
heading1("Introduction") 
273
cd705b27b6a5
initial checkin. user guide generation framework.
aaron_watters
parents:
diff
changeset

332 

cd705b27b6a5
initial checkin. user guide generation framework.
aaron_watters
parents:
diff
changeset

333 
disc(""" 
cd705b27b6a5
initial checkin. user guide generation framework.
aaron_watters
parents:
diff
changeset

334 
This document is intended to be a conversational introduction 
cd705b27b6a5
initial checkin. user guide generation framework.
aaron_watters
parents:
diff
changeset

335 
to the use of the ReportLab packages. Some previous programming experience 
cd705b27b6a5
initial checkin. user guide generation framework.
aaron_watters
parents:
diff
changeset

336 
is presumed and familiarity with the Python Programming language is 
cd705b27b6a5
initial checkin. user guide generation framework.
aaron_watters
parents:
diff
changeset

337 
recommended. 
cd705b27b6a5
initial checkin. user guide generation framework.
aaron_watters
parents:
diff
changeset

338 
""") 
cd705b27b6a5
initial checkin. user guide generation framework.
aaron_watters
parents:
diff
changeset

339 

317
fce6dad947c3
Pushed down most existing lessons one level; added
andy_robinson
parents:
314
diff
changeset

340 
heading2("What is PDFgen all about") 
fce6dad947c3
Pushed down most existing lessons one level; added
andy_robinson
parents:
314
diff
changeset

341 
todo("rationale  from Andy") 
296  342 
#canvasdemo(NOP) # execute some code 
343 

317
fce6dad947c3
Pushed down most existing lessons one level; added
andy_robinson
parents:
314
diff
changeset

344 
heading2("About Python") 
fce6dad947c3
Pushed down most existing lessons one level; added
andy_robinson
parents:
314
diff
changeset

345 
todo("If they don't know Python, rave a little then tell them where to get it") 
fce6dad947c3
Pushed down most existing lessons one level; added
andy_robinson
parents:
314
diff
changeset

346 

fce6dad947c3
Pushed down most existing lessons one level; added
andy_robinson
parents:
314
diff
changeset

347 
heading2("Installation and Setup") 
fce6dad947c3
Pushed down most existing lessons one level; added
andy_robinson
parents:
314
diff
changeset

348 
todo("need notes on packages, Windows, PIL and zlib; how to test it works") 
fce6dad947c3
Pushed down most existing lessons one level; added
andy_robinson
parents:
314
diff
changeset

349 

296  350 
pencilnote() 
351 

283  352 
disc(""" 
353 
This document is in a <em>very</em> preliminary form. 

354 
""") 

355 

317
fce6dad947c3
Pushed down most existing lessons one level; added
andy_robinson
parents:
314
diff
changeset

356 
heading1("Graphics and Text with $pdfgen$") 
273
cd705b27b6a5
initial checkin. user guide generation framework.
aaron_watters
parents:
diff
changeset

357 

317
fce6dad947c3
Pushed down most existing lessons one level; added
andy_robinson
parents:
314
diff
changeset

358 
heading2("Basic Concepts") 
273
cd705b27b6a5
initial checkin. user guide generation framework.
aaron_watters
parents:
diff
changeset

359 
disc(""" 
301
5ad57f31ae75
added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents:
300
diff
changeset

360 
The $pdfgen$ package is the lowest level interface for 
5ad57f31ae75
added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents:
300
diff
changeset

361 
generating PDF documents. A $pdfgen$ program is essentially 
273
cd705b27b6a5
initial checkin. user guide generation framework.
aaron_watters
parents:
diff
changeset

362 
a sequence of instructions for "painting" a document onto 
cd705b27b6a5
initial checkin. user guide generation framework.
aaron_watters
parents:
diff
changeset

363 
a sequence of pages. The interface object which provides the 
301
5ad57f31ae75
added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents:
300
diff
changeset

364 
painting operations is the $pdfgen$ canvas. 
273
cd705b27b6a5
initial checkin. user guide generation framework.
aaron_watters
parents:
diff
changeset

365 
""") 
cd705b27b6a5
initial checkin. user guide generation framework.
aaron_watters
parents:
diff
changeset

366 

cd705b27b6a5
initial checkin. user guide generation framework.
aaron_watters
parents:
diff
changeset

367 
disc(""" 
cd705b27b6a5
initial checkin. user guide generation framework.
aaron_watters
parents:
diff
changeset

368 
The canvas should be thought of as a sheet of white paper 
301
5ad57f31ae75
added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents:
300
diff
changeset

369 
with points on the sheet identified using Cartesian ^(X,Y)^ coordinates 
5ad57f31ae75
added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents:
300
diff
changeset

370 
which by default have the ^(0,0)^ origin point at the lower 
5ad57f31ae75
added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents:
300
diff
changeset

371 
left corner of the page. Furthermore the first coordinate ^x^ 
5ad57f31ae75
added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents:
300
diff
changeset

372 
goes to the right and the second coordinate ^y^ goes up, by 
273
cd705b27b6a5
initial checkin. user guide generation framework.
aaron_watters
parents:
diff
changeset

373 
default.""") 
cd705b27b6a5
initial checkin. user guide generation framework.
aaron_watters
parents:
diff
changeset

374 

cd705b27b6a5
initial checkin. user guide generation framework.
aaron_watters
parents:
diff
changeset

375 
disc(""" 
cd705b27b6a5
initial checkin. user guide generation framework.
aaron_watters
parents:
diff
changeset

376 
A simple example 
cd705b27b6a5
initial checkin. user guide generation framework.
aaron_watters
parents:
diff
changeset

377 
program that uses a canvas follows. 
cd705b27b6a5
initial checkin. user guide generation framework.
aaron_watters
parents:
diff
changeset

378 
""") 
cd705b27b6a5
initial checkin. user guide generation framework.
aaron_watters
parents:
diff
changeset

379 

cd705b27b6a5
initial checkin. user guide generation framework.
aaron_watters
parents:
diff
changeset

380 
eg(""" 
cd705b27b6a5
initial checkin. user guide generation framework.
aaron_watters
parents:
diff
changeset

381 
from reportlab.pdfgen import canvas 
cd705b27b6a5
initial checkin. user guide generation framework.
aaron_watters
parents:
diff
changeset

382 
c = canvas.Canvas("hello.pdf") 
cd705b27b6a5
initial checkin. user guide generation framework.
aaron_watters
parents:
diff
changeset

383 
hello(c) 
cd705b27b6a5
initial checkin. user guide generation framework.
aaron_watters
parents:
diff
changeset

384 
c.showPage() 
cd705b27b6a5
initial checkin. user guide generation framework.
aaron_watters
parents:
diff
changeset

385 
c.save() 
cd705b27b6a5
initial checkin. user guide generation framework.
aaron_watters
parents:
diff
changeset

386 
""") 
cd705b27b6a5
initial checkin. user guide generation framework.
aaron_watters
parents:
diff
changeset

387 

cd705b27b6a5
initial checkin. user guide generation framework.
aaron_watters
parents:
diff
changeset

388 
disc(""" 
301
5ad57f31ae75
added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents:
300
diff
changeset

389 
The above code creates a $canvas$ object which will generate 
5ad57f31ae75
added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents:
300
diff
changeset

390 
a PDF file named $hello.pdf$ in the current working directory. 
5ad57f31ae75
added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents:
300
diff
changeset

391 
It then calls the $hello$ function passing the $canvas$ as an argument. 
5ad57f31ae75
added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents:
300
diff
changeset

392 
Finally the $showPage$ method saves the current page of the canvas 
5ad57f31ae75
added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents:
300
diff
changeset

393 
and the $save$ method stores the file and closes the canvas.""") 
273
cd705b27b6a5
initial checkin. user guide generation framework.
aaron_watters
parents:
diff
changeset

394 

cd705b27b6a5
initial checkin. user guide generation framework.
aaron_watters
parents:
diff
changeset

395 
disc(""" 
301
5ad57f31ae75
added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents:
300
diff
changeset

396 
The $showPage$ method causes the $canvas$ to stop drawing on the 
273
cd705b27b6a5
initial checkin. user guide generation framework.
aaron_watters
parents:
diff
changeset

397 
current page and any further operations will draw on a subsequent 
293  398 
page (if there are any further operations  if not no 
301
5ad57f31ae75
added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents:
300
diff
changeset

399 
new page is created). The $save$ method must be called after the 
273
cd705b27b6a5
initial checkin. user guide generation framework.
aaron_watters
parents:
diff
changeset

400 
construction of the document is complete  it generates the PDF 
301
5ad57f31ae75
added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents:
300
diff
changeset

401 
document, which is the whole purpose of the $canvas$ object. 
273
cd705b27b6a5
initial checkin. user guide generation framework.
aaron_watters
parents:
diff
changeset

402 
""") 
cd705b27b6a5
initial checkin. user guide generation framework.
aaron_watters
parents:
diff
changeset

403 

cd705b27b6a5
initial checkin. user guide generation framework.
aaron_watters
parents:
diff
changeset

404 
disc(""" 
301
5ad57f31ae75
added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents:
300
diff
changeset

405 
Suppose the $hello$ function referenced above is implemented as 
273
cd705b27b6a5
initial checkin. user guide generation framework.
aaron_watters
parents:
diff
changeset

406 
follows (we will not explain each of the operations in detail 
cd705b27b6a5
initial checkin. user guide generation framework.
aaron_watters
parents:
diff
changeset

407 
yet). 
cd705b27b6a5
initial checkin. user guide generation framework.
aaron_watters
parents:
diff
changeset

408 
""") 
cd705b27b6a5
initial checkin. user guide generation framework.
aaron_watters
parents:
diff
changeset

409 

cd705b27b6a5
initial checkin. user guide generation framework.
aaron_watters
parents:
diff
changeset

410 
eg(examples.testhello) 
cd705b27b6a5
initial checkin. user guide generation framework.
aaron_watters
parents:
diff
changeset

411 

cd705b27b6a5
initial checkin. user guide generation framework.
aaron_watters
parents:
diff
changeset

412 
disc(""" 
cd705b27b6a5
initial checkin. user guide generation framework.
aaron_watters
parents:
diff
changeset

413 
Examining this code notice that there are essentially two types 
cd705b27b6a5
initial checkin. user guide generation framework.
aaron_watters
parents:
diff
changeset

414 
of operations performed using a canvas. The first type draws something 
cd705b27b6a5
initial checkin. user guide generation framework.
aaron_watters
parents:
diff
changeset

415 
on the page such as a text string or a rectangle or a line. The second 
283  416 
type changes the state of the canvas such as 
273
cd705b27b6a5
initial checkin. user guide generation framework.
aaron_watters
parents:
diff
changeset

417 
changing the current fill or stroke color or changing the current font 
283  418 
type and size. 
273
cd705b27b6a5
initial checkin. user guide generation framework.
aaron_watters
parents:
diff
changeset

419 
""") 
cd705b27b6a5
initial checkin. user guide generation framework.
aaron_watters
parents:
diff
changeset

420 

cd705b27b6a5
initial checkin. user guide generation framework.
aaron_watters
parents:
diff
changeset

421 
disc(""" 
283  422 
If we imagine the program as a painter working on 
423 
the canvas the "draw" operations apply paint to the canvas using 

424 
the current set of tools (colors, line styles, fonts, etcetera) 

425 
and the "state change" operations change one of the current tools 

426 
(changing the fill color from whatever it was to blue, or changing 

301
5ad57f31ae75
added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents:
300
diff
changeset

427 
the current font to $TimesRoman$ in 15 points, for example). 
283  428 
""") 
429 

430 
disc(""" 

431 
The document generated by the "hello world" program listed above would contain 

273
cd705b27b6a5
initial checkin. user guide generation framework.
aaron_watters
parents:
diff
changeset

432 
the following graphics. 
cd705b27b6a5
initial checkin. user guide generation framework.
aaron_watters
parents:
diff
changeset

433 
""") 
cd705b27b6a5
initial checkin. user guide generation framework.
aaron_watters
parents:
diff
changeset

434 

cd705b27b6a5
initial checkin. user guide generation framework.
aaron_watters
parents:
diff
changeset

435 
canvasdemo(examples.hello) 
cd705b27b6a5
initial checkin. user guide generation framework.
aaron_watters
parents:
diff
changeset

436 

317
fce6dad947c3
Pushed down most existing lessons one level; added
andy_robinson
parents:
314
diff
changeset

437 
heading3("About the demos in this document") 
283  438 

439 
disc(""" 

440 
This document contains demonstrations of the code discussed like the one shown 

441 
in the rectangle above. These demos are drawn on a "tiny page" embedded 

442 
within the real pages of the guide. The tiny pages are %s inches wide 

293  443 
and %s inches tall. The demo displays show the actual output of the demo 
283  444 
code. 
445 
""" % (examplefunctionxinches, examplefunctionyinches)) 

446 

317
fce6dad947c3
Pushed down most existing lessons one level; added
andy_robinson
parents:
314
diff
changeset

447 
heading2('The tools: the "draw" operations') 
283  448 

449 
disc(""" 

450 
This section briefly lists the tools available to the program 

451 
for painting information onto a page using the canvas interface. 

452 
These will be discussed in detail in later sections. They are listed 

453 
here for easy reference and for summary purposes. 

454 
""") 

455 

317
fce6dad947c3
Pushed down most existing lessons one level; added
andy_robinson
parents:
314
diff
changeset

456 
heading3("Line methods") 
283  457 

458 
eg("""canvas.line(x1,y1,x2,y2)""") 

459 
eg("""canvas.lines(linelist)""") 

460 

461 
disc(""" 

462 
The line methods draw straight line segments on the canvas. 

463 
""") 

464 

317
fce6dad947c3
Pushed down most existing lessons one level; added
andy_robinson
parents:
314
diff
changeset

465 
heading3("Shape methods") 
283  466 

467 
eg("""canvas.grid(xlist, ylist) """) 

468 
eg("""canvas.bezier(x1, y1, x2, y2, x3, y3, x4, y4)""") 

469 
eg("""canvas.arc(x1,y1,x2,y2) """) 

470 
eg("""canvas.rect(x, y, width, height, stroke=1, fill=0) """) 

471 
eg("""canvas.ellipse(x, y, width, height, stroke=1, fill=0)""") 

472 
eg("""canvas.wedge(x1,y1, x2,y2, startAng, extent, stroke=1, fill=0) """) 

473 
eg("""canvas.circle(x_cen, y_cen, r, stroke=1, fill=0)""") 

474 
eg("""canvas.roundRect(x, y, width, height, radius, stroke=1, fill=0) """) 

475 

476 
disc(""" 

477 
The shape methods draw common complex shapes on the canvas. 

478 
""") 

479 

317
fce6dad947c3
Pushed down most existing lessons one level; added
andy_robinson
parents:
314
diff
changeset

480 
heading3("String drawing methods") 
283  481 

482 
eg("""canvas.drawString(x, y, text):""") 

483 
eg("""canvas.drawRightString(x, y, text) """) 

484 
eg("""canvas.drawCentredString(x, y, text)""") 

485 

486 
disc(""" 

487 
The draw string methods draw single lines of text on the canvas. 

488 
""") 

489 

317
fce6dad947c3
Pushed down most existing lessons one level; added
andy_robinson
parents:
314
diff
changeset

490 
heading3("The text object methods") 
283  491 
eg("""textobject = canvas.beginText(x, y) """) 
492 
eg("""canvas.drawText(textobject) """) 

493 

494 
disc(""" 

495 
Text objects are used to format text in ways that 

496 
are not supported directly by the canvas interface. 

497 
A program creates a text object from the canvas using beginText 

498 
and then formats text by invoking textobject methods. 

499 
Finally the textobject is drawn onto the canvas using 

500 
drawText. 

501 
""") 

502 

317
fce6dad947c3
Pushed down most existing lessons one level; added
andy_robinson
parents:
314
diff
changeset

503 
heading3("The path object methods") 
283  504 

505 
eg("""path = canvas.beginPath() """) 

293  506 
eg("""canvas.drawPath(path, stroke=1, fill=0) """) 
507 
eg("""canvas.clipPath(path, stroke=1, fill=0) """) 

283  508 

317
fce6dad947c3
Pushed down most existing lessons one level; added
andy_robinson
parents:
314
diff
changeset

509 
heading3("Image methods") 
283  510 

511 
eg("""canvas.drawInlineImage(self, image, x,y, width=None,height=None) """) 

512 

317
fce6dad947c3
Pushed down most existing lessons one level; added
andy_robinson
parents:
314
diff
changeset

513 
heading3("Ending a page") 
283  514 

515 
eg("""canvas.showPage()""") 

516 

300
44c954f72e2b
showPage resets all state parameters warning.
aaron_watters
parents:
299
diff
changeset

517 
disc("""The showPage method finishes the current page. All additional drawing will 
44c954f72e2b
showPage resets all state parameters warning.
aaron_watters
parents:
299
diff
changeset

518 
be done on another page.""") 
44c954f72e2b
showPage resets all state parameters warning.
aaron_watters
parents:
299
diff
changeset

519 

44c954f72e2b
showPage resets all state parameters warning.
aaron_watters
parents:
299
diff
changeset

520 
pencilnote() 
44c954f72e2b
showPage resets all state parameters warning.
aaron_watters
parents:
299
diff
changeset

521 

44c954f72e2b
showPage resets all state parameters warning.
aaron_watters
parents:
299
diff
changeset

522 
disc("""Warning! All state changes (font changes, color settings, geometry transforms, etcetera) 
301
5ad57f31ae75
added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents:
300
diff
changeset

523 
are FORGOTTEN when you advance to a new page in $pdfgen$. Any state settings you wish to preserve 
300
44c954f72e2b
showPage resets all state parameters warning.
aaron_watters
parents:
299
diff
changeset

524 
must be set up again before the program proceeds with drawing!""") 
44c954f72e2b
showPage resets all state parameters warning.
aaron_watters
parents:
299
diff
changeset

525 

317
fce6dad947c3
Pushed down most existing lessons one level; added
andy_robinson
parents:
314
diff
changeset

526 
heading2('The toolbox: the "state change" operations') 
283  527 

528 
disc(""" 

529 
This section briefly lists the ways to switch the tools used by the 

530 
program 

531 
for painting information onto a page using the canvas interface. 

532 
These too will be discussed in detail in later sections. 

533 
""") 

534 

317
fce6dad947c3
Pushed down most existing lessons one level; added
andy_robinson
parents:
314
diff
changeset

535 
heading3("Changing Colors") 
283  536 
eg("""canvas.setFillColorCMYK(c, m, y, k) """) 
537 
eg("""canvas.setStrikeColorCMYK(c, m, y, k) """) 

538 
eg("""canvas.setFillColorRGB(r, g, b) """) 

539 
eg("""canvas.setStrokeColorRGB(r, g, b) """) 

540 
eg("""canvas.setFillColor(acolor) """) 

541 
eg("""canvas.setStrokeColor(acolor) """) 

542 
eg("""canvas.setFillGray(gray) """) 

543 
eg("""canvas.setStrokeGray(gray) """) 

544 

317
fce6dad947c3
Pushed down most existing lessons one level; added
andy_robinson
parents:
314
diff
changeset

545 
heading3("Changing Fonts") 
283  546 
eg("""canvas.setFont(psfontname, size, leading = None) """) 
547 

317
fce6dad947c3
Pushed down most existing lessons one level; added
andy_robinson
parents:
314
diff
changeset

548 
heading3("Changing Graphical Styles") 
283  549 

550 
eg("""canvas.setLineWidth(width) """) 

551 
eg("""canvas.setLineCap(mode) """) 

552 
eg("""canvas.setLineJoin(mode) """) 

553 
eg("""canvas.setMiterLimit(limit) """) 

554 
eg("""canvas.setDash(self, array=[], phase=0) """) 

555 

317
fce6dad947c3
Pushed down most existing lessons one level; added
andy_robinson
parents:
314
diff
changeset

556 
heading3("Changing Geometry") 
283  557 

558 
eg("""canvas.setPageSize(pair) """) 

559 
eg("""canvas.transform(a,b,c,d,e,f): """) 

560 
eg("""canvas.translate(dx, dy) """) 

561 
eg("""canvas.scale(x, y) """) 

562 
eg("""canvas.rotate(theta) """) 

563 
eg("""canvas.skew(alpha, beta) """) 

564 

317
fce6dad947c3
Pushed down most existing lessons one level; added
andy_robinson
parents:
314
diff
changeset

565 
heading3("State control") 
283  566 

567 
eg("""canvas.saveState() """) 

568 
eg("""canvas.restoreState() """) 

569 

570 

317
fce6dad947c3
Pushed down most existing lessons one level; added
andy_robinson
parents:
314
diff
changeset

571 
heading2("Other canvas methods.") 
283  572 

573 
disc(""" 

574 
Not all methods of the canvas object fit into the "tool" or "toolbox" 

575 
categories. Below are some of the misfits, included here for completeness. 

576 
""") 

577 

578 
eg(""" 

579 
canvas.setAuthor() 

580 
canvas.addOutlineEntry(title, key, level=0, closed=None) 

581 
canvas.setTitle(title) 

582 
canvas.setSubject(subj) 

583 
canvas.pageHasData() 

584 
canvas.showOutline() 

585 
canvas.bookmarkPage(name) 

586 
canvas.bookmarkHorizontalAbsolute(name, yhorizontal) 

587 
canvas.doForm() 

588 
canvas.beginForm(name, lowerx=0, lowery=0, upperx=None, uppery=None) 

589 
canvas.endForm() 

590 
canvas.linkAbsolute(contents, destinationname, Rect=None, addtopage=1, name=None, **kw) 

591 
canvas.getPageNumber() 

592 
canvas.addLiteral() 

593 
canvas.getAvailableFonts() 

308  594 
canvas.stringWidth(self, text, fontName, fontSize, encoding=None) 
283  595 
canvas.setPageCompression(onoff=1) 
596 
canvas.setPageTransition(self, effectname=None, duration=1, 

597 
direction=0,dimension='H',motion='I') 

598 
""") 

599 

600 

317
fce6dad947c3
Pushed down most existing lessons one level; added
andy_robinson
parents:
314
diff
changeset

601 
heading2('Coordinates (default user space)') 
283  602 

603 
disc(""" 

604 
By default locations on a page are identified by a pair of numbers. 

301
5ad57f31ae75
added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents:
300
diff
changeset

605 
For example the pair $(4.5*inch, 1*inch)$ identifies the location 
283  606 
found on the page by starting at the lower left corner and moving to 
607 
the right 4.5 inches and up one inch. 

608 
""") 

609 

610 
disc("""For example, the following function draws 

611 
a number of elements on a canvas.""") 

612 

613 
eg(examples.testcoords) 

614 

301
5ad57f31ae75
added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents:
300
diff
changeset

615 
disc("""In the default user space the "origin" ^(0,0)^ point is at the lower 
5ad57f31ae75
added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents:
300
diff
changeset

616 
left corner. Executing the $coords$ function in the default user space 
283  617 
(for the "demo minipage") we obtain the following.""") 
618 

619 
canvasdemo(examples.coords) 

620 

317
fce6dad947c3
Pushed down most existing lessons one level; added
andy_robinson
parents:
314
diff
changeset

621 
heading3("Moving the origin: the $translate$ method") 
283  622 

623 
disc("""Often it is useful to "move the origin" to a new point off 

301
5ad57f31ae75
added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents:
300
diff
changeset

624 
the lower left corner. The $canvas.translate(^x,y^)$ method moves the origin 
5ad57f31ae75
added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents:
300
diff
changeset

625 
for the current page to the point currently identified by ^(x,y)^.""") 
283  626 

627 
disc("""For example the following translate function first moves 

628 
the origin before drawing the same objects as shown above.""") 

629 

630 
eg(examples.testtranslate) 

631 

632 
disc("""This produces the following.""") 

633 

634 
canvasdemo(examples.translate) 

635 

296  636 

637 
#canvasdemo(NOP) # execute some code 

638 

639 
pencilnote() 

640 

641 

283  642 
disc(""" 
301
5ad57f31ae75
added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents:
300
diff
changeset

643 
<i>Note:</i> As illustrated in the example it is perfectly possible to draw objects 
283  644 
or parts of objects "off the page". 
645 
In particular a common confusing bug is a translation operation that translates the 

646 
entire drawing off the visible area of the page. If a program produces a blank page 

647 
it is possible that all the drawn objects are off the page. 

648 
""") 

649 

317
fce6dad947c3
Pushed down most existing lessons one level; added
andy_robinson
parents:
314
diff
changeset

650 
heading3("Shrinking and growing: the scale operation") 
283  651 

301
5ad57f31ae75
added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents:
300
diff
changeset

652 
disc("""Another important operation is scaling. The scaling operation $canvas.scale(^dx,dy^)$ 
5ad57f31ae75
added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents:
300
diff
changeset

653 
stretches or shrinks the ^x^ and ^y^ dimensions by the ^dx^, ^dy^ factors respectively. Often 
5ad57f31ae75
added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents:
300
diff
changeset

654 
^dx^ and ^dy^ are the same  for example to reduce a drawing by half in all dimensions use 
5ad57f31ae75
added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents:
300
diff
changeset

655 
$dx = dy = 0.5$. However for the purposes of illustration we show an example where 
5ad57f31ae75
added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents:
300
diff
changeset

656 
$dx$ and $dy$ are different. 
283  657 
""") 
658 

659 
eg(examples.testscale) 

660 

661 
disc("""This produces a "short and fat" reduced version of the previously displayed operations.""") 

662 

663 
canvasdemo(examples.scale) 

664 

296  665 

666 
#canvasdemo(NOP) # execute some code 

667 

668 
pencilnote() 

669 

670 

301
5ad57f31ae75
added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents:
300
diff
changeset

671 
disc("""<i>Note:</i> scaling may also move objects or parts of objects off the page, 
283  672 
or may cause objects to "shrink to nothing." """) 
673 

674 
disc("""Scaling and translation can be combined, but the order of the 

675 
operations are important.""") 

676 

677 
eg(examples.testscaletranslate) 

678 

679 
disc("""This example function first saves the current canvas state 

301
5ad57f31ae75
added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents:
300
diff
changeset

680 
and then does a $scale$ followed by a $translate$. Afterward the function 
283  681 
restores the state (effectively removing the effects of the scaling and 
301
5ad57f31ae75
added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents:
300
diff
changeset

682 
translation) and then does the <i>same</i> operations in a different order. 
283  683 
Observe the effect below.""") 
684 

685 
canvasdemo(examples.scaletranslate) 

686 

296  687 

688 
#canvasdemo(NOP) # execute some code 

689 

690 
pencilnote() 

691 

692 

283  693 
disc("""<em>Note:</em> scaling shrinks or grows everything including line widths 
694 
so using the canvas.scale method to render a microscopic drawing in 

695 
scaled microscopic units 

696 
may produce a blob (because all line widths will get expanded a huge amount). 

697 
Also rendering an aircraft wing in meters scaled to centimeters may cause the lines 

698 
to shrink to the point where they disappear. For engineering or scientific purposes 

699 
such as these scale and translate 

700 
the units externally before rendering them using the canvas.""") 

701 

317
fce6dad947c3
Pushed down most existing lessons one level; added
andy_robinson
parents:
314
diff
changeset

702 
heading3("Saving and restoring the canvas state: $saveState$ and $restoreState$") 
283  703 

704 
disc(""" 

301
5ad57f31ae75
added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents:
300
diff
changeset

705 
The $scaletranslate$ function used an important feature of the canvas object: 
283  706 
the ability to save and restore the current parameters of the canvas. 
301
5ad57f31ae75
added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents:
300
diff
changeset

707 
By enclosing a sequence of operations in a matching pair of $canvas.saveState()$ 
5ad57f31ae75
added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents:
300
diff
changeset

708 
an $canvas.restoreState()$ operations all changes of font, color, line style, 
283  709 
scaling, translation, or other aspects of the canvas graphics state can be 
301
5ad57f31ae75
added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents:
300
diff
changeset

710 
restored to the state at the point of the $saveState()$. Remember that the save/restore 
283  711 
calls must match: a stray save or restore operation may cause unexpected 
301
5ad57f31ae75
added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents:
300
diff
changeset

712 
and undesirable behavior. Also, remember that <i>no</i> canvas state is 
5ad57f31ae75
added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents:
300
diff
changeset

713 
preserved across page breaks, and the save/restore mechanism does not work 
5ad57f31ae75
added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents:
300
diff
changeset

714 
across page breaks. 
283  715 
""") 
716 

317
fce6dad947c3
Pushed down most existing lessons one level; added
andy_robinson
parents:
314
diff
changeset

717 
heading3("Mirror image") 
293  718 

719 
disc(""" 

720 
It is interesting although perhaps not terribly useful to note that 

721 
scale factors can be negative. For example the following function 

722 
""") 

723 

724 
eg(examples.testmirror) 

725 

726 
disc(""" 

301
5ad57f31ae75
added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents:
300
diff
changeset

727 
creates a mirror image of the elements drawn by the $coord$ function. 
293  728 
""") 
729 

730 
canvasdemo(examples.mirror) 

731 

732 
disc(""" 

733 
Notice that the text strings are painted backwards. 

734 
""") 

735 

317
fce6dad947c3
Pushed down most existing lessons one level; added
andy_robinson
parents:
314
diff
changeset

736 
heading2("Colors") 
298  737 

301
5ad57f31ae75
added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents:
300
diff
changeset

738 
disc(""" 
5ad57f31ae75
added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents:
300
diff
changeset

739 
There are four way to specify colors in $pdfgen$: by name (using the $color$ 
5ad57f31ae75
added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents:
300
diff
changeset

740 
module, by red/green/blue (additive, $RGB$) value, 
5ad57f31ae75
added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents:
300
diff
changeset

741 
by cyan/magenta/yellow/darkness (subtractive, $CMYK$), or by gray level. 
5ad57f31ae75
added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents:
300
diff
changeset

742 
The $colors$ function below exercises each of the four methods. 
5ad57f31ae75
added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents:
300
diff
changeset

743 
""") 
5ad57f31ae75
added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents:
300
diff
changeset

744 

298  745 
eg(examples.testcolors) 
746 

301
5ad57f31ae75
added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents:
300
diff
changeset

747 
disc(""" 
5ad57f31ae75
added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents:
300
diff
changeset

748 
The $RGB$ or additive color specification follows the way a computer 
5ad57f31ae75
added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents:
300
diff
changeset

749 
screen adds different levels of the red, green, or blue light to make 
5ad57f31ae75
added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents:
300
diff
changeset

750 
any color, where white is formed by turning all three lights on full 
5ad57f31ae75
added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents:
300
diff
changeset

751 
$(1,1,1)$.""") 
5ad57f31ae75
added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents:
300
diff
changeset

752 

5ad57f31ae75
added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents:
300
diff
changeset

753 
disc("""The $CMYK$ or subtractive method follows the way a printer 
5ad57f31ae75
added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents:
300
diff
changeset

754 
mixes three pigments (cyan, magenta, and yellow) to form colors. 
5ad57f31ae75
added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents:
300
diff
changeset

755 
Because mixing chemicals is more difficult than combining light there 
5ad57f31ae75
added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents:
300
diff
changeset

756 
is a fourth parameter for darkness. For example a chemical 
5ad57f31ae75
added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents:
300
diff
changeset

757 
combination of the $CMY$ pigments generally never makes a perfect 
5ad57f31ae75
added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents:
300
diff
changeset

758 
black  instead producing a muddy color  so, to get black printers 
5ad57f31ae75
added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents:
300
diff
changeset

759 
don't use the $CMY$ pigments but use a direct black ink. Because 
5ad57f31ae75
added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents:
300
diff
changeset

760 
$CMYK$ maps more directly to the way printer hardware works it may 
5ad57f31ae75
added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents:
300
diff
changeset

761 
be the case that colors specified in $CMYK$ will provide better fidelity 
5ad57f31ae75
added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents:
300
diff
changeset

762 
and better control when printed. 
5ad57f31ae75
added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents:
300
diff
changeset

763 
""") 
5ad57f31ae75
added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents:
300
diff
changeset

764 

298  765 
canvasdemo(examples.colors) 
766 

317
fce6dad947c3
Pushed down most existing lessons one level; added
andy_robinson
parents:
314
diff
changeset

767 
heading2('Painting back to front') 
283  768 

301
5ad57f31ae75
added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents:
300
diff
changeset

769 
disc(""" 
5ad57f31ae75
added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents:
300
diff
changeset

770 
Objects may be painted over other objects to good effect in $pdfgen$. As 
5ad57f31ae75
added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents:
300
diff
changeset

771 
in painting with oils the object painted last will show up on top. For 
5ad57f31ae75
added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents:
300
diff
changeset

772 
example, the $spumoni$ function below paints up a base of colors and then 
5ad57f31ae75
added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents:
300
diff
changeset

773 
paints a white text over the base. 
5ad57f31ae75
added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents:
300
diff
changeset

774 
""") 
5ad57f31ae75
added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents:
300
diff
changeset

775 

283  776 
eg(examples.testspumoni) 
777 

301
5ad57f31ae75
added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents:
300
diff
changeset

778 
disc(""" 
5ad57f31ae75
added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents:
300
diff
changeset

779 
The word "SPUMONI" is painted in white over the colored rectangles, 
5ad57f31ae75
added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents:
300
diff
changeset

780 
with the apparent effect of "removing" the color inside the body of 
5ad57f31ae75
added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents:
300
diff
changeset

781 
the word. 
5ad57f31ae75
added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents:
300
diff
changeset

782 
""") 
5ad57f31ae75
added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents:
300
diff
changeset

783 

283  784 
canvasdemo(examples.spumoni) 
785 

301
5ad57f31ae75
added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents:
300
diff
changeset

786 
disc(""" 
5ad57f31ae75
added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents:
300
diff
changeset

787 
The last letters of the word are not visible because the default canvas 
5ad57f31ae75
added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents:
300
diff
changeset

788 
background is white and painting white letters over a white background 
5ad57f31ae75
added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents:
300
diff
changeset

789 
leaves no visible effect. 
5ad57f31ae75
added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents:
300
diff
changeset

790 
""") 
5ad57f31ae75
added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents:
300
diff
changeset

791 

5ad57f31ae75
added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents:
300
diff
changeset

792 
disc(""" 
5ad57f31ae75
added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents:
300
diff
changeset

793 
This method of building up complex paintings in layers can be done 
5ad57f31ae75
added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents:
300
diff
changeset

794 
in very many layers in $pdfgen$  there are fewer physical limitations 
5ad57f31ae75
added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents:
300
diff
changeset

795 
than there are when dealing with physical paints. 
5ad57f31ae75
added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents:
300
diff
changeset

796 
""") 
5ad57f31ae75
added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents:
300
diff
changeset

797 

283  798 
eg(examples.testspumoni2) 
799 

301
5ad57f31ae75
added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents:
300
diff
changeset

800 
disc(""" 
5ad57f31ae75
added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents:
300
diff
changeset

801 
The $spumoni2$ function layers an ice cream cone over the 
5ad57f31ae75
added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents:
300
diff
changeset

802 
$spumoni$ drawing. Note that different parts of the cone 
5ad57f31ae75
added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents:
300
diff
changeset

803 
and scoops layer over eachother as well. 
5ad57f31ae75
added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents:
300
diff
changeset

804 
""") 
283  805 
canvasdemo(examples.spumoni2) 
806 

807 

317
fce6dad947c3
Pushed down most existing lessons one level; added
andy_robinson
parents:
314
diff
changeset

808 
heading2('Fonts and text objects') 
283  809 

301
5ad57f31ae75
added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents:
300
diff
changeset

810 
disc(""" 
5ad57f31ae75
added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents:
300
diff
changeset

811 
Text may be drawn in many different colors, fonts, and sizes in $pdfgen$. 
5ad57f31ae75
added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents:
300
diff
changeset

812 
The $textsize$ function demonstrates how to change the color and font and 
5ad57f31ae75
added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents:
300
diff
changeset

813 
size of text and how to place text on the page. 
5ad57f31ae75
added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents:
300
diff
changeset

814 
""") 
5ad57f31ae75
added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents:
300
diff
changeset

815 

298  816 
eg(examples.testtextsize) 
817 

301
5ad57f31ae75
added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents:
300
diff
changeset

818 
disc(""" 
5ad57f31ae75
added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents:
300
diff
changeset

819 
The $textsize$ function generates the following page. 
5ad57f31ae75
added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents:
300
diff
changeset

820 
""") 
5ad57f31ae75
added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents:
300
diff
changeset

821 

298  822 
canvasdemo(examples.textsize) 
823 

301
5ad57f31ae75
added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents:
300
diff
changeset

824 
disc(""" 
5ad57f31ae75
added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents:
300
diff
changeset

825 
A number of different fonts are always available in $pdfgen$. 
5ad57f31ae75
added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents:
300
diff
changeset

826 
""") 
5ad57f31ae75
added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents:
300
diff
changeset

827 

5ad57f31ae75
added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents:
300
diff
changeset

828 
eg(examples.testfonts) 
5ad57f31ae75
added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents:
300
diff
changeset

829 

5ad57f31ae75
added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents:
300
diff
changeset

830 
disc(""" 
5ad57f31ae75
added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents:
300
diff
changeset

831 
The $fonts$ function lists the fonts that are always available. 
5ad57f31ae75
added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents:
300
diff
changeset

832 
""") 
5ad57f31ae75
added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents:
300
diff
changeset

833 

5ad57f31ae75
added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents:
300
diff
changeset

834 
canvasdemo(examples.fonts) 
5ad57f31ae75
added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents:
300
diff
changeset

835 

5ad57f31ae75
added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents:
300
diff
changeset

836 
disc(""" 
5ad57f31ae75
added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents:
300
diff
changeset

837 
Other fonts can be added to a PDF document as well. 
5ad57f31ae75
added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents:
300
diff
changeset

838 
""") 
5ad57f31ae75
added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents:
300
diff
changeset

839 

317
fce6dad947c3
Pushed down most existing lessons one level; added
andy_robinson
parents:
314
diff
changeset

840 
heading2("Text object methods") 
298  841 

301
5ad57f31ae75
added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents:
300
diff
changeset

842 
disc(""" 
5ad57f31ae75
added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents:
300
diff
changeset

843 
For the dedicated presentation of text in a PDF document, use a text object. 
5ad57f31ae75
added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents:
300
diff
changeset

844 
The text object interface provides detailed control of text layout parameters 
5ad57f31ae75
added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents:
300
diff
changeset

845 
not available directly at the canvas level. 
5ad57f31ae75
added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents:
300
diff
changeset

846 
""") 
5ad57f31ae75
added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents:
300
diff
changeset

847 

299
909b83ce750c
textobject and pathobject methods, among other things
aaron_watters
parents:
298
diff
changeset

848 
eg("""textobject.setTextOrigin(x,y)""") 
909b83ce750c
textobject and pathobject methods, among other things
aaron_watters
parents:
298
diff
changeset

849 

909b83ce750c
textobject and pathobject methods, among other things
aaron_watters
parents:
298
diff
changeset

850 
eg("""textobject.setTextTransform(a,b,c,d,e,f)""") 
909b83ce750c
textobject and pathobject methods, among other things
aaron_watters
parents:
298
diff
changeset

851 

909b83ce750c
textobject and pathobject methods, among other things
aaron_watters
parents:
298
diff
changeset

852 
eg("""textobject.moveCursor(dx, dy) # from start of current LINE""") 
909b83ce750c
textobject and pathobject methods, among other things
aaron_watters
parents:
298
diff
changeset

853 

909b83ce750c
textobject and pathobject methods, among other things
aaron_watters
parents:
298
diff
changeset

854 
eg("""(x,y) = textobject.getCursor()""") 
909b83ce750c
textobject and pathobject methods, among other things
aaron_watters
parents:
298
diff
changeset

855 

909b83ce750c
textobject and pathobject methods, among other things
aaron_watters
parents:
298
diff
changeset

856 
eg("""x = textobject.getX(); y = textobject.getY()""") 
909b83ce750c
textobject and pathobject methods, among other things
aaron_watters
parents:
298
diff
changeset

857 

909b83ce750c
textobject and pathobject methods, among other things
aaron_watters
parents:
298
diff
changeset

858 
eg("""textobject.setFont(psfontname, size, leading = None)""") 
909b83ce750c
textobject and pathobject methods, among other things
aaron_watters
parents:
298
diff
changeset

859 

909b83ce750c
textobject and pathobject methods, among other things
aaron_watters
parents:
298
diff
changeset

860 
eg("""textobject.textOut(text)""") 
909b83ce750c
textobject and pathobject methods, among other things
aaron_watters
parents:
298
diff
changeset

861 

909b83ce750c
textobject and pathobject methods, among other things
aaron_watters
parents:
298
diff
changeset

862 
eg("""textobject.textLine(text='')""") 
909b83ce750c
textobject and pathobject methods, among other things
aaron_watters
parents:
298
diff
changeset

863 

909b83ce750c
textobject and pathobject methods, among other things
aaron_watters
parents:
298
diff
changeset

864 
eg("""textobject.textLines(stuff, trim=1)""") 
909b83ce750c
textobject and pathobject methods, among other things
aaron_watters
parents:
298
diff
changeset

865 

301
5ad57f31ae75
added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents:
300
diff
changeset

866 
disc(""" 
5ad57f31ae75
added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents:
300
diff
changeset

867 
The text object methods shown above relate to basic text geometry. 
5ad57f31ae75
added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents:
300
diff
changeset

868 
""") 
5ad57f31ae75
added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents:
300
diff
changeset

869 

5ad57f31ae75
added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents:
300
diff
changeset

870 
disc(""" 
5ad57f31ae75
added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents:
300
diff
changeset

871 
A text object maintains a text cursor which moves about the page when 
5ad57f31ae75
added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents:
300
diff
changeset

872 
text is drawn. For example the $setTextOrigin$ places the cursor 
5ad57f31ae75
added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents:
300
diff
changeset

873 
in a known position and the $textLine$ and $textLines$ methods move 
5ad57f31ae75
added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents:
300
diff
changeset

874 
the text cursor down past the lines that have been missing. 
5ad57f31ae75
added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents:
300
diff
changeset

875 
""") 
5ad57f31ae75
added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents:
300
diff
changeset

876 

299
909b83ce750c
textobject and pathobject methods, among other things
aaron_watters
parents:
298
diff
changeset

877 
eg(examples.testcursormoves1) 
909b83ce750c
textobject and pathobject methods, among other things
aaron_watters
parents:
298
diff
changeset

878 

301
5ad57f31ae75
added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents:
300
diff
changeset

879 
disc(""" 
304  880 
The $cursormoves$ function relies on the automatic 
301
5ad57f31ae75
added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents:
300
diff
changeset

881 
movement of the text cursor for placing text after the origin 
5ad57f31ae75
added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents:
300
diff
changeset

882 
has been set. 
5ad57f31ae75
added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents:
300
diff
changeset

883 
""") 
5ad57f31ae75
added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents:
300
diff
changeset

884 

299
909b83ce750c
textobject and pathobject methods, among other things
aaron_watters
parents:
298
diff
changeset

885 
canvasdemo(examples.cursormoves1) 
909b83ce750c
textobject and pathobject methods, among other things
aaron_watters
parents:
298
diff
changeset

886 

301
5ad57f31ae75
added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents:
300
diff
changeset

887 
disc(""" 
5ad57f31ae75
added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents:
300
diff
changeset

888 
It is also possible to control the movement of the cursor 
5ad57f31ae75
added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents:
300
diff
changeset

889 
more explicitly by using the $moveCursor$ method (which moves 
5ad57f31ae75
added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents:
300
diff
changeset

890 
the cursor as an offset from the start of the current <i>line</i> 
5ad57f31ae75
added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents:
300
diff
changeset

891 
NOT the current cursor, and which also has positive ^y^ offsets 
5ad57f31ae75
added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents:
300
diff
changeset

892 
move <i>down</i> (in contrast to the normal geometry where 
5ad57f31ae75
added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents:
300
diff
changeset

893 
positive ^y^ usually moves up. 
5ad57f31ae75
added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents:
300
diff
changeset

894 
""") 
5ad57f31ae75
added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents:
300
diff
changeset

895 

299
909b83ce750c
textobject and pathobject methods, among other things
aaron_watters
parents:
298
diff
changeset

896 
eg(examples.testcursormoves2) 
909b83ce750c
textobject and pathobject methods, among other things
aaron_watters
parents:
298
diff
changeset

897 

301
5ad57f31ae75
added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents:
300
diff
changeset

898 
disc(""" 
5ad57f31ae75
added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents:
300
diff
changeset

899 
Here the $textOut$ does not move the down a line in contrast 
5ad57f31ae75
added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents:
300
diff
changeset

900 
to the $textLine$ function which does move down. 
5ad57f31ae75
added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents:
300
diff
changeset

901 
""") 
5ad57f31ae75
added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents:
300
diff
changeset

902 

299
909b83ce750c
textobject and pathobject methods, among other things
aaron_watters
parents:
298
diff
changeset

903 
canvasdemo(examples.cursormoves2) 
909b83ce750c
textobject and pathobject methods, among other things
aaron_watters
parents:
298
diff
changeset

904 

317
fce6dad947c3
Pushed down most existing lessons one level; added
andy_robinson
parents:
314
diff
changeset

905 
heading3("Character Spacing") 
301
5ad57f31ae75
added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents:
300
diff
changeset

906 

299
909b83ce750c
textobject and pathobject methods, among other things
aaron_watters
parents:
298
diff
changeset

907 
eg("""textobject.setCharSpace(charSpace)""") 
909b83ce750c
textobject and pathobject methods, among other things
aaron_watters
parents:
298
diff
changeset

908 

301
5ad57f31ae75
added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents:
300
diff
changeset

909 
disc("""The $setCharSpace$ method adjusts one of the parameters of text  the intercharacter 
5ad57f31ae75
added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents:
300
diff
changeset

910 
spacing.""") 
5ad57f31ae75
added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents:
300
diff
changeset

911 

299
909b83ce750c
textobject and pathobject methods, among other things
aaron_watters
parents:
298
diff
changeset

912 
eg(examples.testcharspace) 
909b83ce750c
textobject and pathobject methods, among other things
aaron_watters
parents:
298
diff
changeset

913 

301
5ad57f31ae75
added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents:
300
diff
changeset

914 
disc("""The 
5ad57f31ae75
added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents:
300
diff
changeset

915 
$charspace$ function exercises various spacing settings. 
5ad57f31ae75
added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents:
300
diff
changeset

916 
It produces the following page.""") 
5ad57f31ae75
added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents:
300
diff
changeset

917 

304  918 
canvasdemo(examples.charspace) 
301
5ad57f31ae75
added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents:
300
diff
changeset

919 

317
fce6dad947c3
Pushed down most existing lessons one level; added
andy_robinson
parents:
314
diff
changeset

920 
heading3("Word Spacing") 
299
909b83ce750c
textobject and pathobject methods, among other things
aaron_watters
parents:
298
diff
changeset

921 

909b83ce750c
textobject and pathobject methods, among other things
aaron_watters
parents:
298
diff
changeset

922 
eg("""textobject.setWordSpace(wordSpace)""") 
909b83ce750c
textobject and pathobject methods, among other things
aaron_watters
parents:
298
diff
changeset

923 

304  924 
disc("The $setWordSpace$ method adjusts the space between word.") 
925 

299
909b83ce750c
textobject and pathobject methods, among other things
aaron_watters
parents:
298
diff
changeset

926 
eg(examples.testwordspace) 
909b83ce750c
textobject and pathobject methods, among other things
aaron_watters
parents:
298
diff
changeset

927 

304  928 
disc("""The $wordspace$ function shows what various word space settings 
929 
look like below.""") 

930 

299
909b83ce750c
textobject and pathobject methods, among other things
aaron_watters
parents:
298
diff
changeset

931 
canvasdemo(examples.wordspace) 
909b83ce750c
textobject and pathobject methods, among other things
aaron_watters
parents:
298
diff
changeset

932 

317
fce6dad947c3
Pushed down most existing lessons one level; added
andy_robinson
parents:
314
diff
changeset

933 
heading3("Horizontal Scaling") 
304  934 

299
909b83ce750c
textobject and pathobject methods, among other things
aaron_watters
parents:
298
diff
changeset

935 
eg("""textobject.setHorizScale(horizScale)""") 
909b83ce750c
textobject and pathobject methods, among other things
aaron_watters
parents:
298
diff
changeset

936 

304  937 
disc("""Lines of text can be stretched or shrunken horizontally by the 
938 
$setHorizScale$ method.""") 

939 

299
909b83ce750c
textobject and pathobject methods, among other things
aaron_watters
parents:
298
diff
changeset

940 
eg(examples.testhorizontalscale) 
909b83ce750c
textobject and pathobject methods, among other things
aaron_watters
parents:
298
diff
changeset

941 

304  942 
disc("""The horizontal scaling parameter ^horizScale^ 
943 
is given in percentages (with 100 as the default), so the 80 setting 

944 
shown below looks skinny. 

945 
""") 

299
909b83ce750c
textobject and pathobject methods, among other things
aaron_watters
parents:
298
diff
changeset

946 
canvasdemo(examples.horizontalscale) 
909b83ce750c
textobject and pathobject methods, among other things
aaron_watters
parents:
298
diff
changeset

947 

317
fce6dad947c3
Pushed down most existing lessons one level; added
andy_robinson
parents:
314
diff
changeset

948 
heading3("Interline spacing (Leading)") 
304  949 

299
909b83ce750c
textobject and pathobject methods, among other things
aaron_watters
parents:
298
diff
changeset

950 
eg("""textobject.setLeading(leading)""") 
909b83ce750c
textobject and pathobject methods, among other things
aaron_watters
parents:
298
diff
changeset

951 

304  952 
disc("""The vertical offset between the point at which one 
953 
line starts and where the next starts is called the leading 

954 
offset. The $setLeading$ method adjusts the leading offset. 

955 
""") 

956 

299
909b83ce750c
textobject and pathobject methods, among other things
aaron_watters
parents:
298
diff
changeset

957 
eg(examples.testleading) 
909b83ce750c
textobject and pathobject methods, among other things
aaron_watters
parents:
298
diff
changeset

958 

304  959 
disc("""As shown below if the leading offset is set too small 
960 
characters of one line my write over the bottom parts of characters 

961 
in the previous line.""") 

962 

299
909b83ce750c
textobject and pathobject methods, among other things
aaron_watters
parents:
298
diff
changeset

963 
canvasdemo(examples.leading) 
909b83ce750c
textobject and pathobject methods, among other things
aaron_watters
parents:
298
diff
changeset

964 

317
fce6dad947c3
Pushed down most existing lessons one level; added
andy_robinson
parents:
314
diff
changeset

965 
heading3("Other text object methods") 
304  966 

299
909b83ce750c
textobject and pathobject methods, among other things
aaron_watters
parents:
298
diff
changeset

967 
eg("""textobject.setTextRenderMode(mode)""") 
909b83ce750c
textobject and pathobject methods, among other things
aaron_watters
parents:
298
diff
changeset

968 

304  969 
disc("""The $setTextRenderMode$ method allows text to be used 
970 
as a forground for clipping background drawings, for example.""") 

971 

299
909b83ce750c
textobject and pathobject methods, among other things
aaron_watters
parents:
298
diff
changeset

972 
eg("""textobject.setRise(rise)""") 
909b83ce750c
textobject and pathobject methods, among other things
aaron_watters
parents:
298
diff
changeset

973 

304  974 
disc(""" 
975 
The $setRise$ method <super>raises</super> or <sub>lowers</sub> text on the line 

976 
(for creating superscripts or subscripts, for example). 

977 
""") 

978 

299
909b83ce750c
textobject and pathobject methods, among other things
aaron_watters
parents:
298
diff
changeset

979 
eg("""textobject.setFillColor(aColor); 
909b83ce750c
textobject and pathobject methods, among other things
aaron_watters
parents:
298
diff
changeset

980 
textobject.setStrokeColor(self, aColor) 
909b83ce750c
textobject and pathobject methods, among other things
aaron_watters
parents:
298
diff
changeset

981 
# and similar""") 
298  982 

304  983 
disc(""" 
984 
These color change operations change the <font color=darkviolet>color</font> of the text and are otherwise 

985 
similar to the color methods for the canvas object.""") 

986 

317
fce6dad947c3
Pushed down most existing lessons one level; added
andy_robinson
parents:
314
diff
changeset

987 
heading2('Paths and Lines') 
298  988 

304  989 
disc("""Just as textobjects are designed for the dedicated presentation 
990 
of text, path objects are designed for the dedicated construction of 

991 
graphical figures. When path objects are drawn onto a canvas they are 

992 
are drawn as one figure (like a rectangle) and the mode of drawing 

993 
for the entire figure can be adjusted: the lines of the figure can 

994 
be drawn (stroked) or not; the interior of the figure can be filled or 

995 
not; and so forth.""") 

996 

997 
disc(""" 

998 
For example the $star$ function uses a path object 

999 
to draw a star 

1000 
""") 

1001 

298  1002 
eg(examples.teststar) 
1003 

304  1004 
disc(""" 
1005 
The $star$ function has been designed to be useful in illustrating 

1006 
various line style parameters supported by $pdfgen$. 

1007 
""") 

1008 

298  1009 
canvasdemo(examples.star) 
1010 

317
fce6dad947c3
Pushed down most existing lessons one level; added
andy_robinson
parents:
314
diff
changeset

1011 
heading3("Line join settings") 
304  1012 

1013 
disc(""" 

1014 
The $setLineJoin$ method can adjust whether line segments meet in a point 

1015 
a square or a rounded vertex. 

1016 
""") 

1017 

298  1018 
eg(examples.testjoins) 
1019 

304  1020 
disc(""" 
1021 
The line join setting is only really of interest for thick lines because 

1022 
it cannot be seen clearly for thin lines. 

1023 
""") 

1024 

298  1025 
canvasdemo(examples.joins) 
1026 

317
fce6dad947c3
Pushed down most existing lessons one level; added
andy_robinson
parents:
314
diff
changeset

1027 
heading3("Line cap settings") 
304  1028 

1029 
disc("""The line cap setting, adjusted using the $setLineCap$ method, 

1030 
determines whether a terminating line 

1031 
ends in a square exactly at the vertex, a square over the vertex 

1032 
or a half circle over the vertex. 

1033 
""") 

1034 

298  1035 
eg(examples.testcaps) 
1036 

304  1037 
disc("""The line cap setting, like the line join setting, is only 
1038 
visible when the lines are thick.""") 

1039 

298  1040 
canvasdemo(examples.caps) 
1041 

317
fce6dad947c3
Pushed down most existing lessons one level; added
andy_robinson
parents:
314
diff
changeset

1042 
heading3("Dashes and broken lines") 
304  1043 

1044 
disc(""" 

1045 
The $setDash$ method allows lines to be broken into dots or dashes. 

1046 
""") 

1047 

298  1048 
eg(examples.testdashes) 
1049 

304  1050 
disc(""" 
1051 
The patterns for the dashes or dots can be in a simple on/off repeating pattern 

1052 
or they can be specified in a complex repeating pattern. 

1053 
""") 

1054 

298  1055 
canvasdemo(examples.dashes) 
283  1056 

317
fce6dad947c3
Pushed down most existing lessons one level; added
andy_robinson
parents:
314
diff
changeset

1057 
heading3("Creating complex figures with path objects") 
304  1058 

1059 
disc(""" 

1060 
Combinations of lines, curves, arcs and other figures 

1061 
can be combined into a single figure using path objects. 

1062 
For example the function shown below constructs two path 

1063 
objects using lines and curves. 

1064 
This function will be used later on as part of a 

1065 
pencil icon construction. 

1066 
""") 

1067 

296  1068 
eg(examples.testpenciltip) 
1069 

304  1070 
disc(""" 
1071 
Note that the interior of the pencil tip is filled 

1072 
as one object even though it is constructed from 

1073 
several lines and curves. The pencil lead is then 

1074 
drawn over it using a new path object. 

1075 
""") 

1076 

296  1077 
canvasdemo(examples.penciltip) 
1078 

317
fce6dad947c3
Pushed down most existing lessons one level; added
andy_robinson
parents:
314
diff
changeset

1079 
heading2('Rectangles, circles, ellipses') 
283  1080 

304  1081 
disc(""" 
1082 
The $pdfgen$ module supports a number of generally useful shapes 

1083 
such as rectangles, rounded rectangles, ellipses, and circles. 

1084 
Each of these figures can be used in path objects or can be drawn 

1085 
directly on a canvas. For example the $pencil$ function below 

1086 
draws a pencil icon using rectangles and rounded rectangles with 

1087 
various fill colors and a few other annotations. 

1088 
""") 

1089 

296  1090 
eg(examples.testpencil) 
1091 

304  1092 
pencilnote() 
1093 

1094 
disc(""" 

1095 
Note that this function is used to create the "margin pencil" to the left. 

1096 
Also note that the order in which the elements are drawn are important 

1097 
because, for example, the white rectangles "erase" parts of a black rectangle 

1098 
and the "tip" paints over part of the yellow rectangle. 

1099 
""") 

1100 

296  1101 
canvasdemo(examples.pencil) 
1102 

317
fce6dad947c3
Pushed down most existing lessons one level; added
andy_robinson
parents:
314
diff
changeset

1103 
heading2('Bezier curves') 
273
cd705b27b6a5
initial checkin. user guide generation framework.
aaron_watters
parents:
diff
changeset

1104 

304  1105 
disc(""" 
1106 
Programs that wish to construct figures with curving borders 

1107 
generally use Bezier curves to form the borders. 

1108 
""") 

1109 

293  1110 
eg(examples.testbezier) 
1111 

304  1112 
disc(""" 
1113 
A Bezier curve is specified by four control points 

1114 
$(x1,y1)$, $(x2,y2)$, $(x3,y3)$, $(x4,y4)$. 

1115 
The curve starts at $(x1,y1)$ and ends at $(x4,y4)$ 

1116 
and the line segment from $(x1,y1)$ to $(x2,y2)$ 

1117 
and the line segment from $(x3,y3)$ to $(x4,y4)$ 

1118 
both form tangents to the curve. Furthermore the 

1119 
curve is entirely contained in the convex figure with vertices 

1120 
at the control points. 

1121 
""") 

1122 

293  1123 
canvasdemo(examples.bezier) 
1124 

304  1125 
disc(""" 
1126 
The drawing above (the output of $testbezier$) shows 

1127 
a bezier curves, the tangent lines defined by the control points 

1128 
and the convex figure with vertices at the control points. 

1129 
""") 

1130 

317
fce6dad947c3
Pushed down most existing lessons one level; added
andy_robinson
parents:
314
diff
changeset

1131 
heading3("Smoothly joining bezier curve sequences") 
304  1132 

1133 
disc(""" 

1134 
It is often useful to join several bezier curves to form a 

1135 
single smooth curve. To construct a larger smooth curve from 

1136 
several bezier curves make sure that the tangent lines to adjacent 

1137 
bezier curves that join at a control point lie on the same line. 

1138 
""") 

1139 

293  1140 
eg(examples.testbezier2) 
1141 

304  1142 
disc(""" 
1143 
The figure created by $testbezier2$ describes a smooth 

1144 
complex curve because adjacent tangent lines "line up" as 

1145 
illustrated below. 

1146 
""") 

1147 

293  1148 
canvasdemo(examples.bezier2) 
1149 

317
fce6dad947c3
Pushed down most existing lessons one level; added
andy_robinson
parents:
314
diff
changeset

1150 
heading2("Path object methods") 
298  1151 

299
909b83ce750c
textobject and pathobject methods, among other things
aaron_watters
parents:
298
diff
changeset

1152 
eg("""pathobject.moveTo(x,y)""") 
909b83ce750c
textobject and pathobject methods, among other things
aaron_watters
parents:
298
diff
changeset

1153 

909b83ce750c
textobject and pathobject methods, among other things
aaron_watters
parents:
298
diff
changeset

1154 
eg("""pathobject.lineTo(x,y)""") 
909b83ce750c
textobject and pathobject methods, among other things
aaron_watters
parents:
298
diff
changeset

1155 

909b83ce750c
textobject and pathobject methods, among other things
aaron_watters
parents:
298
diff
changeset

1156 
eg("""pathobject.curveTo(x1, y1, x2, y2, x3, y3) """) 
909b83ce750c
textobject and pathobject methods, among other things
aaron_watters
parents:
298
diff
changeset

1157 

909b83ce750c
textobject and pathobject methods, among other things
aaron_watters
parents:
298
diff
changeset

1158 
eg("""pathobject.arc(x1,y1, x2,y2, startAng=0, extent=90) """) 
909b83ce750c
textobject and pathobject methods, among other things
aaron_watters
parents:
298
diff
changeset

1159 

909b83ce750c
textobject and pathobject methods, among other things
aaron_watters
parents:
298
diff
changeset

1160 
eg("""pathobject.arcTo(x1,y1, x2,y2, startAng=0, extent=90) """) 
909b83ce750c
textobject and pathobject methods, among other things
aaron_watters
parents:
298
diff
changeset

1161 

909b83ce750c
textobject and pathobject methods, among other things
aaron_watters
parents:
298
diff
changeset

1162 
eg("""pathobject.rect(x, y, width, height) """) 
909b83ce750c
textobject and pathobject methods, among other things
aaron_watters
parents:
298
diff
changeset

1163 

909b83ce750c
textobject and pathobject methods, among other things
aaron_watters
parents:
298
diff
changeset

1164 
eg("""pathobject.ellipse(x, y, width, height)""") 
909b83ce750c
textobject and pathobject methods, among other things
aaron_watters
parents:
298
diff
changeset

1165 

909b83ce750c
textobject and pathobject methods, among other things
aaron_watters
parents:
298
diff
changeset

1166 
eg("""pathobject.circle(x_cen, y_cen, r) """) 
909b83ce750c
textobject and pathobject methods, among other things
aaron_watters
parents:
298
diff
changeset

1167 

909b83ce750c
textobject and pathobject methods, among other things
aaron_watters
parents:
298
diff
changeset

1168 
eg("""pathobject.close() """) 
909b83ce750c
textobject and pathobject methods, among other things
aaron_watters
parents:
298
diff
changeset

1169 

301
5ad57f31ae75
added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents:
300
diff
changeset

1170 
eg(examples.testhand) 
5ad57f31ae75
added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents:
300
diff
changeset

1171 

5ad57f31ae75
added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents:
300
diff
changeset

1172 
canvasdemo(examples.hand) 
5ad57f31ae75
added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents:
300
diff
changeset

1173 

5ad57f31ae75
added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents:
300
diff
changeset

1174 

5ad57f31ae75
added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents:
300
diff
changeset

1175 
eg(examples.testhand2) 
5ad57f31ae75
added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents:
300
diff
changeset

1176 

5ad57f31ae75
added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents:
300
diff
changeset

1177 
canvasdemo(examples.hand2) 
5ad57f31ae75
added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents:
300
diff
changeset

1178 

5ad57f31ae75
added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents:
300
diff
changeset

1179 

298  1180 
##### FILL THEM IN 
1181 

317
fce6dad947c3
Pushed down most existing lessons one level; added
andy_robinson
parents:
314
diff
changeset

1182 

fce6dad947c3
Pushed down most existing lessons one level; added
andy_robinson
parents:
314
diff
changeset

1183 
heading1("Exposing PDF Special Capabilities") 
fce6dad947c3
Pushed down most existing lessons one level; added
andy_robinson
parents:
314
diff
changeset

1184 
disc("""PDF provides a number of features to make electronic 
fce6dad947c3
Pushed down most existing lessons one level; added
andy_robinson
parents:
314
diff
changeset

1185 
document viewing more efficient and comfortable, and 
fce6dad947c3
Pushed down most existing lessons one level; added
andy_robinson
parents:
314
diff
changeset

1186 
our library exposes a number of these.""") 
fce6dad947c3
Pushed down most existing lessons one level; added
andy_robinson
parents:
314
diff
changeset

1187 

fce6dad947c3
Pushed down most existing lessons one level; added
andy_robinson
parents:
314
diff
changeset

1188 
heading2("Forms") 
fce6dad947c3
Pushed down most existing lessons one level; added
andy_robinson
parents:
314
diff
changeset

1189 
heading2("Links and Destinations") 
fce6dad947c3
Pushed down most existing lessons one level; added
andy_robinson
parents:
314
diff
changeset

1190 
heading2("Outline Trees") 
fce6dad947c3
Pushed down most existing lessons one level; added
andy_robinson
parents:
314
diff
changeset

1191 
heading2("Page Transition Effects") 
fce6dad947c3
Pushed down most existing lessons one level; added
andy_robinson
parents:
314
diff
changeset

1192 

fce6dad947c3
Pushed down most existing lessons one level; added
andy_robinson
parents:
314
diff
changeset

1193 

fce6dad947c3
Pushed down most existing lessons one level; added
andy_robinson
parents:
314
diff
changeset

1194 

296  1195 

1196 
#####################################################################################################3 

1197 

317
fce6dad947c3
Pushed down most existing lessons one level; added
andy_robinson
parents:
314
diff
changeset

1198 
heading1("PLATYPUS  Page Layout and Typography Using Scripts") 
fce6dad947c3
Pushed down most existing lessons one level; added
andy_robinson
parents:
314
diff
changeset

1199 
heading2("Design Goals") 
fce6dad947c3
Pushed down most existing lessons one level; added
andy_robinson
parents:
314
diff
changeset

1200 
heading2("Frames and Flowables") 
fce6dad947c3
Pushed down most existing lessons one level; added
andy_robinson
parents:
314
diff
changeset

1201 
heading2("Paragraphs in detail") 
fce6dad947c3
Pushed down most existing lessons one level; added
andy_robinson
parents:
314
diff
changeset

1202 
heading2("Tables") 
fce6dad947c3
Pushed down most existing lessons one level; added
andy_robinson
parents:
314
diff
changeset

1203 
heading2("Custom Flowable Objects") 
fce6dad947c3
Pushed down most existing lessons one level; added
andy_robinson
parents:
314
diff
changeset

1204 
heading3("A very simple Flowable") 
296  1205 

1206 
eg(examples.testnoteannotation) 

317
fce6dad947c3
Pushed down most existing lessons one level; added
andy_robinson
parents:
314
diff
changeset

1207 

fce6dad947c3
Pushed down most existing lessons one level; added
andy_robinson
parents:
314
diff
changeset

1208 
heading2("Document Templates") 
fce6dad947c3
Pushed down most existing lessons one level; added
andy_robinson
parents:
314
diff
changeset

1209 

fce6dad947c3
Pushed down most existing lessons one level; added
andy_robinson
parents:
314
diff
changeset

1210 
heading1("Future Directions") 
fce6dad947c3
Pushed down most existing lessons one level; added
andy_robinson
parents:
314
diff
changeset

1211 

fce6dad947c3
Pushed down most existing lessons one level; added
andy_robinson
parents:
314
diff
changeset

1212 

273
cd705b27b6a5
initial checkin. user guide generation framework.
aaron_watters
parents:
diff
changeset

1213 

cd705b27b6a5
initial checkin. user guide generation framework.
aaron_watters
parents:
diff
changeset

1214 
if __name__=="__main__": 
cd705b27b6a5
initial checkin. user guide generation framework.
aaron_watters
parents:
diff
changeset

1215 
g = Guide() 
cd705b27b6a5
initial checkin. user guide generation framework.
aaron_watters
parents:
diff
changeset

1216 
g.go() 
308  1217 