Checkbox issue using pdfrw

125 Views Asked by At

I've noticed that when writing out a pdf using pdfrw, the format of the original is changed. In my situation, the format going in is PDF-1.6, but when it's written out it becomes PDF-1.3.

Could this be causing any issues with the checkboxes?

The situation is the following. Changes to text annotations are properly displayed in all document viewers. However, updating checkboxes is only displayed correctly when the output PDF is viewed in GNOME Document Viewer. The checkboxes remain unchecked or appear to be when the PDF is viewed in other viewers.

I'm updating checkboxes and writing out with the following:

pdf = pdfrw.PdfReader(pdf_path)
page = pdf.pages[0]
checkbox = page['/Annots'][9]
checkbox.update(pdfrw.PdfDict(V=pdfrw.PdfName('Yes'),AS=pdfrw.PdfName('Yes')))
pdfrw.PdfWriter().write(pdf_path_out, pdf)

Edit: In response to a comment, check out the gist link here. https://gist.github.com/busterdancy/41a869645f83addff9f6205eb37447bb

I'm printing the annotation dictionary before updating, after updating, and after writing the pdf out. Yes we see that keys /AS and /V have values of /Yes at the end. However, note the differences.

  1. The first dictionary has no key named /V
  2. The second dictionary has included the key /V
  3. The third dictionary's key, /AP, is different than the other two
  4. The parent key /P is different for all three.

I'm not sure if these differences can be the cause of the issues.

1

There are 1 best solutions below

2
On

There seem to be errors in naming this should be named as associated with "Loan Assumption Addendum" but is named "Check Box1" whereas "Loan Assumption Addendum" thinks it is on Page 8 (where there is a second box ?) This may just be one discrepancy in 284 but if not the best bet is to review all.

enter image description here enter image description here

There are several other oddities causing ambiguity, where both is and is not can be selected together, whereas it should be either or. Also other numbering is less rational for tracking results, so number 6 is stored as number 111.

enter image description here

Whilst I did not spot duplicated fields there are 20 that are tagged as "Undefined" so not really unique for assigning values, and others have name tags but I could not see where they were to be applied.

Two signatures for buyer and seller but both have singular fields. All in all, so many oddities it's a wonder it is offered for a contract.

The questions focus was check boxes and many of those I could find by selection were set to be Off or "On".

<<
/T (A Buyers Possession Seller shall deliver to Buyer possession of the Property in its present or required-1)
/V /Off
>> <<
/T (A Buyers Possession Seller shall deliver to Buyer possession of the Property in its present or required-111)
/V /On
>>

In summary /Yes is not an answer and the whole form needs a darn good overhaul.

So @MKL s 1st comment was valid:

Are you sure the positive appearance starts stream has the name Yes in your document?

Currently some CheckBoxs in the whole file show /Off /Yes and many others, before and after, are set either /Off or /On. So the issue seems to be rooted in inconsistency, as this appears to be the 17th time somebody has revised the file from prior years version 17 to last years version 18.

enter image description here