PDF formfield radiobutton syntax latex3 generation

172 Views Asked by At

I stumbled over the following PDF since my PDF library has problems with it. It contains what I would call a peculiar interpretation of the PDF specification thus the radiobutton is not working correctly in most viewers. However a standard could be interpreted in many ways so the question is:

Is this a valid radiobutton group?

I see the following points - please share your insights:

  1. It mimics a 'RadiosInUnison' behavior without using the actual flag (probably by referencing the same index in the Opt array)
  2. The option array does only contain 4 widget references instead of 6
  3. The intent of the 0 index element of the option array seems to be a "standby position" for the DV or the initial V (or maybe a NoToggleToOff was desired?)
  4. Encoding of Bär?
  5. ...?

Here is the "code" (shortened)

51 0 obj
  <</DV /0 /FT/Btn /Ff 32768 /Kids[ 55 0 R 58 0 R 61 0 R 73 0 R 77 0 R 81 0 R ] /Opt [ (B) (Bär) (Sieglinde) (Duck) ] /T (A) /V /0 >>
endobj
55 0 obj
  <</Type /Annot /AP <</N <</1 36 0 R/Off 39 0 R>>>> /AS /Off /F 0 /Parent 51 0 R /Rect [ 255 387 301 447 ] /Subtype /Widget>>
endobj
58 0 obj
  <</Type /Annot /AP <</N <</2 41 0 R /Off 43 0 R>>>> /AS /Off /F 0 /Parent 51 0 R /Rect [ 313 387 348 447 ] /Subtype /Widget>>
endobj
61 0 obj
  <</Type /Annot /AP <</N <</3 45 0 R /Off 47 0 R>>>> /AS /Off /F 0 /Parent 51 0 R /Rect [ 360 387 417 447 ] /Subtype /Widget>>
endobj
73 0 obj
  <</Type /Annot /AP 72 0 obj<</D <</1 66 0 R/Off 68 0 R>>/N <</1 62 0 R/Off 64 0 R>>>> /AS /Off /F 0 /Parent 51 0 R /Rect [ 272 367 284 379 ] /Subtype /Widget>>
endobj
77 0 obj
  <</Type /Annot /AP <</D <</2 66 0 R/Off 68 0 R>>/N <</2 62 0 R /Off 64 0 R>>>> R /AS /Off /F 0 /Parent 51 0 R /Rect [ 325 367 336 379 ] /Subtype /Widget>>
endobj
81 0 obj
  <</Type /Annot /AP <</D <</3 66 0 R/Off 68 0 R>>/N <</3 62 0 R/Off 64 0 R>>>> /AS /Off /F 0 /Parent 51 0 R /Rect [ 383 367 395 379 ] /Subtype /Widget>>
endobj

1. According to the PDF spec the Opt array is:

An array containing one entry for each widget annotation in the Kids array of the radio button [...]

2. And also

When this entry (=Opt) is present, the names used to represent the on state in the AP dictionary of each annotation may use numerical position (starting with 0) of the annotation in the Kids array [...]

Which basically means that the indices must match, right?

/Kids[55 0 R  58 0 R   61 0 R      73 0 R    77 0 R     81 0 R ] 
       |        |          |          |         |         |
/Opt [(B)     (Bär)   (Sieglinde) (Duck)       ?         ?    ]

3.

For radio buttons, the same behaviour (several widgets are checked) shall occur only if the RadiosInUnison flag is set. If it is not set, at most one radio button in a field shall be set at a time.

=> to reach the result in the example PDF that two radiobutton widgets are checked the RadiosInUnison must be set

Any other violations? (Background: After everything is collected I'll inform the latex3 guys and hopefully we'll get this improved)

1

There are 1 best solutions below

6
On
  1. If you want Radiosinunison behavior you need to set the flag

From the ISO 32000 PDF Standard: "For radio buttons, the same behaviour shall occur only if the RadiosInUnison flag is set. If it is not set, at most one radio button in a field shall be set at a time."

  1. There is no such thing as a "dummy index for /0" nor should the number of elements in the Opt array be smaller than the number of elements in the Kids array:

From the ISO 32000 PDF Standard: An array containing one entry for each widget annotation in the Kids array of the radio button [...]

This messes up your export values as shown in the following viewer: Shifted export values

  1. The encoding for Bär is wrong. Should be (Bär).

There are several possibilities to correctly specify the scenario of your test document:

