title: Java uses pdfbox to add digital signature to pdf
body: <p>I want to ask a question. If I want to add digital signature to a multi-page pdf, each page has the same seal, can I only add the digital signature once on the first page, and then the other pages only need to quote the appearance of the first seal. Because using this method can reduce the time to add stamps.</p>
  <p>I used the code given by mkl, but I have a question. I replaced the following code with other codes.</p>
  <p>original:</p>
  
  <pre class="lang-java prettyprint-override"><code>try (PDPageContentStream cs = new PDPageContentStream(pdDocument, appearanceStream))
  {
      // show background (just for debugging, to see the rect size + position)
      cs.setNonStrokingColor(Color.yellow);
      cs.addRect(-5000, -5000, 10000, 10000);
      cs.fill();
  
      float fontSize = 10;
      float leading = fontSize * 1.5f;
      cs.beginText();
      cs.setFont(font, fontSize);
      cs.setNonStrokingColor(Color.black);
      cs.newLineAtOffset(fontSize, height - leading);
      cs.setLeading(leading);
      cs.showText(&quot;Signature text&quot;);
      cs.newLine();
      cs.showText(&quot;some additional Information&quot;);
      cs.newLine();
      cs.showText(&quot;let's keep talking&quot;);
      cs.endText();
  }
  </code></pre>
  <p>now:</p>
  <pre class="lang-java prettyprint-override"><code>PDImageXObject Sign0 = PDImageXObject.createFromByteArray(doc, imageByte, null);
  
  try (PDPageContentStream cs = new PDPageContentStream(pdDocument, appearanceStream))
  {
      cs.drawImage(Sign0,0, 0,rectangle.getWidth(),rectangle.getHeight());
  }
  </code></pre>
  <p>The original code is valid at the time of stamping, but the modified code will invalidate the stamp. I use Adobe Acrobat Pro DC to open the signed document. This error is &quot;An error occurred during signature verification. Adobe Acrobat error. Expected dictionary object.&quot;. I'm not sure what happened.</p>