I am having trouble with stamping PDF documents without invalidating digital signatures.
Current, I succeeded stamping a PDF. However, if the document is previously signed the signature is no longer valid. I understand why that happens, but if I use Acrobat to add text or stamp it using annotation, the signature is valid.
I tried adding annotations or comments but it still invalidates the signature. Is there a way to add stamp to a PDF using iText without invalidating digital signatures?
Here is a snippet of the code i use to stamp:
PdfReader reader = new PdfReader(inputstream);
stamp = new PdfStamper(reader, new FileOutputStream(file));
PdfContentByte pcb;
BaseFont bf = BaseFont.createFont("Courier", BaseFont.CP1250,BaseFont.EMBEDDED);
Rectangle r = reader.getPageSizeWithRotation(1);
pcb = stamp.getOverContent(1);
// set the font and size
float size = 12;
pcb.setFontAndSize(bf, size);
float width = 90;
float centerX = 0, startY = 0;
centerX = r.getWidth() - (width / 2) - 20;
startY = r.getHeight() - (15 * 2) - 145;
pcb.beginText();
pcb.showTextAligned(PdfContentByte.ALIGN_CENTER, stampText, centerX, startY, 0);
pcb.setFontAndSize(bf, 10);
pcb.showTextAligned(PdfContentByte.ALIGN_CENTER, date, centerX-9, startY-8, 0);
pcb.endText();
stamp.close();
Any help will be much appreciated, Thanks