Add signature image on PDF without digitally signing it using iTextSharp

Viewed 17491

I am using iTextSharp to work with PDFs. I want to add signature image to Signature field without digitally signing the document (without any involvement of certificate).

Is it possible? I am able to work with digital signing but I also want to just add signature image on signature field without any use of certificates.

UPDATE:

Write now I have following code.

// Set PDF Reader and PDF Stamper
PdfReader reader = new PdfReader(sourceDocument);

// File stream where PDF will write
FileStream fout = new FileStream(destinationPath, FileMode.Create, FileAccess.ReadWrite);
PdfStamper stamper = PdfStamper.CreateSignature(reader, fout, '\0', null, true);

// Set PDF Appearance              
PdfSignatureAppearance appearance = stamper.SignatureAppearance;
iTextSharp.text.Image signatureFieldImage = iTextSharp.text.Image.GetInstance(image, System.Drawing.Imaging.ImageFormat.Png);
appearance.SignatureGraphic = signatureFieldImage;
appearance.SignatureRenderingMode = PdfSignatureAppearance.RenderingMode.GRAPHIC;
appearance.SetVisibleSignature(signatureFieldName);

stamper.Close();
reader.Close();
fout.Close();

But when I try to run it, it gives following error:

Signature defined. Must be closed in PdfSignatureAppearance

2 Answers
Related