title: Rendering a document with filled form fields using PDFBox works with 1.8.2, but not 2.0.2
body: <p>My goal is to open a PDF document, fill in some form fields and then render it to an image. I'm using PDFBox with Java to do it. I started using version 2.0.2 (latest) and filling the form fields works. When I save it and then open it with a PDF reader, the form fields have values. But when I render it to an image, the form fields have black borders and no text inside. I then tried the same thing with 1.8.12 and it works. However, I would really like to use the new features in 2.x.</p>
  
  <ul>
  <li>The PDF only has AcroForms, no XFA (or at least I think so). When I call PDAcroForm.getXFA() it returns null.</li>
  <li>Using 2.0.2, if I'm rendering something filled using setValue, then the rendering looks broken. However, rendering something filled using Adobe Reader works. Both cases work using 1.8.</li>
  <li>With 2.0.2 I tried any combination of PDAcroForm.refreshAppearances() and/or PDAcroForm.setNeedAppearances(true). Those methods are absent in 1.8.</li>
  </ul>
  
  <p>The code I'm using to render using 1.8.12:</p>
  
  <pre><code>public class Main {
      public static void main(String[] args) throws Exception {
          PDDocument doc = PDDocument.loadNonSeq(new File("test.pdf"), null);
          doc.setAllSecurityToBeRemoved(true);
          PDDocumentCatalog cat = doc.getDocumentCatalog();
          PDAcroForm form = cat.getAcroForm();
          for (Object _field : form.getFields()) {
              PDField field = (PDField) _field;
              System.out.println(field.getFullyQualifiedName());
              field.setValue(field.getFullyQualifiedName());
          }
  
          List&lt;PDPage&gt; pdPages = doc.getDocumentCatalog().getAllPages();
          int page = 0;
          for (PDPage pdPage : pdPages) {
              ++page;
              BufferedImage bim = pdPage.convertToImage(BufferedImage.TYPE_INT_RGB, 96);
              ImageIOUtil.writeImage(bim, "rendered" + "-" + page + ".png", 96);
          }
          doc.close();
      }
  }
  </code></pre>
  
  <p>The code I'm using to render using 2.0.2:</p>
  
  <pre><code>public class Main {
      public static void main(String[] args) throws Exception {
          PDDocument doc = PDDocument.load(new File("test.pdf"));
          doc.setAllSecurityToBeRemoved(true);
          PDDocumentCatalog cat = doc.getDocumentCatalog();
          PDAcroForm form = cat.getAcroForm();
          for (PDField field : form.getFields()) {
              System.out.println(field.getFullyQualifiedName());
              if (field instanceof PDTextField) {
                  field.setValue(field.getFullyQualifiedName());
              }
          }
          // Doesn't work with or without these
          form.setNeedAppearances(true);
          form.refreshAppearances();
  
          PDDocument renderDoc = doc;
          PDFRenderer pdfRenderer = new PDFRenderer(renderDoc);
          for (int page = 0; page &lt; renderDoc.getNumberOfPages(); ++page) {
              BufferedImage bim = pdfRenderer.renderImageWithDPI(page, 96,     ImageType.RGB);
              ImageIOUtil.writeImage(bim, "rendered" + "-" + (page + 1) +     ".png", 96);
          }
      }
  }
  </code></pre>
  
  <p>Correct version rendered using 1.8.12: <a href="https://i.stack.imgur.com/H7Tpd.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/H7Tpd.png" alt="Correct rendering with 1.8.12"></a></p>
  
  <p>Bad version rendered using 2.0.2: <a href="https://i.stack.imgur.com/tMjh4.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/tMjh4.png" alt="Bad version rendering with 2.0.2"></a></p>