author  andy_robinson 
Mon, 03 Jul 2000 16:03:31 +0000  
changeset 318  03c9f114c621 
parent 317  fce6dad947c3 
child 320  7a4ca2b5bb89 
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 $ 
318  35 
# Revision 1.15 2000/07/03 16:03:31 andy_robinson 
36 
# Changes to heading structure 

37 
# 

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

38 
# 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

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

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

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

43 
# 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

44 
# abspath is 1.5.2 only 
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.12 2000/06/28 16:10:00 rgbecker 
fce6dad947c3
Pushed down most existing lessons one level; added
andy_robinson
parents:
314
diff
changeset

47 
# Fix unwanted 'i' 
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.11 2000/06/28 14:52:43 rgbecker 
fce6dad947c3
Pushed down most existing lessons one level; added
andy_robinson
parents:
314
diff
changeset

50 
# Documentation 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.10 2000/06/27 10:09:48 rgbecker 
fce6dad947c3
Pushed down most existing lessons one level; added
andy_robinson
parents:
314
diff
changeset

53 
# Minor cosmetic changes 
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.9 2000/06/23 21:09:03 aaron_watters 
fce6dad947c3
Pushed down most existing lessons one level; added
andy_robinson
parents:
314
diff
changeset

56 
# text text and more 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.8 2000/06/22 19:05:24 aaron_watters 
fce6dad947c3
Pushed down most existing lessons one level; added
andy_robinson
parents:
314
diff
changeset

59 
# 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

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

61 
# 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

62 
# showPage resets all state parameters warning. 
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.6 2000/06/22 13:35:28 aaron_watters 
fce6dad947c3
Pushed down most existing lessons one level; added
andy_robinson
parents:
314
diff
changeset

65 
# textobject and pathobject methods, among other things 
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.5 2000/06/21 21:19:29 aaron_watters 
fce6dad947c3
Pushed down most existing lessons one level; added
andy_robinson
parents:
314
diff
changeset

68 
# colors, line styles, more examples 
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.4 2000/06/21 15:16:05 aaron_watters 
fce6dad947c3
Pushed down most existing lessons one level; added
andy_robinson
parents:
314
diff
changeset

71 
# Lots of graphical examples added 
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.3 2000/06/20 20:31:42 aaron_watters 
fce6dad947c3
Pushed down most existing lessons one level; added
andy_robinson
parents:
314
diff
changeset

74 
# typos and more examples 
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.2 2000/06/19 21:13:02 aaron_watters 
fce6dad947c3
Pushed down most existing lessons one level; added
andy_robinson
parents:
314
diff
changeset

77 
# 2nd try. more text 
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 
# 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

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

81 
# 
318  82 
__version__=''' $Id: genuserguide.py,v 1.15 2000/07/03 16:03:31 andy_robinson Exp $ ''' 
273
cd705b27b6a5
initial checkin. user guide generation framework.
aaron_watters
parents:
diff
changeset

83 

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 
__doc__ = """ 
cd705b27b6a5
initial checkin. user guide generation framework.
aaron_watters
parents:
diff
changeset

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

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

88 

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

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

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

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

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

95 
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

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

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

98 
styleSheet = getStyleSheet() 
310  99 

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

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

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

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

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

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

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

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

109 

318  110 

111 

112 

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

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

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

115 

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

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

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

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

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

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

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

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

125 

301
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 
def quickfix(text): 
5ad57f31ae75
added quickhack for font changes in paragraphs and lots of new text
aaron_watters
parents:
300
diff
changeset

128 
"""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

129 
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

130 
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

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

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

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

134 
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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

154 
#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

155 

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

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

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

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

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

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

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

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

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

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

166 
# width=6.25*inch,height=0.62*inch) 
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.drawRightString(xsizeinch, ysize0.8*inch, "ReportLab User Guide") 
fce6dad947c3
Pushed down most existing lessons one level; added
andy_robinson
parents:
314
diff
changeset

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

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

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

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

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

174 
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

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

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

177 

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

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

179 
def __init__(self): 
310  180 
if _oldStyle: 
181 
self.myannotations = PageAnnotations() 

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

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

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

