# -*- coding: utf8 -*- #~ #---------------------------------------------------------------------- import wlab #pip install wlab import reportlab.pdfbase.ttfonts #reportlab.pdfbase.pdfmetrics.registerFont(reportlab.pdfbase.ttfonts.TTFont('song', '/usr/share/fonts/cn/msjh.ttf')) #import reportlab.lib.fonts # from reportlab.pdfgen import canvas from reportlab.lib.units import inch # def file2pdf(FileName): fpi=FileName.find('.') if (fpi>0): outputfn=FileName[0:fpi]+'.pdf' else: outputfn=FileName+'.pdf' c = canvas.Canvas(outputfn) #c.setFont('song',10) textobject = c.beginText() textobject.setTextOrigin(inch,11*inch) file=open(FileName) n=0 for line in file: n=n+1 if(n
希望本文所述对大家的Python程序设计有所帮助。
查看更多关于Python使用reportlab将目录下所有的文本文件打印成pdf的方法的详细内容...
声明:本文来自网络,不代表【好得很程序员自学网】立场,转载请注明出处:http://www.haodehen.cn/did91327