Hi,
You need to upload the PDF somewhere. Attachments are deleted.
Tilman

--- Original-Nachricht ---
Von: Damaji Kalunge
Betreff: Re: PDF is not opening the Adobe reader when filled using COS 
Model and save using incremental Save.
Datum: 25. August 2022, 10:22
An: users@pdfbox.apache.org


Please find the attached filled PDF.

On Thu, Aug 25, 2022 at 1:51 PM Damaji Kalunge <dam...@technogise.com
<mailto:dam...@technogise.com> > 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("
  <http://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();

Reply via email to