184 
# generate the doc... 
310  185 
doc = RLDocTemplate(filename,pagesize = letter) 
186 
story = self.story 

187 
if _oldStyle: 

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

189 
else: 

190 
doc.build(story) 

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

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

192 

310  193 
H1 = styleSheet['Heading1'] 
194 
H2 = styleSheet['Heading2'] 

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

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

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

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

198 

318  199 
#set up numbering 
200 
seq = getSequencer() 

201 
seq.setFormat('Chapter','1') 

202 
seq.setFormat('Section','1') 

203 
seq.setFormat('Appendix','A') 

204 
seq.chain('Chapter','Section') 

205 

206 

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

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

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

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

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

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

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

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

216 
# size for every example 
283  217 
examplefunctionxinches = 5.5 
218 
examplefunctionyinches = 3 

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

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

220 

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

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

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

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

224 

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

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

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

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

228 

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

229 
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

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

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

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

233 

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

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

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

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

237 

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

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

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

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

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

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

243 

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

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

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

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

247 

310  248 

249 
def title(text): 

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

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

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

252 

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

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

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

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

256 

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

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

258 

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

259 
#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

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

261 

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

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

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

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

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

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

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

268 

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

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

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

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

272 
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

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

274 

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

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

276 
"""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

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

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

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

280 

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

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

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

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

284 

273
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 canvasdemo(function): 
cd705b27b6a5
initial checkin. user guide generation framework.
aaron_watters
parents:
diff
changeset

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

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

289 

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

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

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

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

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

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

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

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

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

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

299 

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

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

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

302 

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

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

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

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

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

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

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

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

310 

296  311 

312 
def pencilnote(): 

313 
BODY.append(examples.NoteAnnotation()) 

314 

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

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

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

317 

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

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

319 

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

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

321 

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

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

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

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

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

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

327 

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

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

329 

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

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

331 

296  332 
#pencilnote() 
333 

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

335 

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

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

337 
appear in italics like this.""") 
318  338 
todo("") 
317
fce6dad947c3
Pushed down most existing lessons one level; added
andy_robinson
parents:
314
diff
changeset

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

340 
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

341 
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

342 
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

343 
draw inside that.""") 
318  344 
todo("") 
345 
todo("""Sequencer is postincrementing chapters, so all 

346 
section numbers are getting a chapter number one too high!""") 

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

347 

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

348 

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

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

350 

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

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

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

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

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

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

356 
""") 
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("What is PDFgen all about") 
fce6dad947c3
Pushed down most existing lessons one level; added
andy_robinson
parents:
314
diff
changeset

359 
todo("rationale  from Andy") 
296  360 
#canvasdemo(NOP) # execute some code 
361 

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

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

363 
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

364 

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

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

366 
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

367 

296  368 
pencilnote() 
369 

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

372 
""") 

373 

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

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

375 

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

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

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

378 
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

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

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

381 
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

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

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

384 

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

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

386 
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

387 
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

388 
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

389 
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

390 
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

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

392 

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

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

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

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

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

397 

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

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

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

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

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

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

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

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

405 

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

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

407 
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

408 
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

409 
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

410 
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

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

412 

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

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

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

415 
current page and any further operations will draw on a subsequent 
293  416 
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

417 
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

418 
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

419 
document, which is the whole purpose of the $canvas$ object. 
273
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 

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

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

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

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

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

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

427 

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

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

429 

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

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

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

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

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

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

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

438 

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

439 
disc(""" 
283  440 
If we imagine the program as a painter working on 
441 
the canvas the "draw" operations apply paint to the canvas using 

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

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

444 
(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

445 
the current font to $TimesRoman$ in 15 points, for example). 
283  446 
""") 
447 

448 
disc(""" 

449 
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

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

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

452 

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

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

454 

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

455 
heading3("About the demos in this document") 
283  456 

457 
disc(""" 

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

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

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

293  461 
and %s inches tall. The demo displays show the actual output of the demo 
283  462 
code. 
463 
""" % (examplefunctionxinches, examplefunctionyinches)) 

464 

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

465 
heading2('The tools: the "draw" operations') 
283  466 

