Python 官方文档:入门教程 => 点击学习
1.安装reportlab库 Http://www.reportlab.com/ftp/ ubuntu可以直接 apt-get install python-reportlab 2.实验 >>> from report
1.安装reportlab库
Http://www.reportlab.com/ftp/
ubuntu可以直接 apt-get install python-reportlab
2.实验
综合案例
- >>> import datetime,subprocess
- >>> from reportlab.pdfgen import canvas
- >>> from reportlab.lib.units import inch
- >>>
- >>> def dir_report():
- p = subprocess.Popen("dir",shell=True,stdout=subprocess.PIPE)
- return p.stdout.readlines()
-
- >>> def create_pdf(input,output="dir_report.pdf"):
- now = datetime.datetime.today()
- date = now.strftime("%h %d %Y %H:%M:%S")
- c = canvas.Canvas(output)
- textobj = c.beginText()
- textobj.setTextOrigin(inch,11*inch)
- textobj.textLines('''''
- This history sub dir and file is
- time is %s''' % date)
- for line in input:
- textobj.textLine(line.strip())
- c.drawText(textobj)
- c.showPage()
- c.save()
-
-
- >>> report = dir_report()
- >>> create_pdf()
--结束END--
本文标题: python 创建PDF文件
本文链接: https://lsjlt.com/news/188746.html(转载时请注明来源链接)
有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341
2024-03-01
2024-03-01
2024-03-01
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
回答
回答
回答
回答
回答
回答
回答
回答
回答
回答
0