-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSOW_pdf.py
143 lines (119 loc) · 5.38 KB
/
SOW_pdf.py
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
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 SOWForm:
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('Scope Of Work', 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, 150*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, 150*mm, width=65*mm, height=85*mm,
showBoundary=0)
frmRgt.addFromList(inpt, basepg)
# second textarea box
dscrp = []
dscrp.append(Paragraph('Work Description:', hd2))
dscrp.append(Paragraph(self.ta['ta_2'], nrm))
frm1 = Frame(15*mm, 100*mm, width=180*mm, height=65*mm, showBoundary=1)
frm1.addFromList(dscrp, basepg)
# 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, 80*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>Minimum Design Temperature (F):</i></b>',
style=styles['Right']))
dscrp.append(Spacer(1, 5))
dscrp.append(Paragraph('<b><i>Maximum Design Temperature (F):</i></b>',
style=styles['Right']))
frmLft = Frame(15*mm, 40*mm, width=75*mm, height=45*mm,
showBoundary=0)
frmLft.addFromList(dscrp, basepg)
# input text boxes for operating conditions
inpt = []
for n in range(8, 12):
indx = 't_' + str(n)
inpt.append(Paragraph(self.t[indx], style=styles['Left']))
inpt.append(Spacer(1, 7))
frmRgt = Frame(95*mm, 40*mm, width=65*mm, height=45*mm,
showBoundary=0)
frmRgt.addFromList(inpt, basepg)
basepg.showPage()
# final textarea box
dscrp = []
dscrp.append(Paragraph('Attachments:', hd2))
dscrp.append(Paragraph(self.ta['ta_3'], nrm))
frm1 = Frame(15*mm, 200*mm, width=180*mm, height=65*mm, showBoundary=1)
frm1.addFromList(dscrp, basepg)
basepg.save()