467 
disc(""" 

468 
This section briefly lists the tools available to the program 

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

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

471 
here for easy reference and for summary purposes. 

472 
""") 

473 

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

474 
heading3("Line methods") 
283  475 

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

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

478 

479 
disc(""" 

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

481 
""") 

482 

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

483 
heading3("Shape methods") 
283  484 

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

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

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

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

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

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

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

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

493 

494 
disc(""" 

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

496 
""") 

497 

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

498 
heading3("String drawing methods") 
283  499 

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

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

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

503 

504 
disc(""" 

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

506 
""") 

507 

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

508 
heading3("The text object methods") 
283  509 
eg("""textobject = canvas.beginText(x, y) """) 
510 
eg("""canvas.drawText(textobject) """) 

511 

512 
disc(""" 

513 
Text objects are used to format text in ways that 

514 
are not supported directly by the canvas interface. 

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

516 
and then formats text by invoking textobject methods. 

517 
Finally the textobject is drawn onto the canvas using 

518 
drawText. 

519 
""") 

520 

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

521 
heading3("The path object methods") 
283  522 

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

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

283  526 

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

527 
heading3("Image methods") 
283  528 

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

530 

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

531 
heading3("Ending a page") 
283  532 

533 
eg("""canvas.showPage()""") 

534 

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

535 
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

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

537 

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

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

539 

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

540 
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

541 
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

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

543 

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

544 
heading2('The toolbox: the "state change" operations') 
283  545 

546 
disc(""" 

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

548 
program 

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

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

551 
""") 

552 

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

553 
heading3("Changing Colors") 
283  554 
eg("""canvas.setFillColorCMYK(c, m, y, k) """) 
555 
eg("""canvas.setStrikeColorCMYK(c, m, y, k) """) 

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

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

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

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

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

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

562 

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

563 
heading3("Changing Fonts") 
283  564 
eg("""canvas.setFont(psfontname, size, leading = None) """) 
565 

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

566 
heading3("Changing Graphical Styles") 
283  567 

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

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

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

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

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

573 

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

574 
heading3("Changing Geometry") 
283  575 

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

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

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

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

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

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

582 

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

583 
heading3("State control") 
283  584 

585 
eg("""canvas.saveState() """) 

586 
eg("""canvas.restoreState() """) 

587 

588 

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

589 
heading2("Other canvas methods.") 
283  590 

591 
disc(""" 

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

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

594 
""") 

595 

596 
eg(""" 

597 
canvas.setAuthor() 

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

599 
canvas.setTitle(title) 

600 
canvas.setSubject(subj) 

601 
canvas.pageHasData() 

602 
canvas.showOutline() 

603 
canvas.bookmarkPage(name) 

604 
canvas.bookmarkHorizontalAbsolute(name, yhorizontal) 

605 
canvas.doForm() 

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

607 
canvas.endForm() 

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

609 
canvas.getPageNumber() 

610 
canvas.addLiteral() 

611 
canvas.getAvailableFonts() 

308  612 
canvas.stringWidth(self, text, fontName, fontSize, encoding=None) 
283  613 
canvas.setPageCompression(onoff=1) 
614 
canvas.setPageTransition(self, effectname=None, duration=1, 

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

616 
""") 

617 

618 

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

619 
heading2('Coordinates (default user space)') 
283  620 

621 
disc(""" 

622 
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

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

626 
""") 

627 

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

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

630 

631 
eg(examples.testcoords) 

632 

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

633 
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

634 
left corner. Executing the $coords$ function in the default user space 
283  635 
(for the "demo minipage") we obtain the following.""") 
636 

637 
canvasdemo(examples.coords) 

638 

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

639 
heading3("Moving the origin: the $translate$ method") 
283  640 

641 
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

642 
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

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

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

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

647 

648 
eg(examples.testtranslate) 

649 

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

651 

652 
canvasdemo(examples.translate) 

653 

296  654 

655 
#canvasdemo(NOP) # execute some code 

656 

657 
pencilnote() 

658 

659 

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

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

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

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

666 
""") 

667 

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

668 
heading3("Shrinking and growing: the scale operation") 
283  669 

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

670 
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

671 
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

672 
^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

