我正在尝试从python生成一个pdf文档。我希望它只在输出文件中打印一次,但它打印了四次

时间:2016-03-15 11:55:19

标签: python django pdf report

  1. 此脚本尝试生成pdf文件。
  2. 它使用python的pollyreport库。

    from PollyReports import *
    from reportlab.pdfgen.canvas import Canvas
        output = []
        with open('textfile.txt','r') as f:
            for line in f:
                if 'india' in line:
                    output.append(line)
    print output
    rpt = Report(datasource = output, detailband = Band
                ([
                    Element((10,10), ("Helvetica", 12), text=output[0]),
                ]))        
    
    canvas = Canvas("lprep01.pdf")
    rpt.generate(canvas)
    canvas.save()
    

0 个答案:

没有答案