unidoc / unipdf

Golang PDF library for creating and processing PDF files (pure go)
https://unidoc.io
Other
2.47k stars 250 forks source link

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

Open wojciechsmigielski96 opened 2 years ago

wojciechsmigielski96 commented 2 years ago

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"
    }
]
github-actions[bot] commented 2 years ago

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/

wojciechsmigielski96 commented 2 years ago

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