673 
$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

674 
$dx$ and $dy$ are different. 
283  675 
""") 
676 

677 
eg(examples.testscale) 

678 

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

680 

681 
canvasdemo(examples.scale) 

682 

296  683 

684 
#canvasdemo(NOP) # execute some code 

685 

686 
pencilnote() 

687 

688 

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

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

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

693 
operations are important.""") 

694 

695 
eg(examples.testscaletranslate) 

696 

697 
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

698 
and then does a $scale$ followed by a $translate$. Afterward the function 
283  699 
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

700 
translation) and then does the <i>same</i> operations in a different order. 
283  701 
Observe the effect below.""") 
702 

703 
canvasdemo(examples.scaletranslate) 

704 

296  705 

706 
#canvasdemo(NOP) # execute some code 

707 

708 
pencilnote() 

709 

710 

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

713 
scaled microscopic units 

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

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

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

717 
such as these scale and translate 

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

719 

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

720 
heading3("Saving and restoring the canvas state: $saveState$ and $restoreState$") 
283  721 

722 
disc(""" 

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

723 
The $scaletranslate$ function used an important feature of the canvas object: 
283  724 
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

725 
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

726 
an $canvas.restoreState()$ operations all changes of font, color, line style, 
283  727 
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

728 
restored to the state at the point of the $saveState()$. Remember that the save/restore 
283  729 
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

730 
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

731 
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

732 
across page breaks. 
283  733 
""") 
734 

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

735 
heading3("Mirror image") 
293  736 

737 
disc(""" 

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

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

740 
""") 

741 

742 
eg(examples.testmirror) 

743 

744 
disc(""" 

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

745 
creates a mirror image of the elements drawn by the $coord$ function. 
293  746 
""") 
747 

748 
canvasdemo(examples.mirror) 

749 

750 
disc(""" 

751 
Notice that the text strings are painted backwards. 

752 
""") 

753 

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

754 
heading2("Colors") 
298  755 

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

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

757 
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

758 
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

759 
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

760 
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

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

762 

298  763 
eg(examples.testcolors) 
764 

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

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

766 
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

767 
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

768 
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

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

770 

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

771 
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

772 
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

773 
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

774 
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

775 
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

776 
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

777 
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

778 
$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

779 
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

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

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

782 

298  783 
canvasdemo(examples.colors) 
784 

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

785 
heading2('Painting back to front') 
283  786 

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

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

788 
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

789 
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

790 
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

791 
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

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

793 

283  794 
eg(examples.testspumoni) 
795 

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

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

797 
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

798 
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

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

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

801 

283  802 
canvasdemo(examples.spumoni) 
803 

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

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

805 
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

806 
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

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

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

809 

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 
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

812 
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

813 
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

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

815 

283  816 
eg(examples.testspumoni2) 
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 $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

820 
$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

821 
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

822 
""") 
283  823 
canvasdemo(examples.spumoni2) 
824 

825 

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

826 
heading2('Fonts and text objects') 
283  827 

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

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

829 
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

830 
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

831 
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

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

833 

298  834 
eg(examples.testtextsize) 
835 

301
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 
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

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

839 

298  840 
canvasdemo(examples.textsize) 
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 
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

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

845 

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

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

847 

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

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

849 
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

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

851 

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

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

853 

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

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

855 
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

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

857 

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

858 
heading2("Text object methods") 
298  859 

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

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

861 
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

862 
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

863 
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

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

865 

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

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

867 

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

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

869 

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

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

871 

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

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

873 

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

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

875 

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

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

877 

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

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

879 

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

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

881 

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

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

883 

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

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

885 
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

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

887 

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

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

889 
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

890 
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

891 
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

892 
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

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

894 

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

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

896 

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

