-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathHTR_pdf.py
More file actions
248 lines (216 loc) · 9.58 KB
/
Copy pathHTR_pdf.py
File metadata and controls
248 lines (216 loc) · 9.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
from reportlab.lib.pagesizes import letter
from reportlab.pdfgen.canvas import Canvas
from reportlab.lib.styles import getSampleStyleSheet, ParagraphStyle
from reportlab.lib.units import mm
from reportlab.platypus import Flowable, Paragraph, Frame, Spacer
from reportlab.lib.enums import TA_LEFT, TA_RIGHT
class LineDrw(Flowable):
def __init__(self, width, height=0):
Flowable.__init__(self)
self.width = width
self.height = height
def __repr__(self):
return "Line(w=%s)" % self.width
def draw(self):
self.canv.line(0, self.height, self.width, self.height)
class HTRForm:
def __init__(self, pdf_file, t_data, ta_data, chk_data=None):
self.t = t_data
self.ta = ta_data
self.chk = chk_data
self.pdf_file = pdf_file
def create(self):
styles = getSampleStyleSheet()
aW, aH = letter
nrm = styles['Normal']
hd1 = styles['Heading1']
hd2 = styles['Heading2']
styles.add(ParagraphStyle(name='Right', fontSize=12, spaceAfter=15,
alignment=TA_RIGHT))
styles.add(ParagraphStyle(name='Left', fontSize=12, spaceAfter=15,
borderColor='black', borderRadius=3,
borderPadding=5, borderWidth=1,
alignment=TA_LEFT))
basepg = Canvas(self.pdf_file)
# Form title
ttl = []
ttl.append(Paragraph('Hydro Test Report', hd1))
ttl.append(LineDrw(500))
frm = Frame(15*mm, 260*mm, width=150*mm, height=25*mm, showBoundary=0)
frm.addFromList(ttl, basepg)
# First text area box
dscrp = []
dscrp.append(Paragraph('Project Description', hd2))
dscrp.append(Paragraph(self.ta['ta_1'], nrm))
frm1 = Frame(15*mm, 240*mm, width=180*mm, height=25*mm, showBoundary=1)
frm1.addFromList(dscrp, basepg)
# Section of labels for input text
info = []
info.append(Paragraph('<b><i>Work Order:</i></b>',
style=styles['Right']))
info.append(Paragraph('<b><i>Project Engineer:</i></b>',
style=styles['Right']))
info.append(Paragraph('<b><i>Contact Information:</i></b>',
style=styles['Right']))
info.append(Paragraph('<b><i>Fabricator:</i></b>',
style=styles['Right']))
info.append(Paragraph('<b><i>Date Of Issue:</i></b>',
style=styles['Right']))
info.append(Paragraph('<b><i>Pipe Specification Code:</i></b>',
style=styles['Right']))
info.append(Paragraph('<b><i>P&ID Line Number:</i></b>',
style=styles['Right']))
frmLft = Frame(15*mm, 140*mm, width=65*mm, height=85*mm,
showBoundary=0)
frmLft.addFromList(info, basepg)
# list of first section of input text boxes
inpt = []
for n in range(1, 8):
indx = 't_' + str(n)
inpt.append(Paragraph(self.t[indx], style=styles['Left']))
frmRgt = Frame(80*mm, 140*mm, width=65*mm, height=85*mm,
showBoundary=0)
frmRgt.addFromList(inpt, basepg)
# second textarea box
dscrp = []
dscrp.append(Paragraph('Related Drawings and Documents:', hd2))
dscrp.append(Paragraph(self.ta['ta_2'], nrm))
frm1 = Frame(15*mm, 80*mm, width=180*mm, height=65*mm, showBoundary=1)
frm1.addFromList(dscrp, basepg)
basepg.showPage()
# title for beginning of operating conditions
dscrp = []
dscrp.append(LineDrw(500))
dscrp.append(Paragraph('Operating Conditions', hd2))
dscrp.append(Spacer(1, 13))
frm2 = Frame(15*mm, 260*mm, width=180*mm, height=15*mm, showBoundary=0)
frm2.addFromList(dscrp, basepg)
# text box labels for operating conditions
dscrp = []
dscrp.append(Paragraph('<b><i>Design Pressure (psig):</i></b>',
style=styles['Right']))
dscrp.append(Spacer(1, 5))
dscrp.append(Paragraph('<b><i>Hydro Test Pressure (psig):</i></b>',
style=styles['Right']))
dscrp.append(Spacer(1, 5))
dscrp.append(Paragraph('<b><i>Hydro Test Temperature (F):</i></b>',
style=styles['Right']))
dscrp.append(Spacer(1, 7))
dscrp.append(Paragraph('<b><i>Hydro Test Media:</i></b>',
style=styles['Right']))
dscrp.append(Spacer(1, 6))
dscrp.append(Paragraph('<b><i>Test Start Time (hr:min):</i></b>',
style=styles['Right']))
dscrp.append(Spacer(1, 6))
dscrp.append(Paragraph('<b><i>Test Sign Off Time (hr:min):</i></b>',
style=styles['Right']))
dscrp.append(Spacer(1, 6))
dscrp.append(Paragraph('<b><i>Test Duration (min):</i></b>',
style=styles['Right']))
frmLft = Frame(15*mm, 180*mm, width=75*mm, height=85*mm,
showBoundary=0)
frmLft.addFromList(dscrp, basepg)
# input text boxes for hydro test conditions
inpt = []
for n in range(8, 15):
indx = 't_' + str(n)
inpt.append(Paragraph(self.t[indx], style=styles['Left']))
inpt.append(Spacer(1, 7))
frmRgt = Frame(95*mm, 180*mm, width=65*mm, height=85*mm,
showBoundary=0)
frmRgt.addFromList(inpt, basepg)
# title for beginning of operating conditions
dscrp = []
dscrp.append(LineDrw(500))
dscrp.append(Paragraph('Testing Gauges Record', hd2))
dscrp.append(Spacer(1, 13))
frm2 = Frame(15*mm, 165*mm, width=180*mm, height=15*mm, showBoundary=0)
frm2.addFromList(dscrp, basepg)
# text box labels for gage info
info = []
info.append(Paragraph('<b><i>Gauge 1 ID:</i></b>',
style=styles['Right']))
info.append(Spacer(1, 8))
info.append(Paragraph('<b><i>Range:</i></b>',
style=styles['Right']))
info.append(Spacer(1, 8))
info.append(Paragraph('<b><i>Gauge 2 ID:</i></b>',
style=styles['Right']))
info.append(Spacer(1, 8))
info.append(Paragraph('<b><i>Range:</i></b>',
style=styles['Right']))
frmLft1 = Frame(10*mm, 110*mm, width=35*mm, height=55*mm,
showBoundary=0)
frmLft1.addFromList(info, basepg)
# input text data for gage info
inpt = []
for n in range(15, 19):
indx = 't_' + str(n)
inpt.append(Paragraph(self.t[indx], style=styles['Left']))
inpt.append(Spacer(1, 8))
frmLft2 = Frame(50*mm, 110*mm, width=45*mm, height=55*mm,
showBoundary=0)
frmLft2.addFromList(inpt, basepg)
# text box labels for gage info
info = []
info.append(Paragraph('<b><i>Calibration Date:</i></b>',
style=styles['Right']))
info.append(Spacer(1, 28))
info.append(Paragraph('<b><i>Calibration Date:</i></b>',
style=styles['Right']))
frmRgt1 = Frame(100*mm, 117*mm, width=35*mm, height=50*mm,
showBoundary=0)
frmRgt1.addFromList(info, basepg)
# text box input data for gage info
inpt = []
for n in range(19, 21):
indx = 't_' + str(n)
inpt.append(Paragraph(self.t[indx], style=styles['Left']))
inpt.append(Spacer(1, 40))
frmRgt2 = Frame(140*mm, 115*mm, width=35*mm, height=50*mm,
showBoundary=0)
frmRgt2.addFromList(inpt, basepg)
# second textarea box
dscrp = []
dscrp.append(Paragraph('Comments:', hd2))
dscrp.append(Paragraph(self.ta['ta_3'], nrm))
frm1 = Frame(15*mm, 60*mm, width=180*mm, height=45*mm, showBoundary=1)
frm1.addFromList(dscrp, basepg)
# sign off text boxes
info = []
info.append(Paragraph('<b><i>Owner Inspector:</i></b>',
style=styles['Right']))
info.append(Spacer(1, 13))
info.append(Paragraph('<b><i>QC Inspector:</i></b>',
style=styles['Right']))
frmLft1 = Frame(10*mm, 20*mm, width=45*mm, height=30*mm,
showBoundary=0)
frmLft1.addFromList(info, basepg)
# input text data
inpt = []
for n in range(21, 23):
indx = 't_' + str(n)
inpt.append(Paragraph(self.t[indx], style=styles['Left']))
inpt.append(Spacer(1, 13))
frmLft2 = Frame(60*mm, 20*mm, width=45*mm, height=30*mm,
showBoundary=0)
frmLft2.addFromList(inpt, basepg)
# text box labels
info = []
for n in range(2):
info.append(Paragraph('<b><i>Date:</i></b>',
style=styles['Right']))
info.append(Spacer(1, 13))
frmRgt1 = Frame(120*mm, 20*mm, width=25*mm, height=30*mm,
showBoundary=0)
frmRgt1.addFromList(info, basepg)
# text box input data
inpt = []
for n in range(23, 25):
indx = 't_' + str(n)
inpt.append(Paragraph(self.t[indx], style=styles['Left']))
inpt.append(Spacer(1, 13))
frmRgt2 = Frame(150*mm, 20*mm, width=25*mm, height=30*mm,
showBoundary=0)
frmRgt2.addFromList(inpt, basepg)
basepg.save()