使用拉绳的ReportLab包装

时间:2019-04-12 13:43:00

标签: python-3.x

我有一个Python脚本,该脚本读取一个csv文件并将此数据写入PDF文件,该列txt_objetives的字符串很长,需要包装,是否有一种方法可以允许将文本发送到reportlab中的drawstring进行包装如果以下脚本中的内容太长?

# import statements
from reportlab.lib.pagesizes import letter
from reportlab.pdfgen import canvas
from reportlab.lib.pagesizes import portrait
import csv

def import_Data(data_file):
   smsInfo = csv.reader(open(data_file, "r"))
   for row in smsInfo:
      employee_id = row[0]
      employee_name = row[1]
      txt_objective = row[2]
      pdf_filename = 'SMS Data Report.pdf'
      generate_report(employee_id, employee_name, txt_objective)

def generate_report(employee_id, employee_name, txt_objective):
c = canvas.Canvas(pdf_filename, pagesize=portrait(letter))


import_Data(data_file)
canvas.save()

0 个答案:

没有答案