java导出pdf复选框,如何使用Java PDFBOX API选中PDF表单中的复选框

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();

}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值