'Load the certificate from a path or as a stream
Dim cert As PdfCertificate = New PdfCertificate("C://temp//pdf.pfx", "syncfusion")
Dim doc As PdfDocument = New PdfDocument
Dim page As PdfPageBase = doc.Pages.Add
Dim graphics As PdfGraphics = page.Graphics
Dim signature As PdfSignature = New PdfSignature(doc, page, cert, "Signature")
signature.TimeStampServer = New TimeStampServer(New Uri("http://timestamp.ermis.gov.gr/TSS/HttpTspServer"))
signature.Bounds = New RectangleF(New PointF(100, 200), New SizeF(100, 100))
signature.ContactInfo = "CONTACT"
signature.LocationInfo = "LOCATION"
signature.Reason = "REASON"
signature.Bounds = New RectangleF(New PointF(100, 100), New SizeF(50, 50))
Dim font As PdfFont = New PdfStandardFont(PdfFontFamily.Helvetica, 14)
graphics.DrawString("Hello world!", font, PdfBrushes.Black, New PointF(0, 0))
signature.EnableValidationAppearance = True
signature.EnableLtv = True
doc.Save("output.pdf")
doc.Close(True)
Process.Start("output.pdf") |
// Create a PdfCertificate instance with X509Certificate2 created from certificates stored on USB tokens
PdfCertificate cert = new PdfCertificate(x509Certificate2);
PdfDocument doc = new PdfDocument();
PdfPageBase page = doc.Pages.Add();
PdfGraphics graphics = page.Graphics;
PdfSignature signature = new PdfSignature(doc, page, cert, "Signature");
signature.TimeStampServer = new TimeStampServer(new Uri("Time stamp server link"));
signature.Bounds = new RectangleF(new PointF(100, 200), new SizeF(100, 100));
signature.ContactInfo = "CONTACT";
signature.LocationInfo = "LOCATION";
signature.Reason = "REASON";
signature.Bounds = new RectangleF(new PointF(100, 100), new SizeF(50, 50));
PdfFont font = new PdfStandardFont(PdfFontFamily.Helvetica, 14);
graphics.DrawString("Hello world!", font, PdfBrushes.Black, new PointF(0, 0));
signature.EnableValidationAppearance = true;
signature.EnableLtv = true;
doc.Save("output.pdf");
doc.Close(true); |