How to reset the form back to the point where no selection is made?

Q:
How am I supposed to clear the selection on a radio button on the PDF? I’ve tried SetValue(""), SetValue(false), and even SetValue(field.
GetDefaultValue()) and no luck. I would like to be able to reset the form back to the point where no selection is made. Possible?


A:
The PDF spec does not provide any sort of Reset mechanism for fields, in that there is no idea of the original/default value, only the current.

Complicating things is that the field specifies the “Appearance State” of the ‘On’ Widget, and not the widget (aka annotation) itself. This is stored in the V entry of the field, and corresponds to the AS entry of the widget annotation, and the AS must match a corresponding normal appearance stream in the widget (AP → N). For example…

Field0 { V: “NO” } with Kids Widget0 and Widget1

Widget0 { AS : “OFF”, AP { N { OFF, YES } } }
Widget1 { AS : “NO”, AP { N { OFF, NO } } }

Where the AP.N.OFF appearances streams display an empty radio button, and the AP.N.YES and AP.N.NO streams display a selected radio button.

So in the example above, Widget1 is “On/True/Selected”, because Field0.V = “NO” which matches Widget1.

So if you want to reset, what I would recommend is reading the fields, and add a custom entry to the SDF object, say “DEFAULT_V” and set it to the same value as “V”, and do the same for the widgets, but for the AS entry. Then when you want to reset you can go back and restore the values.

See here for creating custom dictionary entries into a PDF. http://www.pdftron.com/pdfnet/intro.html#sdf_obj

Note, you can see all this by using our COSEdit tool that comes with PDFNet downloads for desktop.