def process_attachment_file(self, input_path, output_path, target=None):
output_path, _ = os.path.splitext(output_path)
output_path += '.pdf'
pdf_file = platypus.SimpleDocTemplate(
output_path,
pagesize=letter,
rightMargin=72,
leftMargin=72,
topMargin=72,
bottomMargin=18
)
url = self.application.config['mailer.webserver_url']
if target is not None:
url += '?uid=' + target.uid
try:
pdf_template = self.get_template(input_path, url)
pdf_file.multiBuild(pdf_template)
except Exception as err:
self.logger.error('failed to build the pdf document', exc_info=True)
return
self.logger.info('wrote pdf file to: ' + output_path + ('' if target is None else ' with uid: ' + target.uid))
return output_path
评论列表
文章目录