Please find the attached filled PDF.
On Thu, Aug 25, 2022 at 1:51 PM Damaji Kalunge <[email protected]>
wrote:
> Hi Team,
> I am using the Apache PDFBox library ( 3.0.0-alpha3)and method to fill
> the PDF.
> But it is not opening the Adobe Reader. Please find the attached
> screenshot.
>
>
> PDDocument pDDocument = Loader.loadPDF(new File("src/main/resources",
> "80.pdf"));
> if (pDDocument.isEncrypted()) {
> try {
>
> PDAcroForm pDAcroForm = pDDocument.getDocumentCatalog().getAcroForm();
>
> COSDictionary cosDictionary1=pDAcroForm.getField("ap.name
> fam").getCOSObject();
>
> cosDictionary1.setString(COSName.V ,"family Name");
> COSDictionary cosDictionary2=pDAcroForm.getField("ap.birth
> cntry").getCOSObject();
>
> cosDictionary2.setString(COSName.V ,"India");
>
> COSDictionary
> cosDictionary3=pDAcroForm.getField("ap.sex").getCOSObject();
> cosDictionary3.setString(COSName.V ,"female");
> COSDictionary
> cosDictionary4=pDAcroForm.getField("ap.chinese").getCOSObject();
> cosDictionary4.setString(COSName.V,"Yes");
>
> 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);
> set.add(cosDictionary4);
> pDDocument.saveIncremental(fileOutputStream,set);
> pDDocument.close();
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]