Uploaded image for project: 'PDFBox'
  1. PDFBox
  2. PDFBOX-4922

Missing field value after flatten

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 2.0.20
    • None
    • AcroForm

    Description

      When I'm trying to flatten a pdf, some text become blank

       

      Here is a code snippet

      PDDocument pdfDocument = PDDocument.load(new File("a.pdf"));
      pdfDocument.setAllSecurityToBeRemoved(true);
      PDDocumentCatalog docCatalog = pdfDocument.getDocumentCatalog();
      PDAcroForm acroForm = docCatalog.getAcroForm();
      if (acroForm != null) {
        PDField field = (PDField) acroForm.getField("nas");
        field.setValue("test01");
        field = (PDField) acroForm.getField("nom");
        field.setValue("test02");
        acroForm.flatten();
      }
      pdfDocument.save("output.pdf");
      pdfDocument.close();

       

      In this example, the field "nas" will always get filled, but the field "nom" will only be filled if I remove the acroForm.flatten(); line

       

      I've attached the pdf.

       

      Attachments

        1. a.pdf
          186 kB
          Etienne

        Issue Links

          Activity

            People

              msahyoun Maruan Sahyoun
              Vaielab Etienne
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: