Hello Damaji,

this works for me 

try (PDDocument doc = Loader.loadPDF(new File("80.pdf"))) {
    doc.setAllSecurityToBeRemoved(true);
    PDAcroForm acroForm = doc.getDocumentCatalog().getAcroForm();
    PDCheckBox field = (PDCheckBox) acroForm.getField("ap.sex");
    field.setValue("female");
    doc.save("80-filled-pdfbox.pdf");
}

Now, when using the COSModel as you did you need to ensure that
- you find the widget matching the "on" value
- set the AS entry to the value ("female" in your case)
- set the N entry correctly mathching (copying over) the corresponding
entry from the D entry

...

Best would be to lookup the source of the PDCheckBox field to see
what's happening on the COS level when you doe PDDcheckBox.setvalue

BR
Maruan


Am Donnerstag, dem 25.08.2022 um 14:34 +0530 schrieb Damaji Kalunge:
> HI Team,
> 
>     Refer below information
>       Input PDF File : [
> https://drive.google.com/file/d/17XoTxgGSrn9-XMpZsSqhNanzTW6UBCmg/view?usp=sharing
> ]
> 
>       Source Code used to Fill the PDF: [
> https://drive.google.com/file/d/1JP5mcuWxmKwtP_TfNFJsXxTy4S0zWAHF/view?usp=sharing
> ]
> 
>        Filled PDF :[
> https://drive.google.com/file/d/1qNKvgeQrnxKsGDeUyErSgIzT_BGqG-z8/view?usp=sharing
> ]
> 
> After Filling the PDF we are facing two issues .
> 
>     1.  Not able to check the CheckBox field "sex" using attached
> source
> code.
>      2.  Not able to open the filled PDF in the Abode Reader .
> 
> Could please help out in this ?
> 
> Thanks and Regard,
>   Damaji.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@pdfbox.apache.org
For additional commands, e-mail: users-h...@pdfbox.apache.org

Reply via email to