I'm developing a Python script that reads a specific cell from an Excel file, say B6, and transcribes it to a text box on a PDF form, let's say the text box is called Formulary unite_3.
Python correctly reads the text inside the Excel cell, even prints it, and transfers it to the form, but when I open the pdf file it is not visible until I click on the file.
I already tried to fix the problems, I even made a mini script that allows you to see the properties of the text box to see the behavior, and what I deduce is that what you put in the form you put layers behind. I attach my analysis below:
With this, the text doesn't appear (done indirectly with Python):
{'/AP': {'/N': IndirectObject(113, 0)}, '/DA': '/Helv 0 Tf 0 g', '/DR': {'/Encoding': {'/PDFDocEncoding': IndirectObject(110, 0)}, '/Font': {'/Helv': IndirectObject(111, 0)}}, '/F': 4, '/FT': '/Tx', '/P': IndirectObject(106, 0), '/Rect': [120.84, 600.24, 293.28, 617.16], '/Subtype': '/Widget', '/T': 'Formulary unite_3', '/TU': 'First Name', '/Type': '/Annot', '/V': 'Hola Mundo'}
With this, the text appears (done directly with Adobe Acrobat Reader):
#{'/AP': {'/N': IndirectObject(48, 0)}, '/DA': '/Helv 0 Tf 0 g', '/DR': {'/Encoding': {'/PDFDocEncoding': IndirectObject(772, 0)}, '/Font': {'/Helv': IndirectObject(773, 0)}}, '/F': 4, '/FT': '/Tx', '/P': IndirectObject(1, 0), '/Rect': [120.84, 600.24, 293.28, 617.16], '/Subtype': '/Widget', '/T': 'Formulary unite_3', '/TU': 'First Name', '/Type': '/Annot', '/V': 'Hola Mundo'}
I have tried many libraries but nothing has changed. I am currently using PyPDF2 which has given me better results. I leave you my script and if someone could help me please, I am very desperate for this.
I purposely left out the Excel part because I could already get that to work, and replaced it with Hola Mundo for practicality purposes.



These questions asking why PDF software is having problems with "Forms" come up from time to time and the common reason is they are non conventional forms that should never have been given the file extension .PDF as they are XFA.XMP in a PDF wrapper.
Their behaviour depends on their design intent and should only be used in any program as they were intended. Usually are restricted by time (i.e. Expires 07/31/2024)
In this case as with many others this version is not designed for programming but anyone can attempt contravening the legal requirements. The form is legally to be entered by a responsible human having permitted the inbuilt JavaScript to run that adapts the contents as needed.
Thus you are warned it cannot work acceptably outside Adobe products