-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Labels
help wantedWe appreciate help everywhere - this one might be an easy start!We appreciate help everywhere - this one might be an easy start!is-bugFrom a users perspective, this is a bug - a violation of the expected behavior with a compliant PDFFrom a users perspective, this is a bug - a violation of the expected behavior with a compliant PDFworkflow-formsFrom a users perspective, forms is the affected feature/workflowFrom a users perspective, forms is the affected feature/workflow
Description
I'd like to use PyPDF2 to fill out a pdf form. So far, everything is going smoothly, including updating the field text. But when I write the pdf to a file, there is apparently no change in the form. Running this code:
import datetime as dt
from PyPDF2 import PdfFileReader, PdfFileWriter
import re
form701 = PdfFileReader('ABC701LG.pdf')
page = form701.getPage(0)
filled = PdfFileWriter()
#removing extraneous fields
r = re.compile('^[0-9]')
fields = sorted(list(filter(r.match, form701.getFields().keys())), key = lambda x: int(x[0:2]))
filled.addPage(page)
filled.updatePageFormFieldValues(filled.getPage(0),
{fields[0]: 'some filled in text'})
print(filled.getPage(0)['/Annots'][0].getObject()['/T'])
print(filled.getPage(0)['/Annots'][0].getObject()['/V'])
with open('test.pdf','wb') as fp:
filled.write(fp)prints text:
1 EFFECTIVE DATE OF THIS SCHEDULE <i.e. the field name>
some filled in text
But when I open up test.pdf, there is no added text on the page! Help!
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
help wantedWe appreciate help everywhere - this one might be an easy start!We appreciate help everywhere - this one might be an easy start!is-bugFrom a users perspective, this is a bug - a violation of the expected behavior with a compliant PDFFrom a users perspective, this is a bug - a violation of the expected behavior with a compliant PDFworkflow-formsFrom a users perspective, forms is the affected feature/workflowFrom a users perspective, forms is the affected feature/workflow