from fpdf import FPDF# Author: @NavonilDaspdf = FPDF()# Set Author Name of the PDFpdf.set_author('@NavonilDas')# Set Subject of The PDFpdf.set_subject('python')# Set the Title of the PDFpdf.set_title('Generating PDF with Python')pdf.add_page()# Set Font family Courier with font size 28pdf.set_font("Courier", '', 18)# Add Text at (0,50)pdf.text(0, 50, "Example to generate PDF in python.")# Set Font Family Courier with italic and font size 28pdf.set_font("Courier", 'i', 28)pdf.text(0, 60, "This is an italic text") # Write text at 0,60# Draw a Rectangle at (10,100) with Width 60,30pdf.rect(10, 100, 60, 30, 'D')# Set Fill colorpdf.set_fill_color(255, 0, 0) # Red = (255,0,0)# Draw a Circle at (10,135) with diameter 50pdf.ellipse(10, 135, 50, 50, 'F')# Save the Output at Local Filepdf.output('output.pdf', 'F')
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。