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

PDFBox does not maintain the font appearence of a field if it appears severraly in a PDF Form

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.0.5
    • 2.0.6
    • AcroForm
    • None
    • java web application running on ubutnu 14 and windows 10.

    Description

      I have 5 fields with same name(lets say 'wcode') in different places on a one page pdf form. This fields have different fonts. Normally when you fill out one field manually the other fields automatically pick the sames value, the same this happens when I fill it using PDFbox except that PDFBox changes all my 5 fields to have same font as the first field to appear in the pdf form.

      Here is the code used to fill the field.

      PDDocument _pdfDocument = PDDocument.load(new File(originalPdf))
      PDAcroForm acroForm = _pdfDocument.getDocumentCatalog().getAcroForm();    
      PDTextField myCodeField = (PDTextField) acroForm.getField("wcode");
             if (myCodeField != null) {
                myCodeField .setValue(my.getCode());
             }
      //Refresh layout && Flatten the document                
             acroForm.refreshAppearances();
             acroForm.flatten();
       _pdfDocument.save(outputFile);
      
      

      I added
      acroForm.refreshAppearances();
      after some research but that did not change anything.

      So if the first 'wcode' field to appear on the pdf form is 6pt all the other 'wcode' fields in the rest the pdf will be 6pt even if I had set them in appearance properties to 12pt.

      On the attached pdf the affected field is called CountyCode

      Attachments

        1. countycode.pdf
          3.57 MB
          Shadrack

        Issue Links

          Activity

            People

              Unassigned Unassigned
              shedyk Shadrack
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: