//Creates a new PDF document. PdfDocument document = new PdfDocument(); //Adds a new page. PdfPageBase page = document.Pages.Add(); //Create PDF graphics for the page. PdfGraphics graphics = page.Graphics;
//Creates a certificate instance from PFX file with private key. PdfCertificate pdfCert = new PdfCertificate(@"PDF.pfx", "password123"); //Creates a digital signature. PdfSignature signature = new PdfSignature(document, page, pdfCert, "Signature"); //Sets an image for signature field. PdfBitmap signatureImage = new PdfBitmap(@"signature.png"); //Sets signature information. signature.Bounds = new RectangleF(0,0,200,100); signature.ContactInfo = "johndoe@owned.us"; signature.LocationInfo = "Honolulu, Hawaii"; signature.Reason = "I am author of this document."; //Create appearance for the digital siganture. signature.Appearance.Normal.Graphics.DrawImage(signatureImage, signature.Bounds);
//Save the document. document.Save("DigitalSignature.pdf"); //Close the document. document.Close(true);
|