Last active
July 2, 2023 12:50
-
-
Save MartinThoma/aefa6add94a524dcb871d3c5b211d29c to your computer and use it in GitHub Desktop.
Comment about https://stackoverflow.com/questions/76596133/filling-pdf-with-pypdf-values-not-shwoing-corectly
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from pypdf import PdfReader, PdfWriter | |
import pypdf | |
import sys | |
print(f"Python {sys.version} using pypdf=={pypdf.__version__}") | |
reader = PdfReader("Antrag.pdf") # https://www.docdroid.net/HvUlMpM/antrag-pdf | |
# Get the field names | |
# fields = reader.get_fields() | |
# print(fields) | |
# Write field data | |
data = {"lname": "Özcan", "fname": "Gülcan"} | |
writer = PdfWriter() | |
writer.append(reader) | |
writer.update_page_form_field_values(writer.pages[0], data) | |
writer.update_page_form_field_values(writer.pages[1], data) | |
with open("Antrag_output.pdf", "wb") as output_stream: | |
writer.write(output_stream) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment