unidoc/unipdf

[BUG] Selecting radio button results in an invalid pdf.

wojciechsmigielski96 opened this issue · 2 comments

Description

I have a simple pdf with 3 choices radio button.
radioButtonExample.pdf
Screenshot 2022-05-20 at 14 15 51

Field data of the pdf with no radio button selection:

[
    {
        "name": "RadioButton",
        "value": ""
    },
    {
        "name": "RadioButton",
        "value": "Off",
        "options": [
            "1",
            "Off"
        ]
    },
    {
        "name": "RadioButton",
        "value": "Off",
        "options": [
            "2",
            "Off"
        ]
    },
    {
        "name": "RadioButton",
        "value": "Off",
        "options": [
            "3",
            "Off"
        ]
    }
]

Field data of the pdf with the third option selected.

[
    {
        "name": "RadioButton",
        "value": ""
    },
    {
        "name": "RadioButton",
        "value": "Off",
        "options": [
            "1",
            "Off"
        ]
    },
    {
        "name": "RadioButton",
        "value": "Off",
        "options": [
            "2",
            "Off"
        ]
    },
    {
        "name": "RadioButton",
        "value": "3",
        "options": [
            "3",
            "Off"
        ]
    }
]

Running pdf_form_fill_json.go with Field data of the pdf with the third option selected results in broken pdf
Only the third option is visible.

Screenshot 2022-05-20 at 14 15 37

The broken pdf's field data

[
    {
        "name": "RadioButton",
        "value": ""
    },
    {
        "name": "RadioButton",
        "value": "3",
        "options": [
            "1",
            "Off"
        ]
    },
    {
        "name": "RadioButton",
        "value": "3",
        "options": [
            "2",
            "Off"
        ]
    },
    {
        "name": "RadioButton",
        "value": "3",
        "options": [
            "3",
            "Off"
        ]
    }
]

The following field format also didn't work.

[
    {
        "name": "RadioButton",
        "value": "3"
    }
]

Welcome! Thanks for posting your first issue. The way things work here is that while customer issues are prioritized, other issues go into our backlog where they are assessed and fitted into the roadmap when suitable. If you need to get this done, consider buying a license which also enables you to use it in your commercial products. More information can be found on https://unidoc.io/

I run pdf_form_list_fields.go on the document. The checkbox with radio flag is found instead of RadioBox.

Field 2
Name: RadioButton
 Flags: NoToggleToOff|Radio (49152)
 Button
 - Checkbox
 ..

Field 3
Name: RadioButton
 Flags: NoToggleToOff|Radio (49152)
 Button
 - Checkbox