Skip to content Skip to sidebar Skip to footer

Create A Pdf With Fillable Fields Python

So I have been tasked with creating a pdf that allows the end user to enter information into the pdf and print it or save it, either or. The pdf I am trying to create is being rend

Solution 1:

Facing the same problem. Just found out, the forms in the output.pdf are not fillable in okular or firefox, but still able to fill when opened in google-chrome or chromium-browser.

I used this lines:

from PyPDF2 import PdfFileWriter, PdfFileReader
from reportlab.pdfgen import canvas

c = canvas.Canvas('watermark.pdf')
c.drawImage('testplot.png', 350, 550, width=150, height=150)  
c.save()

output_file = PdfFileWriter()
watermark = PdfFileReader(open("watermark.pdf", 'rb'))
input_file = PdfFileReader(file('template.pdf', 'rb'))

page_count = input_file.getNumPages()
for page_number in range(page_count):
    print "Plotting png to {} of {}".format(page_number, page_count)
    input_page = input_file.getPage(page_number)
    input_page.mergePage(watermark.getPage(0))
    output_file.addPage(input_page)

with open('output.pdf', 'wb') as outputStream:
    output_file.write(outputStream)

Post a Comment for "Create A Pdf With Fillable Fields Python"