def __init__(self, text=[], target='your website', pdfName='Report.pdf'):
self.__target = target
self.__pdfName = self.__path + pdfName
self.__text = text
if not os.path.exists('result/'):
os.mkdir(r'result/')
time = datetime.datetime.today()
date = time.strftime("%h-%d-%Y %H:%M:%S")
c = canvas.Canvas(self.__pdfName)
c.setPageSize((16 * inch,22 * inch))
textobj = c.beginText()
textobj.setTextOrigin(inch, 20 * inch)
textobj.textLines('''
This is the scanning report of %s.
''' %self.__target)
textobj.textLines('''
Date: %s
''' % date)
for line in self.__text:
textobj.textLine(line.strip())
c.drawText(textobj)
c.showPage()
c.save()
评论列表
文章目录