-
Notifications
You must be signed in to change notification settings - Fork 22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
PPF: Repeated field names in PDF form #733
Comments
Hey thanks for posting. If you want to fill distinct data in each row, you will have to modify the name of these fields using a PDF form editor (e.g., Adobe Acrobat). Once done you can do something like this: data = {}
for i, description in enumerate(your_data):
data[f"Description[{i}]"] = description
PdfWrapper("Cost_Basis_Update_TEST.pdf").fill(data) |
Also in v1.4.36 that just got released, I implemented the functionality that lets you modify the key of a widget. So you could do something like this: for i in range(1, 10):
pdf.update_widget_key("Description[0]", f"Description[{i}]", 1)
pdf.update_widget_key("symbol[0]", f"symbol[{i}]", 1)
pdf.update_widget_key("tradedate[0]", f"tradedate[{i}]", 1)
pdf.update_widget_key("settlementdate[0]", f"settlementdate[{i}]", 1)
pdf.update_widget_key("quantity[0]", f"quantity[{i}]", 1)
pdf.update_widget_key("costperunit[0]", f"costperunit[{i}]", 1)
pdf.update_widget_key("costabasis[0]", f"costabasis[{i}]", 1) This would update the keys of each row so that you could fill distinct data. Note that currently the performance of the above is a bit of an issue. But I'm about to go on vacation so I will have to get back to it later. In the meantime I suggest you run the above as a one time thing and save the PDF as a new template. |
Great, I appreciate the help. I'll try this out |
Version
PyPDFForm=4.3.1
Issue Description
Hello, I'm trying to fill the attached PDF. I've included the input PDF and the output using the preview stream. I am trying to fill in the fields in the table, but having difficulty as it looks like they are all named the same.
Is there a way to fill this PDF with values in the table coming from a Pandas data frame (I can loop and map the attributes, but not sure how to do the filling)?
Thanks!
Code Snippet
PDF Form Template
Cost_Basis_Update_TEST.pdf
output.pdf
Screenshots (if applicable)
The text was updated successfully, but these errors were encountered: