MCPcopy
hub / github.com/eldraco/domain_analyzer / convert

Method convert

pyText2pdf.py:265–305  ·  view source on GitHub ↗

Perform the actual conversion

(self)

Source from the content-addressed store, hash-verified

263 return 0
264
265 def convert(self):
266 """ Perform the actual conversion """
267
268 if self._landscape:
269 # swap page width & height
270 tmp = self._pageHt
271 self._pageHt = self._pageWd
272 self._pageWd = tmp
273
274 if self._lines==0:
275 self._lines = (self._pageHt - 72)/self._vertSpace
276 if self._lines < 1:
277 self._lines=1
278
279 try:
280 self._ifs=open(self._ifile)
281 except IOError as xxx_todo_changeme:
282 (strerror, errno) = xxx_todo_changeme.args
283 print('Error: Could not open file to read --->', self._ifile)
284 sys.exit(3)
285
286 if self._ofile=="":
287 self._ofile = os.path.splitext(self._ifile)[0] + '.pdf'
288
289 try:
290 self._ofs = open(self._ofile, 'wb')
291 except IOError as xxx_todo_changeme1:
292 (strerror, errno) = xxx_todo_changeme1.args
293 print('Error: Could not open file to write --->', self._ofile)
294 sys.exit(3)
295
296 print('Input file=>',self._ifile)
297 print('Writing pdf file',self._ofile, '...')
298 self.writeheader()
299 self.writepages()
300 self.writerest()
301
302 print('Wrote file', self._ofile)
303 self._ifs.close()
304 self._ofs.close()
305 return 0
306
307 def writeheader(self):
308 """Write the PDF header"""

Callers 1

mainFunction · 0.95

Calls 4

writeheaderMethod · 0.95
writepagesMethod · 0.95
writerestMethod · 0.95
closeMethod · 0.45

Tested by

no test coverage detected