I am filling in editable fields in a PDF file using Python (PyPDF library) and saving the file with the code below. However, when I open the PDF, the filled fields do not appear. If I open the saved file in Google Drive, I can see that the fields remain editable and the information was inserted. However, when opening it in Adobe Acrobat, the data is not displayed.
reader = PdfReader(rdp_modelo)
writer = PdfWriter()
for page in reader.pages:
writer.add_page(page)
writer.update_page_form_field_values(writer.pages[0], dados_RDP)
writer._flatten()
output_pdf_path = "rdp_preenchido.pdf"
with open(output_pdf_path, "wb") as output_pdf:
writer.write(output_pdf)