1
from reportlab.lib import styles
2
from reportlab.lib import colors
3
from reportlab.lib.units import cm
4
from reportlab.lib.enums import TA_LEFT, TA_CENTER, TA_RIGHT, TA_JUSTIFY
5
from reportlab.platypus import Preformatted, Paragraph, Frame, \
6
Image, Table, TableStyle, Spacer
9
def getParagraphStyles():
10
"""Returns a dictionary of styles to get you started.
12
We will provide a way to specify a module of these. Note that
13
this just includes TableStyles as well as ParagraphStyles for any
14
tables you wish to use.
18
ParagraphStyle = styles.ParagraphStyle
20
para = ParagraphStyle('Normal', None) #the ancestor of all
21
para.fontName = 'Times-Roman'
24
stylesheet['Normal'] = para
26
#This one is spaced out a bit...
27
para = ParagraphStyle('BodyText', stylesheet['Normal'])
29
stylesheet['BodyText'] = para
32
para = ParagraphStyle('Indent', stylesheet['Normal'])
34
para.firstLineIndent = 0
35
stylesheet['Indent'] = para
37
para = ParagraphStyle('Centered', stylesheet['Normal'])
38
para.alignment = TA_CENTER
39
stylesheet['Centered'] = para
41
para = ParagraphStyle('BigCentered', stylesheet['Normal'])
43
para.alignment = TA_CENTER
44
stylesheet['BigCentered'] = para
46
para = ParagraphStyle('Italic', stylesheet['BodyText'])
47
para.fontName = 'Times-Italic'
48
stylesheet['Italic'] = para
50
para = ParagraphStyle('Title', stylesheet['Normal'])
51
para.fontName = 'Times-Roman'
54
para.alignment = TA_CENTER
55
stylesheet['Title'] = para
57
para = ParagraphStyle('Heading1', stylesheet['Normal'])
58
para.fontName = 'Times-Bold'
61
para.alignment = TA_CENTER
62
stylesheet['Heading1'] = para
64
para = ParagraphStyle('Heading2', stylesheet['Normal'])
65
para.fontName = 'Times-Bold'
69
stylesheet['Heading2'] = para
71
para = ParagraphStyle('Heading3', stylesheet['Normal'])
72
para.fontName = 'Times-BoldItalic'
74
stylesheet['Heading3'] = para
76
para = ParagraphStyle('Heading4', stylesheet['Normal'])
77
para.fontName = 'Times-BoldItalic'
79
stylesheet['Heading4'] = para
81
para = ParagraphStyle('Bullet', stylesheet['Normal'])
82
para.firstLineIndent = 0
85
para.bulletFontName = 'Symbol'
86
para.bulletFontSize = 24
87
para.bulletIndent = 20
88
stylesheet['Bullet'] = para
90
para = ParagraphStyle('Definition', stylesheet['Normal'])
91
#use this for definition lists
92
para.firstLineIndent = 0
96
para.bulletFontName = 'Helvetica-BoldOblique'
97
para.bulletFontSize = 24
98
stylesheet['Definition'] = para
100
para = ParagraphStyle('Code', stylesheet['Normal'])
101
para.fontName = 'Courier'
105
stylesheet['Code'] = para
107
para = ParagraphStyle('PythonCode', stylesheet['Normal'])
108
para.fontName = 'Courier'
112
stylesheet['PythonCode'] = para
114
para = ParagraphStyle('Small', stylesheet['Normal'])
117
stylesheet['Small'] = para
121
('FONT', (0,0), (-1,-1), 'Times-Roman', 24),
122
('LINEABOVE', (0,0), (-1,0), 2, colors.green),
123
('LINEABOVE', (0,1), (-1,-1), 0.25, colors.black),
124
('LINEBELOW', (0,-1), (-1,-1), 2, colors.green),
125
('LINEBEFORE', (-1,0), (-1,-1), 2, colors.black),
126
('ALIGN', (1,1), (-1,-1), 'RIGHT'), #all numeric cells right aligned
127
('TEXTCOLOR', (0,1), (0,-1), colors.red),
128
('BACKGROUND', (0,0), (-1,0), colors.Color(0,0.7,0.7))
130
stylesheet['table1'] = ts