I'd like to put an image into a digitally signed PDF. if I do it using the usual way, the signature is broken. But with Acrobat it's possible to add an annotation stamp to a signed PDF and the signature is not broken.
Googgling I've found an example of how to do that:
I've translate it to c# but without success:
using (Stream inputPdfStream = new FileStream("test.pdf", FileMode.Open, FileAccess.Read, FileShare.Read))
using (Stream inputImageStream = new FileStream("grafo.jpg", FileMode.Open, FileAccess.Read, FileShare.Read))
using (Stream outputPdfStream = new FileStream("result.pdf", FileMode.Create, FileAccess.Write, FileShare.None))
{
var reader = new PdfReader(inputPdfStream);
var stamper = new PdfStamper(reader, outputPdfStream);
iTextSharp.text.Image image = iTextSharp.text.Image.GetInstance(inputImageStream);
image.SetAbsolutePosition(0, 0);
PdfTemplate template = PdfTemplate.CreateTemplate(stamper.Writer, image.Width, image.Height);
template.AddImage(image);
iTextSharp.text.Rectangle rect = new iTextSharp.text.Rectangle(350, 250, 350 + image.Width, 250 + image.Height);
PdfAnnotation annotation = PdfAnnotation.CreateStamp(stamper.Writer, rect, null, Guid.NewGuid().ToString());
annotation.SetAppearance(PdfName.N, template);
stamper.AddAnnotation(annotation, 1);
stamper.Close();
}
When I open the PDF with Acrobat, signature is broken.
Some idea of how to do that with iText?
Thank's