897 
disc(""" 
304  898 
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

899 
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

900 
has been set. 
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.cursormoves1) 
909b83ce750c
textobject and pathobject methods, among other things
aaron_watters
parents:
298
diff
changeset

904 

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

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

906 
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

907 
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

908 
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

909 
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

910 
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

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

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

913 

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

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

915 

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

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

917 
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

918 
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

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

920 

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

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

922 

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

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

924 

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

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

926 

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

927 
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

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

929 

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

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

931 

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

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

933 
$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

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

935 

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

937 

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

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

939 

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

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

941 

304  942 
disc("The $setWordSpace$ method adjusts the space between word.") 
943 

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

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

945 

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

948 

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

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

950 

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

951 
heading3("Horizontal Scaling") 
304  952 

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

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

954 

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

957 

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

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

959 

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

962 
shown below looks skinny. 

963 
""") 

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

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

965 

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

966 
heading3("Interline spacing (Leading)") 
304  967 

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

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

969 

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

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

973 
""") 

974 

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

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

976 

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

979 
in the previous line.""") 

980 

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

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

982 

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

983 
heading3("Other text object methods") 
304  984 

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

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

986 

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

989 

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

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

991 

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

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

995 
""") 

996 

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

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

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

999 
# and similar""") 
298  1000 

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

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

1004 

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

1005 
heading2('Paths and Lines') 
298  1006 

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

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

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

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

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

1013 
not; and so forth.""") 

1014 

1015 
disc(""" 

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

1017 
to draw a star 

1018 
""") 

1019 

298  1020 
eg(examples.teststar) 
1021 

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

1024 
various line style parameters supported by $pdfgen$. 

1025 
""") 

1026 

298  1027 
canvasdemo(examples.star) 
1028 

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

1029 
heading3("Line join settings") 
304  1030 

1031 
disc(""" 

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

1033 
a square or a rounded vertex. 

1034 
""") 

1035 

298  1036 
eg(examples.testjoins) 
1037 

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

1040 
it cannot be seen clearly for thin lines. 

1041 
""") 

1042 

298  1043 
canvasdemo(examples.joins) 
1044 

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

1045 
heading3("Line cap settings") 
304  1046 

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

1048 
determines whether a terminating line 

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

1050 
or a half circle over the vertex. 

1051 
""") 

1052 

298  1053 
eg(examples.testcaps) 
1054 

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

1057 

298  1058 
canvasdemo(examples.caps) 
1059 

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

1060 
heading3("Dashes and broken lines") 
304  1061 

1062 
disc(""" 

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

1064 
""") 

1065 

298  1066 
eg(examples.testdashes) 
1067 

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

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

1071 
""") 

1072 

298  1073 
canvasdemo(examples.dashes) 
283  1074 

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

1075 
heading3("Creating complex figures with path objects") 
304  1076 

1077 
disc(""" 

1078 
Combinations of lines, curves, arcs and other figures 

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

1080 
For example the function shown below constructs two path 

1081 
objects using lines and curves. 

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

1083 
pencil icon construction. 

1084 
""") 

1085 

296  1086 
eg(examples.testpenciltip) 
1087 

304  1088 
disc(""" 
1089 
Note that the interior of the pencil tip is filled 

1090 
as one object even though it is constructed from 

1091 
several lines and curves. The pencil lead is then 

1092 
drawn over it using a new path object. 

1093 
""") 

1094 

296  1095 
canvasdemo(examples.penciltip) 
1096 

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

1097 
heading2('Rectangles, circles, ellipses') 
283  1098 

304  1099 
disc(""" 
1100 
The $pdfgen$ module supports a number of generally useful shapes 

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

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

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

1104 
draws a pencil icon using rectangles and rounded rectangles with 

1105 
various fill colors and a few other annotations. 

1106 
""") 

1107 

296  1108 
eg(examples.testpencil) 
1109 

304  1110 
pencilnote() 
1111 

1112 
disc(""" 

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

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

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

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

1117 
""") 

1118 

296  1119 
canvasdemo(examples.pencil) 
1120 

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

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

1122 

304  1123 
disc(""" 
1124 
Programs that wish to construct figures with curving borders 

1125 
generally use Bezier curves to form the borders. 

1126 
""") 

1127 

293  1128 
eg(examples.testbezier) 
1129 

304  1130 
disc(""" 
1131 
A Bezier curve is specified by four control points 

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

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

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

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

1136 
both form tangents to the curve. Furthermore the 

1137 
curve is entirely contained in the convex figure with vertices 

1138 
at the control points. 

