I am following the instructions in this article for writing information to annotations in a PDF document.
The script in the aforementioned article does work. However, after the script is executed and the output file is opened, the fields remain invisible. When clicking on a annotation, the text added from the script appears. But subsequently when clicking elsewhere in the document, the text from the script disappears.
Is there some sort of flag that needs to be triggered, to inform the PDF reader that the fields have been filled?
EDIT:
The script given in the article is probably not really correct.
When reading the first annotation of the unedited PDF, I get the following:
{'/T': '(business_name_1)', '/AA': {'/F': (113, 0)}, '/MK': {}, '/F': '4', '/Rect': ['77.433', '639.425', '538.174', '663.305'], '/Type': '/Annot', '/FT': '/Tx', '/AP': {'/N': (12, 0)}, '/DA': '(/Helv 0 Tf 1 1 1 rg)', '/Subtype': '/Widget', '/TU': '([Business Name])', '/Q': '1', '/P': (11, 0)}
When manually filling in a field with a PDF reader and saving it, and subsequently read that PDF file, the '/V':
attribute is added to the previous code, i.e. the the first annotation is the following code:
{'/V': '(Bostata)', '/T': '(business_name_1)', '/AA': {'/F': (113, 0)}, '/MK': {}, '/F': '4', '/Rect': ['77.433', '639.425', '538.174', '663.305'], '/Type': '/Annot', '/FT': '/Tx', '/AP': {'/N': (12, 0)}, '/DA': '(/Helv 0 Tf 1 1 1 rg)', '/Subtype': '/Widget', '/TU': '([Business Name])', '/Q': '1', '/P': (11, 0)}
However, after the script has added the value to the annotation, a whole buch of data is added as well (10k+ charachters, so I'm not gonna paste it here).
Can someone plese spot the error of the script given in this article
EDIT2:
Here I found a partial answer.
Altering the code to:
annotation.update( pdfrw.PdfDict(AP=data_dict[key], V=data_dict[key]) )
When I open the pdf with Adobe reader in google chrome, it works fine. And if I open the file with PDF-XChange, it works fine.
HOWEVER, when I open the PDF file in Adobe acrobate installed on my Windows 10 machine, I have the same problem that the field is empty.