1

In my PDF I am having one box I want to place digital signature in that box..How can I do it using iTextSharp. enter image description here

iTextSharp.text.pdf.PdfStamper stamper = iTextSharp.text.pdf.PdfStamper.CreateSignature(reader, fout, '\0');

iTextSharp.text.pdf.PdfSignatureAppearance appearance = stamper.SignatureAppearance;
iTextSharp.text.pdf.BaseFont bf = iTextSharp.text.pdf.BaseFont.CreateFont(System.Web.HttpContext.Current.Server.MapPath("~/files/Arial.ttf"), iTextSharp.text.pdf.BaseFont.IDENTITY_H, iTextSharp.text.pdf.BaseFont.EMBEDDED);
iTextSharp.text.Font font = new iTextSharp.text.Font(bf, 11);
appearance.Layer2Font = font;
//appearance.Image = new iTextSharp.text.pdf.PdfImage();
appearance.Reason = "Test";
appearance.Location = "Pune";

appearance.SetVisibleSignature("SignHere");
IExternalSignature es = new PrivateKeySignature(pk, "SHA-256");
MakeSignature.SignDetached(appearance, es, new Org.BouncyCastle.X509.X509Certificate[] { pk12.GetCertificate(alias).Certificate }, null, null, null, 0, CryptoStandard.CMS);
stamper.Close();
Amedee Van Gasse
  • 7,280
  • 5
  • 55
  • 101
snehal
  • 31
  • 1
  • How can that box be recognized? Is it always at the same position? If not, how is it drawn (vector graphics? Bitmap? Somehow else?) Is the text in the box always the same? – mkl Jul 31 '20 at 08:03
  • PDF is generated using SSRS RDL report. Text will be the same always but position may change – snehal Jul 31 '20 at 08:51
  • How is it drawn (vector graphics? Bitmap? Somehow else?) You may want to share a representative example file. – mkl Jul 31 '20 at 09:14
  • Another approach is: Can you influence the PDF which is created? I once implemented a mechanism where a customer would embedd a white text on a white page ("@signature here") and afterwards you could scan the PDF for this specific text and add a signature field at that location... – Lonzak Aug 20 '20 at 16:01

0 Answers0