代码拉取完成,页面将自动刷新
from fpdf import FPDF
# Author: @NavonilDas
pdf = FPDF()
# Set Author Name of the PDF
pdf.set_author('@NavonilDas')
# Set Subject of The PDF
pdf.set_subject('python')
# Set the Title of the PDF
pdf.set_title('Generating PDF with Python')
pdf.add_page()
# Set Font family Courier with font size 28
pdf.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 28
pdf.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,30
pdf.rect(10, 100, 60, 30, 'D')
# Set Fill color
pdf.set_fill_color(255, 0, 0) # Red = (255,0,0)
# Draw a Circle at (10,135) with diameter 50
pdf.ellipse(10, 135, 50, 50, 'F')
# Save the Output at Local File
pdf.output('output.pdf', 'F')
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。