我想用Python创建一个可填写输入的表单,格式如下(见附件)
我尝试了几个不同的 pdf 库,但没有一个能够生成这样的输入。有人猜测哪个图书馆是用来生成这些表格的吗?我可以用 python 来做吗?
我在 blob 库上看了很多,还看了 aspose.pdf lib,但它根本不起作用
有一些 python 库可以做到这一点,这是我使用过的一个:
from reportlab.pdfgen import canvas
from reportlab.pdfbase import pdfform
def create_fillable_form():
c = canvas.Canvas("fillable_form.pdf")
form = c.acroForm
# Create a text field
c.drawString(100, 700, "Name:")
form.textfield(name='name', tooltip='Enter your name', x=150, y=690, width=200)
# Create a checkbox
c.drawString(100, 650, "Agree to terms:")
form.checkbox(name='agree', tooltip='Check to agree', x=180, y=640)
c.save()
create_fillable_form()
还有一些方法可以将 HTML 页面转换为 PDF(如果更简单的话)