How to check a check box in PDF-form using Java PDFBOX api
Initially I tried with the below piece of code but after the execution check box field is invisible in PDF , but it has been checked.. how to avoid such circumstances or they way i have implemented is wrong ? can any one help me out
public void check() throws Exception
{
PDDocument fdeb = null;
fdeb = PDDocument.load( "C:\\Users\\34\\Desktop\\complaintform.pdf" );
PDAcroForm form = fdeb.getDocumentCatalog().getAcroForm();
PDField feld3 = form.getField( "check" );
feld3.setValue("check");
fdeb.save("C:\\Users\\34\\Desktop\\complaintform.pdf");
fdeb.close();
}
Thanks
Finally got it work !!!! change made in setValue statment and replaced with ((PDCheckbox) feld3).check();
public void check() throws Exception
{
PDDocument fdeb = null;
fdeb = PDDocument.load( "C:\\Users\\34\\Desktop\\complaintform.pdf" );
PDAcroForm form = fdeb.getDocumentCatalog().getAcroForm();
PDField feld3 = form.getField("loan");
((PDCheckbox) feld3).check();
fdeb.save("C:\\Users\\34\\Desktop\\complaintform.pdf");
fdeb.close();
}