You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@pdfbox.apache.org by Damaji Kalunge <da...@technogise.com> on 2022/08/25 06:33:49 UTC
Check the PDF box based on its value
Hi Team,
I am ticking the checkbox using below
try {
PDDocument pDDocument = Loader.loadPDF(new
File("src/main/resources", "80.pdf"));
if (pDDocument.isEncrypted()) {
try {
PDAcroForm pDAcroForm =
pDDocument.getDocumentCatalog().getAcroForm();
COSDictionary cosDictionary3 =
pDAcroForm.getField("ap.sex").getCOSObject();
cosDictionary3.setString(COSName.V, "male");
OR
FileOutputStream fileOutputStream = new
FileOutputStream(new File("src/main/resources",
"incrementalSave.pdf"));
Set<COSDictionary> set = new HashSet<>();
set.add(cosDictionary1);
set.add(cosDictionary2);
set.add(cosDictionary3);
pDDocument.saveIncremental(fileOutputStream, set);
pDDocument.close();
}