1139 
""") 

1140 

293  1141 
canvasdemo(examples.bezier) 
1142 

304  1143 
disc(""" 
1144 
The drawing above (the output of $testbezier$) shows 

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

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

1147 
""") 

1148 

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

1149 
heading3("Smoothly joining bezier curve sequences") 
304  1150 

1151 
disc(""" 

1152 
It is often useful to join several bezier curves to form a 

1153 
single smooth curve. To construct a larger smooth curve from 

1154 
several bezier curves make sure that the tangent lines to adjacent 

1155 
bezier curves that join at a control point lie on the same line. 

1156 
""") 

1157 

293  1158 
eg(examples.testbezier2) 
1159 

304  1160 
disc(""" 
1161 
The figure created by $testbezier2$ describes a smooth 

1162 
complex curve because adjacent tangent lines "line up" as 

1163 
illustrated below. 

1164 
""") 

1165 

293  1166 
canvasdemo(examples.bezier2) 
1167 

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

1168 
heading2("Path object methods") 
298  1169 

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

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

1171 

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

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

1173 

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

1174 
eg("""pathobject.curveTo(x1, y1, x2, y2, x3, y3) """) 
909b83ce750c
textobject and pathobject methods, among other things
aaron_watters
parents:
298
diff
changeset

1175 

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

1176 
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

1177 

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

1178 
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

1179 

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

1180 
eg("""pathobject.rect(x, y, width, height) """) 
909b83ce750c
textobject and pathobject methods, among other things
aaron_watters
parents:
298
diff
changeset

1181 

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

1182 
eg("""pathobject.ellipse(x, y, width, height)""") 
909b83ce750c
textobject and pathobject methods, among other things
aaron_watters
parents:
298
diff
changeset

1183 

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

1184 
eg("""pathobject.circle(x_cen, y_cen, r) """) 
909b83ce750c
textobject and pathobject methods, among other things
aaron_watters
parents:
298
diff
changeset

1185 

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

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

1187 

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

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

1189 

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

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

1191 

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

1192 

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

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

1194 

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

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

1196 

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

1197 

298  1198 
##### FILL THEM IN 
1199 

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

1200 

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

1201 
heading1("Exposing PDF Special Capabilities") 
fce6dad947c3
Pushed down most existing lessons one level; added
andy_robinson
parents:
314
diff
changeset

1202 
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

1203 
document viewing more efficient and comfortable, and 
fce6dad947c3
Pushed down most existing lessons one level; added
andy_robinson
parents:
314
diff
changeset

1204 
our library exposes a number of these.""") 
fce6dad947c3
Pushed down most existing lessons one level; added
andy_robinson
parents:
314
diff
changeset

1205 

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

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

1207 
heading2("Links and Destinations") 
fce6dad947c3
Pushed down most existing lessons one level; added
andy_robinson
parents:
314
diff
changeset

1208 
heading2("Outline Trees") 
fce6dad947c3
Pushed down most existing lessons one level; added
andy_robinson
parents:
314
diff
changeset

1209 
heading2("Page Transition Effects") 
fce6dad947c3
Pushed down most existing lessons one level; added
andy_robinson
parents:
314
diff
changeset

1210 

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 

296  1213 

1214 
#####################################################################################################3 

1215 

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

1216 
heading1("PLATYPUS  Page Layout and Typography Using Scripts") 
fce6dad947c3
Pushed down most existing lessons one level; added
andy_robinson
parents:
314
diff
changeset

1217 
heading2("Design Goals") 
fce6dad947c3
Pushed down most existing lessons one level; added
andy_robinson
parents:
314
diff
changeset

1218 
heading2("Frames and Flowables") 
fce6dad947c3
Pushed down most existing lessons one level; added
andy_robinson
parents:
314
diff
changeset

1219 
heading2("Paragraphs in detail") 
fce6dad947c3
Pushed down most existing lessons one level; added
andy_robinson
parents:
314
diff
changeset

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

1221 
heading2("Custom Flowable Objects") 
fce6dad947c3
Pushed down most existing lessons one level; added
andy_robinson
parents:
314
diff
changeset

1222 
heading3("A very simple Flowable") 