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.
I used the code given by mkl, but I have a question. I replaced the following code with other codes.
original:
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("Signature text");
cs.newLine();
cs.showText("some additional Information");
cs.newLine();
cs.showText("let's keep talking");
cs.endText();
}
now:
PDImageXObject Sign0 = PDImageXObject.createFromByteArray(doc, imageByte, null);
try (PDPageContentStream cs = new PDPageContentStream(pdDocument, appearanceStream))
{
cs.drawImage(Sign0,0, 0,rectangle.getWidth(),rectangle.getHeight());
}
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 "An error occurred during signature verification. Adobe Acrobat error. Expected dictionary object.". I'm not sure what happened.