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

Filled form fields appear gray instead of black after flatten

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.0.3, 2.0.4, 2.0.5, 3.0.0 PDFBox
    • 2.0.5, 3.0.0 PDFBox
    • AcroForm
    • None

    Description

      Hi,

      I'm facing the following issue: When filling out an acrobat form and flattening it, the text color in the resulting pdf is gray instead of black.

      I attached the input.pdf and several output files for different pdfbox versions. Using pdfbox 2.0.2, I get the expected result with black text, as from version >=2.0.3 the text is gray.

      Code:

      public static void main(String[] args) throws IOException {
          PDDocument doc = PDDocument.load(new File("input.pdf"));
          PDAcroForm form = doc.getDocumentCatalog().getAcroForm();
          form.getField("Text1").setValue("value");
          form.getField("Text2").setValue("value");
          form.getField("Text3").setValue("value");
          form.flatten();
          doc.save("output.pdf");
      }
      

      The default appearance for every text field is set to something like /Helv 0 Tf 0 g. Our current workaround is to replace 0 g with 0 0 0 rg. But in my understanding, they both should yield the same result.

      Thanks in advance.

      Attachments

        1. input.pdf
          403 kB
          Tilman Ginzel
        2. output-2.0.2.pdf
          404 kB
          Tilman Ginzel
        3. output-2.0.3.pdf
          404 kB
          Tilman Ginzel
        4. output-2.0.4.pdf
          404 kB
          Tilman Ginzel
        5. output-2.0.5.pdf
          404 kB
          Tilman Ginzel
        6. output-2.1.0.pdf
          404 kB
          Tilman Ginzel

        Activity

          People

            msahyoun Maruan Sahyoun
            tilmanginzel Tilman Ginzel
            Votes:
            1 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: