3

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)

Lonzak
  • 9,334
  • 5
  • 57
  • 88
  • 1
    regarding 1 the docu says "The flag RadiosInUnison is neither needed for this (but doesn’t harm either) nor does it change the behaviour, at least again not in the PDF viewers I tried.". Regaring the rest: I have no time currently. Please open an issue at the pdfresource repo then I can look later. – Ulrike Fischer Mar 24 '22 at 13:44
  • What documentation are you referring to? The flag is of course optional however if you want to get the behavior of the example document that two radiobuttons are selected at the same time you need to use it. 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." – Lonzak Mar 24 '22 at 14:33
  • 1
    "documentation" meant the file you found. But beside this: it is not my fault viewers don't handle the flag as intended ;-). It can be easily added, there is an option, but I didn't find an example where it mattered or an example that demonstrated the difference. – Ulrike Fischer Mar 24 '22 at 14:52
  • Ah ok so did you create the PDF? I updated my post (cp. point 3). "But beside this: it is not my fault viewers don't handle the flag as intended ;-)" In my experience most viewers do support `RadiosInUnison` however not the invalid syntax with the `opt` array which is used. I am just thinking that you/we should maximize compatibility regarding the PDF syntax used... – Lonzak Mar 24 '22 at 16:12
  • 1
    well if you think that there is an invalid syntax then open an issue at the repo. – Ulrike Fischer Mar 24 '22 at 16:16
  • 1
    I changed the code and added a test file here with four groups with different settings https://github.com/latex3/pdfresources/blob/testradio/experiments/radiobuttons.pdf Could you check them if they work with your library? (I still see no difference if RadiosInUnison is set or not.) – Ulrike Fischer Apr 02 '22 at 13:35
  • Yes the first Radiobuttongroup called (A) now works correctly. The 2nd one however throws an error since two elements are selected (/AS is twice not /Off) and the radiosinunison is not set. Element (C) is nearly correct however the 2nd appearance (of Siglinde) is not correctly set (it is /Off not /1). The last one behaves correctly... – Lonzak Apr 11 '22 at 15:43

1 Answers1

0
  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
Lonzak
  • 9,334
  • 5
  • 57
  • 88
  • hm, why do you think that the opt array needs six entries, when you use only three (/0, /1, and /2)? And to answer why my array has four elements: because it makes my code simpler if I can count starting from /1, so I have a dummy for /0 at the begin. – Ulrike Fischer Mar 24 '22 at 16:42
  • a) "hm, why do you think that the opt array needs six entries" Because the PDF spec says so :-) (see the bold 1. in my question). b) " I have a dummy for /0 at the begin" This "dummy" now maps to the first element in the widget array and is not a valid concept according to the PDF spec. This you can also see in the *crobat edit mode which is broken... – Lonzak Mar 24 '22 at 17:19
  • you are contradiction yourself. If you think that there should be a one-to-one mapping between the array and the widgets, then you should also use the values and have /4, /5, /6 in your second set. It doesn't make sense to assume that the spec requires values that nobody access. – Ulrike Fischer Mar 24 '22 at 17:37
  • If `Radiosinunison` behavior is wanted the index turns into the name for the on state which must be the same for same-checked widgets -> `/0/1/2/0/1/2` instead of `/0/1/2/3/4/5`. However all widgets need an export value - so if you electronically read the PDF (e.g. in a batch or a program) and get the export value for each widget a 1:1 mapping is done to extract the export value. This would in your PDF result in an IndexOutOfBound Error... – Lonzak Mar 24 '22 at 22:53
  • well as I said: please open an issue, I don't have currently the time to really look at it. And if you know a program that errors please give some details (Is the screenshot from adobe?). – Ulrike Fischer Mar 25 '22 at 10:52
  • Yes I'll do so when we have clarity about all issues. Yes the screenshot is from *dobe *crobat. – Lonzak Mar 25 '22 at 12:52