//not using /Opt array
4 0 obj
<</FT/Btn/Ff 33587200/Kids[16 0 R 31 0 R 40 0 R 49 0 R 63 0 R 77 0 R]/T(A)>>
endobj
16 0 obj
<</AP <</N <</B#E4r 19 0 R/Off 20 0 R>>>>/AS/Off/MK<</CA(l)>>/P 14 0 R/Parent 4 0 R/Rect[255.191 387.106 301.307 447.484]/Subtype/Widget/Type/Annot>>
endobj
31 0 obj
<</AP <</N <</Off 34 0 R/Sieglinde 35 0 R>>>>/AS/Off/MK<</CA(l)>>/P 14 0 R/Parent 4 0 R/Rect[313.262 387.106 348.695 447.484]/Subtype/Widget/Type/Annot>>
endobj
40 0 obj
<</AP <</N <</Duck 43 0 R/Off 44 0 R>>>>/AS/Off/MK<</CA(l)>>/P 14 0 R/Parent 4 0 R/Rect[360.65 387.106 417.825 447.484]/Subtype/Widget/Type/Annot>>
endobj
49 0 obj
<</AP <</D <</B#E4r 59 0 R/Off 60 0 R>>/N <</B#E4r 53 0 R/Off 54 0 R>>>>/AS/Off/MK<</CA(l)>>/P 14 0 R/Parent 4 0 R/Rect[272.271 367.275 284.226 379.23]/Subtype/Widget/Type/Annot>>
endobj
63 0 obj
<</AP <</D <</Off 73 0 R/Sieglinde 74 0 R>>/N <</Off 67 0 R/Sieglinde 68 0 R>>>>/AS/Off/MK<</CA(l)>>/P 14 0 R/Parent 4 0 R/Rect[325.001 367.275 336.956 379.23]/Subtype/Widget/Type/Annot>>
endobj
77 0 obj
<</AP <</D <</Duck 87 0 R/Off 88 0 R>>/N <</Duck 81 0 R/Off 82 0 R>>>>/AS/Off/MK<</CA(l)>>/P 14 0 R/Parent 4 0 R/Rect[383.26 367.275 395.215 379.23]/Subtype/Widget/Type/Annot>>
endobj

OR

//With /Opt array
4 0 obj
<</FT/Btn/Ff 33587200/Kids[16 0 R 31 0 R 40 0 R 49 0 R 63 0 R 77 0 R]/Opt[(Bär)(Sieglinde)(Duck)(Bär)(Sieglinde)(Duck)]/T(A)/V/Off>>
endobj
16 0 obj
<</AP <</N <</0 19 0 R/Off 20 0 R>>>>/AS/Off/MK<</CA(l)>>/P 14 0 R/Parent 4 0 R/Rect[255.191 387.106 301.307 447.484]/Subtype/Widget/Type/Annot>>
endobj
31 0 obj
<</AP <</N <</1 34 0 R/Off 35 0 R>>>>/AS/Off/MK<</CA(l)>>/P 14 0 R/Parent 4 0 R/Rect[313.262 387.106 348.695 447.484]/Subtype/Widget/Type/Annot>>
endobj
40 0 obj
<</AP <</N <</2 43 0 R/Off 44 0 R>>>>/AS/Off/MK<</CA(l)>>/P 14 0 R/Parent 4 0 R/Rect[360.65 387.106 417.825 447.484]/Subtype/Widget/Type/Annot>>
endobj
49 0 obj
<</AP <</D <</0 59 0 R/Off 60 0 R>>/N <</0 53 0 R/Off 54 0 R>>>>/AS/Off/MK<</CA(l)>>/P 14 0 R/Parent 4 0 R/Rect[272.271 367.275 284.226 379.23]/Subtype/Widget/Type/Annot>>
endobj
63 0 obj
<</AP <</D <</1 73 0 R/Off 74 0 R>>/N <</1 67 0 R/Off 68 0 R>>>>/AS/Off/MK<</CA(l)>>/P 14 0 R/Parent 4 0 R/Rect[325.001 367.275 336.956 379.23]/Subtype/Widget/Type/Annot>>
endobj
77 0 obj
<</AP <</D <</2 87 0 R/Off 88 0 R>>/N <</2 81 0 R/Off 82 0 R>>>>/AS/Off/MK<</CA(l)>>/P 14 0 R/Parent 4 0 R/Rect[383.26 367.275 395.215 379.23]/Subtype/Widget/Type/Annot>>
endobj