Class PdfCertificate
Represents the Certificate object.
Inheritance
Inherited Members
Namespace: Syncfusion.Pdf.Security
Assembly: Syncfusion.Pdf.Base.dll
Syntax
public class PdfCertificate
Remarks
This API is not supported in WinRT, Windows Phone, Xamarin, Universal Windows Platform and Silverlight.
Examples
// Creates a new document
PdfDocument doc = new PdfDocument();
//Creates a new page and adds it as the last page of the document
PdfPage page = doc.Pages.Add();
//Create new PDF certificate instance.
PdfCertificate pdfCert = new PdfCertificate("Pdf.pfx", "syncfusion");
//Create new PDF signature instance.
PdfSignature signature = new PdfSignature(doc, page, pdfCert, "Signature");
signature.Bounds = new RectangleF(new PointF(5, 5),new SizeF(100,200));
doc.Save("SignedPdfSample.pdf");
doc.Close(true);
' Creates a new document
Dim doc As PdfDocument = New PdfDocument()
' Create a page
Dim page As PdfPage = doc.Pages.Add()
'Create new PDF certificate instance.
Dim pdfCert As PdfCertificate = New PdfCertificate("Pdf.pfx", "syncfusion")
'Create new PDF signature instance.
Dim signature As PdfSignature = New PdfSignature(doc, page, pdfCert, "Signature")
signature.Bounds = New RectangleF(New PointF(5, 5),New SizeF(100,200))
doc.Save("SignedPdfSample.pdf")
doc.Close(True)
Constructors
PdfCertificate(Stream, String)
Initializes a new instance of the PdfCertificate class with the path to the pfx file and the password.
Declaration
public PdfCertificate(Stream certificate, string password)
Parameters
Type | Name | Description |
---|---|---|
System.IO.Stream | certificate | |
System.String | password | The password for pfx file. |
Remarks
This constructor is not supported in WinRT and Silverlight.
Examples
// Creates a new document
PdfDocument doc = new PdfDocument();
//Creates a new page and adds it as the last page of the document
PdfPage page = doc.Pages.Add();
PdfCertificate pdfCert = new PdfCertificate(certificateStream, "123");
PdfSignature signature = new PdfSignature(doc, page, pdfCert, "Signature");
signature.Bounds = new RectangleF(new PointF(5, 5),new SizeF(100,200));
doc.Save("SignedPdfSample.pdf");
doc.Close(true);
' Creates a new document
Dim doc As PdfDocument = New PdfDocument()
' Create a page
Dim page As PdfPage = doc.Pages.Add()
Dim pdfCert As PdfCertificate = New PdfCertificate(certificateStream, "123")
Dim signature As PdfSignature = New PdfSignature(doc, page, pdfCert, "Signature")
signature.Bounds = New RectangleF(New PointF(5, 5),New SizeF(100,200))
doc.Save("SignedPdfSample.pdf")
doc.Close(True)
See Also
PdfCertificate(Stream, String, KeyStorageFlags)
Initializes a new instance of the PdfCertificate class with the path to the pfx file,password and storageflag
Declaration
public PdfCertificate(Stream certificate, string password, KeyStorageFlags storageFlag)
Parameters
Type | Name | Description |
---|---|---|
System.IO.Stream | certificate | |
System.String | password | The password for pfx file. |
KeyStorageFlags | storageFlag | The private key storage flag. |
Remarks
This constructor is not supported in WinRT and Silverlight.
Examples
// Creates a new document
PdfDocument doc = new PdfDocument();
//Creates a new page and adds it as the last page of the document
PdfPage page = doc.Pages.Add();
PdfCertificate pdfCert = new PdfCertificate(certificateStream, "123",KeyStorageFlags.DefaultKeySet);
PdfSignature signature = new PdfSignature(doc, page, pdfCert, "Signature");
signature.Bounds = new RectangleF(new PointF(5, 5),new SizeF(100,200));
doc.Save("SignedPdfSample.pdf");
doc.Close(true);
' Creates a new document
Dim doc As PdfDocument = New PdfDocument()
' Create a page
Dim page As PdfPage = doc.Pages.Add()
Dim pdfCert As PdfCertificate = New PdfCertificate(certificateStream, "123",KeyStorageFlags.DefaultKeySet)
Dim signature As PdfSignature = New PdfSignature(doc, page, pdfCert, "Signature")
signature.Bounds = New RectangleF(New PointF(5, 5),New SizeF(100,200))
doc.Save("SignedPdfSample.pdf")
doc.Close(True)
See Also
PdfCertificate(X509Certificate2)
Initialize the new instance of the PdfCertificate class.
Declaration
public PdfCertificate(X509Certificate2 x509Certificate2)
Parameters
Type | Name | Description |
---|---|---|
System.Security.Cryptography.X509Certificates.X509Certificate2 | x509Certificate2 | The X509 certificate. |
Examples
// Creates a new document
PdfDocument document = new PdfDocument();
//Creates a new page and adds it as the last page of the document
PdfPage page = document.Pages.Add();
//Load the x509 certificate.
X509Certificate2 cert = new X509Certificate2("certificate.pfx", "password");
//Create a new PDF certificate instance using X509Certificate2 object.
PdfCertificate pdfCert = new PdfCertificate(cert);
//Creates a signature.
PdfSignature signature = new PdfSignature(document, page, pdfCert, "Signature");
signature.Bounds = new RectangleF(new PointF(0, 0), new SizeF(100, 100));
signature.ContactInfo = "johndoe@owned.us";
signature.LocationInfo = "Honolulu, Hawaii";
signature.Reason = "I am author of this document.";
//Save the document.
document.Save("output.pdf");
//Close the document.
document.Close(true);
' Creates a new document
Dim document As New PdfDocument()
'Creates a new page and adds it as the last page of the document
Dim page As PdfPage = document.Pages.Add()
'Load the x509 certificate.
Dim cert As New X509Certificate2("certificate.pfx", "password")
'Create a new PDF certificate instance using X509Certificate2 object.
Dim pdfCert As New PdfCertificate(cert)
'Creates a signature.
Dim signature As New PdfSignature(document, page, pdfCert, "Signature")
signature.Bounds = New RectangleF(New PointF(0, 0), New SizeF(100, 100))
signature.ContactInfo = "johndoe@owned.us"
signature.LocationInfo = "Honolulu, Hawaii"
signature.Reason = "I am author of this document."
'Save the document.
document.Save("output.pdf")
'Close the document.
document.Close(True)
PdfCertificate(String, String)
Initializes a new instance of the PdfCertificate class with the path to the pfx file and the password.
Declaration
public PdfCertificate(string pfxPath, string password)
Parameters
Type | Name | Description |
---|---|---|
System.String | pfxPath | The path to pfx file. |
System.String | password | The password for pfx file. |
Remarks
This constructor is not supported in WinRT, Windows Phone, Xamarin, Universal Windows Platform and Silverlight.
Examples
// Creates a new document
PdfDocument doc = new PdfDocument();
//Creates a new page and adds it as the last page of the document
PdfPage page = doc.Pages.Add();
PdfCertificate pdfCert = new PdfCertificate("Pdf.pfx", "123");
PdfSignature signature = new PdfSignature(doc, page, pdfCert, "Signature");
signature.Bounds = new RectangleF(new PointF(5, 5),new SizeF(100,200));
doc.Save("SignedPdfSample.pdf");
doc.Close(true);
' Creates a new document
Dim doc As PdfDocument = New PdfDocument()
' Create a page
Dim page As PdfPage = doc.Pages.Add()
Dim pdfCert As PdfCertificate = New PdfCertificate("Pdf.pfx", "123")
Dim signature As PdfSignature = New PdfSignature(doc, page, pdfCert, "Signature")
signature.Bounds = New RectangleF(New PointF(5, 5),New SizeF(100,200))
doc.Save("SignedPdfSample.pdf")
doc.Close(True)
See Also
PdfCertificate(String, String, KeyStorageFlags)
Initializes a new instance of the PdfCertificate class with the path to the pfx file,password and storageflag
Declaration
public PdfCertificate(string pfxPath, string password, KeyStorageFlags storageFlag)
Parameters
Type | Name | Description |
---|---|---|
System.String | pfxPath | The path to pfx file. |
System.String | password | The password for pfx file. |
KeyStorageFlags | storageFlag | The private key storage flag. |
Remarks
This constructor is not supported in WinRT, Windows Phone, Xamarin, Universal Windows Platform and Silverlight.
Examples
// Creates a new document
PdfDocument doc = new PdfDocument();
//Creates a new page and adds it as the last page of the document
PdfPage page = doc.Pages.Add();
PdfCertificate pdfCert = new PdfCertificate("Pdf.pfx", "123",KeyStorageFlags.DefaultKeySet);
PdfSignature signature = new PdfSignature(doc, page, pdfCert, "Signature");
signature.Bounds = new RectangleF(new PointF(5, 5),new SizeF(100,200));
doc.Save("SignedPdfSample.pdf");
doc.Close(true);
' Creates a new document
Dim doc As PdfDocument = New PdfDocument()
' Create a page
Dim page As PdfPage = doc.Pages.Add()
Dim pdfCert As PdfCertificate = New PdfCertificate("Pdf.pfx", "123",KeyStorageFlags.DefaultKeySet)
Dim signature As PdfSignature = New PdfSignature(doc, page, pdfCert, "Signature")
signature.Bounds = New RectangleF(New PointF(5, 5),New SizeF(100,200))
doc.Save("SignedPdfSample.pdf")
doc.Close(True)
See Also
Properties
IssuerName
Gets the certificate issuer's name.[Read-Only]
Declaration
public string IssuerName { get; }
Property Value
Type | Description |
---|---|
System.String | The certificate issuer`s name. |
Remarks
This property is not supported in WinRT, Windows Phone, Xamarin, Universal Windows Platform and Silverlight.
Examples
PdfDocument doc = new PdfDocument();
PdfPage page = doc.Pages.Add();
PdfSolidBrush brush = new PdfSolidBrush(Color.Black);
PdfPen pen = new PdfPen(brush, 0.2f);
PdfFont font = new PdfStandardFont(PdfFontFamily.Courier, 12, PdfFontStyle.Regular);
PdfCertificate pdfCert = new PdfCertificate(@"PDF.pfx", "syncfusion");
PdfSignature signature = new PdfSignature(page, pdfCert, "Signature");
signature.Bounds = new RectangleF(new PointF(5, 5), page.Size);
signature.ContactInfo = "johndoe@owned.us";
signature.LocationInfo = "Honolulu, Hawaii";
signature.Reason = "I am author of this document.";
PdfGraphics g = signature.Appearence.Normal.Graphics;
string validto = "Issuer Name: " + signature.Certificate.IssuerName.ToString()
string validfrom = "Valid From: " + signature.Certificate.ValidFrom.ToString();
doc.Pages[0].Graphics.DrawString(validfrom, font, pen, brush, 0, 90);
doc.Pages[0].Graphics.DrawString(validto, font, pen, brush, 0, 110);
doc.Pages[0].Graphics.DrawString(" Protected Document. Digitally signed Document.", font, pen, brush, 0, 130);
doc.Pages[0].Graphics.DrawString("* To validate Signature click on the signature on this page \n * To check Document Status \n click document status icon on the bottom left of the acrobat reader.", font, pen, brush, 0, 150);
// Save the PDF file.
doc.Save("Sample.pdf");
doc.Close(true);
Dim doc As PdfDocument = New PdfDocument()
Dim page As PdfPage = doc.Pages.Add()
Dim brush As PdfSolidBrush = New PdfSolidBrush(Color.Black)
Dim pen As PdfPen = New PdfPen(brush, 0.2f)
Dim font As PdfFont = New PdfStandardFont(PdfFontFamily.Courier, 12, PdfFontStyle.Regular)
Dim pdfCert As PdfCertificate = New PdfCertificate("PDF.pfx", "syncfusion")
Dim signature As PdfSignature = New PdfSignature(page, pdfCert, "Signature")
signature.Bounds = New RectangleF(New PointF(5, 5), page.Size)
signature.ContactInfo = "johndoe@owned.us"
signature.LocationInfo = "Honolulu, Hawaii"
signature.Reason = "I am author of this document."
Dim g As PdfGraphics = signature.Appearence.Normal.Graphics
Dim validto As String = "Issuer Name: " + signature.Certificate.IssuerName.ToString()
Dim validfrom As String = "Valid From: " + signature.Certificate.ValidFrom.ToString()
doc.Pages(0).Graphics.DrawString(validfrom, font, pen, brush, 0, 90)
doc.Pages(0).Graphics.DrawString(validto, font, pen, brush, 0, 110)
' Save the PDF file.
doc.Save("Sample.pdf")
doc.Close(True)
See Also
SerialNumber
Gets the serial number of a certificate.[Read-Only]
Declaration
public byte[] SerialNumber { get; }
Property Value
Type | Description |
---|---|
System.Byte[] | The serial number of the certificate. |
Remarks
This property is not supported in WinRT, Windows Phone, Xamarin, Universal Windows Platform and Silverlight.
Examples
// Creates a new document
PdfDocument document = new PdfDocument();
//Creates a new page and adds it as the last page of the document
PdfPage page = document.Pages.Add();
//Load an existing PDF certificate.
PdfCertificate certificate = new PdfCertificate("certificate.Pfx", "password");
//Get the serial number of the certificate.
byte[] data = certificate.SerialNumber;
//Get the store certificate.
PdfCertificate storeCertificate = PdfCertificate.FindBySerialId(StoreType.MY, data);
//Creates a digital signature.
PdfSignature signature = new PdfSignature(document, page, storeCertificate, "Signature");
signature.Bounds = new RectangleF(new PointF(0, 0), new SizeF(100, 100));
signature.ContactInfo = "johndoe@owned.us";
signature.LocationInfo = "Honolulu, Hawaii";
signature.Reason = "I am author of this document.";
//Save the document.
document.Save("output.pdf");
//Close the document.
document.Close(true);
' Creates a new document
Dim document As New PdfDocument()
'Creates a new page and adds it as the last page of the document
Dim page As PdfPage = document.Pages.Add()
'Load an existing PDF certificate.
Dim certificate As New PdfCertificate("certificate.Pfx", "password")
'Get the serial number of the certificate.
Dim data As Byte() = certificate.SerialNumber
'Get the store certificate.
Dim storeCertificate As PdfCertificate = PdfCertificate.FindBySerialId(StoreType.MY, data)
'Creates a digital signature.
Dim signature As New PdfSignature(document, page, storeCertificate, "Signature")
signature.Bounds = New RectangleF(New PointF(0, 0), New SizeF(100, 100))
signature.ContactInfo = "johndoe@owned.us"
signature.LocationInfo = "Honolulu, Hawaii"
signature.Reason = "I am author of this document."
'Save the document.
document.Save("output.pdf")
'Close the document.
document.Close(True)
SubjectName
Gets the certificate subject's name.[Read-Only]
Declaration
public string SubjectName { get; }
Property Value
Type |
---|
System.String |
Remarks
This property is not supported in WinRT, Windows Phone, Xamarin, Universal Windows Platform and Silverlight.
Examples
PdfDocument doc = new PdfDocument();
PdfPage page = doc.Pages.Add();
PdfSolidBrush brush = new PdfSolidBrush(Color.Black);
PdfPen pen = new PdfPen(brush, 0.2f);
PdfFont font = new PdfStandardFont(PdfFontFamily.Courier, 12, PdfFontStyle.Regular);
PdfCertificate pdfCert = new PdfCertificate(@"PDF.pfx", "syncfusion");
PdfSignature signature = new PdfSignature(page, pdfCert, "Signature");
signature.Bounds = new RectangleF(new PointF(5, 5), page.Size);
signature.ContactInfo = "johndoe@owned.us";
signature.LocationInfo = "Honolulu, Hawaii";
signature.Reason = "I am author of this document.";
PdfGraphics g = signature.Appearence.Normal.Graphics;
string validto = "Issuer Name: " + signature.Certificate.IssuerName.ToString()
string validfrom = "Valid From: " + signature.Certificate.ValidFrom.ToString();
doc.Pages[0].Graphics.DrawString(validfrom, font, pen, brush, 0, 90);
doc.Pages[0].Graphics.DrawString(validto, font, pen, brush, 0, 110);
doc.Pages[0].Graphics.DrawString(" Protected Document. Digitally signed Document.", font, pen, brush, 0, 130);
doc.Pages[0].Graphics.DrawString("* To validate Signature click on the signature on this page \n * To check Document Status \n click document status icon on the bottom left of the acrobat reader.", font, pen, brush, 0, 150);
// Save the PDF file.
doc.Save("Sample.pdf");
doc.Close(true);
Dim doc As PdfDocument = New PdfDocument()
Dim page As PdfPage = doc.Pages.Add()
Dim brush As PdfSolidBrush = New PdfSolidBrush(Color.Black)
Dim pen As PdfPen = New PdfPen(brush, 0.2f)
Dim font As PdfFont = New PdfStandardFont(PdfFontFamily.Courier, 12, PdfFontStyle.Regular)
Dim pdfCert As PdfCertificate = New PdfCertificate("PDF.pfx", "syncfusion")
Dim signature As PdfSignature = New PdfSignature(page, pdfCert, "Signature")
signature.Bounds = New RectangleF(New PointF(5, 5), page.Size)
signature.ContactInfo = "johndoe@owned.us"
signature.LocationInfo = "Honolulu, Hawaii"
signature.Reason = "I am author of this document."
Dim g As PdfGraphics = signature.Appearence.Normal.Graphics
Dim validto As String = "Subject Name: " + signature.Certificate.SubjectName.ToString()
Dim validfrom As String = "Valid From: " + signature.Certificate.ValidFrom.ToString()
doc.Pages(0).Graphics.DrawString(validfrom, font, pen, brush, 0, 90)
doc.Pages(0).Graphics.DrawString(validto, font, pen, brush, 0, 110)
' Save the PDF file.
doc.Save("Sample.pdf")
doc.Close(True)
See Also
ValidFrom
Gets the date and time after which the certificate is not valid.[Read-Only]
Declaration
public DateTime ValidFrom { get; }
Property Value
Type |
---|
System.DateTime |
Remarks
This property is not supported in WinRT, Windows Phone, Xamarin, Universal Windows Platform and Silverlight.
Examples
PdfDocument doc = new PdfDocument();
PdfPage page = doc.Pages.Add();
PdfSolidBrush brush = new PdfSolidBrush(Color.Black);
PdfPen pen = new PdfPen(brush, 0.2f);
PdfFont font = new PdfStandardFont(PdfFontFamily.Courier, 12, PdfFontStyle.Regular);
PdfCertificate pdfCert = new PdfCertificate(@"PDF.pfx", "syncfusion");
PdfSignature signature = new PdfSignature(page, pdfCert, "Signature");
signature.Bounds = new RectangleF(new PointF(5, 5), page.Size);
signature.ContactInfo = "johndoe@owned.us";
signature.LocationInfo = "Honolulu, Hawaii";
signature.Reason = "I am author of this document.";
PdfGraphics g = signature.Appearence.Normal.Graphics;
string validto = "Version To: " + signature.Certificate.ValidTo.ToString()
string validfrom = "Valid From: " + signature.Certificate.ValidFrom.ToString();
doc.Pages[0].Graphics.DrawString(validfrom, font, pen, brush, 0, 90);
doc.Pages[0].Graphics.DrawString(validto, font, pen, brush, 0, 110);
doc.Pages[0].Graphics.DrawString(" Protected Document. Digitally signed Document.", font, pen, brush, 0, 130);
doc.Pages[0].Graphics.DrawString("* To validate Signature click on the signature on this page \n * To check Document Status \n click document status icon on the bottom left of the acrobat reader.", font, pen, brush, 0, 150);
// Save the PDF file.
doc.Save("Sample.pdf");
doc.Close(true);
Dim doc As PdfDocument = New PdfDocument()
Dim page As PdfPage = doc.Pages.Add()
Dim brush As PdfSolidBrush = New PdfSolidBrush(Color.Black)
Dim pen As PdfPen = New PdfPen(brush, 0.2f)
Dim font As PdfFont = New PdfStandardFont(PdfFontFamily.Courier, 12, PdfFontStyle.Regular)
Dim pdfCert As PdfCertificate = New PdfCertificate("PDF.pfx", "syncfusion")
Dim signature As PdfSignature = New PdfSignature(page, pdfCert, "Signature")
signature.Bounds = New RectangleF(New PointF(5, 5), page.Size)
signature.ContactInfo = "johndoe@owned.us"
signature.LocationInfo = "Honolulu, Hawaii"
signature.Reason = "I am author of this document."
Dim g As PdfGraphics = signature.Appearence.Normal.Graphics
Dim validto As String = "Version To: " + signature.Certificate.ValidTo.ToString()
Dim validfrom As String = "Valid From: " + signature.Certificate.ValidFrom.ToString()
doc.Pages(0).Graphics.DrawString(validfrom, font, pen, brush, 0, 90)
doc.Pages(0).Graphics.DrawString(validto, font, pen, brush, 0, 110)
doc.Pages(0).Graphics.DrawString(" Protected Document. Digitally signed Document.", font, pen, brush, 0, 130)
doc.Pages(0).Graphics.DrawString("* To validate Signature click on the signature on this page " + Constants.vbLf + " * To check Document Status " + Constants.vbLf + " click document status icon on the bottom left of the acrobat reader.", font, pen, brush, 0, 150)
' Save the PDF file.
doc.Save("Sample.pdf")
doc.Close(True)
See Also
ValidTo
Gets the date and time before which the certificate is not valid.[Read-Only]
Declaration
public DateTime ValidTo { get; }
Property Value
Type |
---|
System.DateTime |
Remarks
This property is not supported in WinRT, Windows Phone, Xamarin, Universal Windows Platform and Silverlight.
Examples
PdfDocument doc = new PdfDocument();
PdfPage page = doc.Pages.Add();
PdfSolidBrush brush = new PdfSolidBrush(Color.Black);
PdfPen pen = new PdfPen(brush, 0.2f);
PdfFont font = new PdfStandardFont(PdfFontFamily.Courier, 12, PdfFontStyle.Regular);
PdfCertificate pdfCert = new PdfCertificate(@"PDF.pfx", "syncfusion");
PdfSignature signature = new PdfSignature(page, pdfCert, "Signature");
signature.Bounds = new RectangleF(new PointF(5, 5), page.Size);
signature.ContactInfo = "johndoe@owned.us";
signature.LocationInfo = "Honolulu, Hawaii";
signature.Reason = "I am author of this document.";
PdfGraphics g = signature.Appearence.Normal.Graphics;
string validto = "Version To: " + signature.Certificate.ValidTo.ToString()
string validfrom = "Valid From: " + signature.Certificate.ValidFrom.ToString();
doc.Pages[0].Graphics.DrawString(validfrom, font, pen, brush, 0, 90);
doc.Pages[0].Graphics.DrawString(validto, font, pen, brush, 0, 110);
doc.Pages[0].Graphics.DrawString(" Protected Document. Digitally signed Document.", font, pen, brush, 0, 130);
doc.Pages[0].Graphics.DrawString("* To validate Signature click on the signature on this page \n * To check Document Status \n click document status icon on the bottom left of the acrobat reader.", font, pen, brush, 0, 150);
// Save the PDF file.
doc.Save("Sample.pdf");
doc.Close(true);
Dim doc As PdfDocument = New PdfDocument()
Dim page As PdfPage = doc.Pages.Add()
Dim brush As PdfSolidBrush = New PdfSolidBrush(Color.Black)
Dim pen As PdfPen = New PdfPen(brush, 0.2f)
Dim font As PdfFont = New PdfStandardFont(PdfFontFamily.Courier, 12, PdfFontStyle.Regular)
Dim pdfCert As PdfCertificate = New PdfCertificate("PDF.pfx", "syncfusion")
Dim signature As PdfSignature = New PdfSignature(page, pdfCert, "Signature")
signature.Bounds = New RectangleF(New PointF(5, 5), page.Size)
signature.ContactInfo = "johndoe@owned.us"
signature.LocationInfo = "Honolulu, Hawaii"
signature.Reason = "I am author of this document."
Dim g As PdfGraphics = signature.Appearence.Normal.Graphics
Dim validto As String = "Version To: " + signature.Certificate.ValidTo.ToString()
Dim validfrom As String = "Valid From: " + signature.Certificate.ValidFrom.ToString()
doc.Pages(0).Graphics.DrawString(validfrom, font, pen, brush, 0, 90)
doc.Pages(0).Graphics.DrawString(validto, font, pen, brush, 0, 110)
doc.Pages(0).Graphics.DrawString(" Protected Document. Digitally signed Document.", font, pen, brush, 0, 130)
doc.Pages(0).Graphics.DrawString("* To validate Signature click on the signature on this page " + Constants.vbLf + " * To check Document Status " + Constants.vbLf + " click document status icon on the bottom left of the acrobat reader.", font, pen, brush, 0, 150)
' Save the PDF file.
doc.Save("Sample.pdf")
doc.Close(True)
See Also
Version
Gets the certificate's version number.[Read-Only]
Declaration
public int Version { get; }
Property Value
Type |
---|
System.Int32 |
Remarks
This property is not supported in WinRT, Windows Phone, Xamarin, Universal Windows Platform and Silverlight.
Examples
PdfDocument doc = new PdfDocument();
PdfPage page = doc.Pages.Add();
PdfSolidBrush brush = new PdfSolidBrush(Color.Black);
PdfPen pen = new PdfPen(brush, 0.2f);
PdfFont font = new PdfStandardFont(PdfFontFamily.Courier, 12, PdfFontStyle.Regular);
PdfCertificate pdfCert = new PdfCertificate(@"PDF.pfx", "syncfusion");
PdfSignature signature = new PdfSignature(page, pdfCert, "Signature");
signature.Bounds = new RectangleF(new PointF(5, 5), page.Size);
signature.ContactInfo = "johndoe@owned.us";
signature.LocationInfo = "Honolulu, Hawaii";
signature.Reason = "I am author of this document.";
PdfGraphics g = signature.Appearence.Normal.Graphics;
string validto = "Version: " + signature.Certificate.Version.ToString();
string validfrom = "Valid From: " + signature.Certificate.ValidFrom.ToString();
doc.Pages[0].Graphics.DrawString(validfrom, font, pen, brush, 0, 90);
doc.Pages[0].Graphics.DrawString(validto, font, pen, brush, 0, 110);
doc.Pages[0].Graphics.DrawString(" Protected Document. Digitally signed Document.", font, pen, brush, 0, 130);
doc.Pages[0].Graphics.DrawString("* To validate Signature click on the signature on this page \n * To check Document Status \n click document status icon on the bottom left of the acrobat reader.", font, pen, brush, 0, 150);
// Save the PDF file.
doc.Save("Sample.pdf");
doc.Close(true);
Dim doc As PdfDocument = New PdfDocument()
Dim page As PdfPage = doc.Pages.Add()
Dim brush As PdfSolidBrush = New PdfSolidBrush(Color.Black)
Dim pen As PdfPen = New PdfPen(brush, 0.2f)
Dim font As PdfFont = New PdfStandardFont(PdfFontFamily.Courier, 12, PdfFontStyle.Regular)
Dim pdfCert As PdfCertificate = New PdfCertificate("PDF.pfx", "syncfusion")
Dim signature As PdfSignature = New PdfSignature(page, pdfCert, "Signature")
signature.Bounds = New RectangleF(New PointF(5, 5), page.Size)
signature.ContactInfo = "johndoe@owned.us"
signature.LocationInfo = "Honolulu, Hawaii"
signature.Reason = "I am author of this document."
Dim g As PdfGraphics = signature.Appearence.Normal.Graphics
Dim validto As String = "Version: " + signature.Certificate.Version.ToString()
Dim validfrom As String = "Valid From: " + signature.Certificate.ValidFrom.ToString()
doc.Pages(0).Graphics.DrawString(validfrom, font, pen, brush, 0, 90)
doc.Pages(0).Graphics.DrawString(validto, font, pen, brush, 0, 110)
doc.Pages(0).Graphics.DrawString(" Protected Document. Digitally signed Document.", font, pen, brush, 0, 130)
doc.Pages(0).Graphics.DrawString("* To validate Signature click on the signature on this page" + vbCrLf + " * To check Document Status" + vbCrLf + " click document status icon on the bottom left of the acrobat reader.", font, pen, brush, 0, 150)
' Save the PDF file.
doc.Save("Sample.pdf")
doc.Close(True)
See Also
Methods
FindByIssuer(StoreType, String)
Finds the certificate by issuer.
Declaration
public static PdfCertificate FindByIssuer(StoreType type, string issuer)
Parameters
Type | Name | Description |
---|---|---|
StoreType | type | The certification system store type. |
System.String | issuer | The issuer. |
Returns
Type |
---|
PdfCertificate |
Remarks
This method is not supported in WinRT, Windows Phone, Xamarin, Universal Windows Platform and Silverlight.
Examples
PdfDocument doc = new PdfDocument();
PdfPage page = doc.Pages.Add();
PdfSolidBrush brush = new PdfSolidBrush(Color.Black);
PdfPen pen = new PdfPen(brush, 0.2f);
PdfFont font = new PdfStandardFont(PdfFontFamily.Courier, 12, PdfFontStyle.Regular);
PdfCertificate pdfCert = PdfCertificate.FindByIssuer(StoreType.ROOT, "syncfusion");
PdfSignature signature = new PdfSignature(page, pdfCert, "Signature");
signature.Bounds = new RectangleF(new PointF(5, 5), page.Size);
signature.ContactInfo = "johndoe@owned.us";
signature.LocationInfo = "Honolulu, Hawaii";
signature.Reason = "I am author of this document.";
PdfGraphics g = signature.Appearence.Normal.Graphics;
string validto = "Version To: " + signature.Certificate.ValidTo.ToString()
string validfrom = "Valid From: " + signature.Certificate.ValidFrom.ToString();
doc.Pages[0].Graphics.DrawString(validfrom, font, pen, brush, 0, 90);
doc.Pages[0].Graphics.DrawString(validto, font, pen, brush, 0, 110);
doc.Pages[0].Graphics.DrawString(" Protected Document. Digitally signed Document.", font, pen, brush, 0, 130);
doc.Pages[0].Graphics.DrawString("* To validate Signature click on the signature on this page \n * To check Document Status \n click document status icon on the bottom left of the acrobat reader.", font, pen, brush, 0, 150);
// Save the PDF file.
doc.Save("Sample.pdf");
doc.Close(true);
Dim doc As PdfDocument = New PdfDocument()
Dim page As PdfPage = doc.Pages.Add()
Dim brush As PdfSolidBrush = New PdfSolidBrush(Color.Black)
Dim pen As PdfPen = New PdfPen(brush, 0.2f)
Dim font As PdfFont = New PdfStandardFont(PdfFontFamily.Courier, 12, PdfFontStyle.Regular)
Dim pdfCert As PdfCertificate = PdfCertificate.FindByIssuer(StoreType.ROOT, "syncfusion")
Dim signature As New PdfSignature(page, pdfCert, "Signature")
signature.Bounds = New RectangleF(New PointF(5, 5), page.Size)
signature.ContactInfo = "johndoe@owned.us"
signature.LocationInfo = "Honolulu, Hawaii"
signature.Reason = "I am author of this document."
Dim g As PdfGraphics = signature.Appearence.Normal.Graphics
Dim validto As String = "Version To: " + signature.Certificate.ValidTo.ToString()
Dim validfrom As String = "Valid From: " + signature.Certificate.ValidFrom.ToString()
doc.Pages(0).Graphics.DrawString(validfrom, font, pen, brush, 0, 90)
doc.Pages(0).Graphics.DrawString(validto, font, pen, brush, 0, 110)
doc.Pages(0).Graphics.DrawString(" Protected Document. Digitally signed Document.", font, pen, brush, 0, 130)
doc.Pages(0).Graphics.DrawString("* To validate Signature click on the signature on this page " + Constants.vbLf + " * To check Document Status " + Constants.vbLf + " click document status icon on the bottom left of the acrobat reader.", font, pen, brush, 0, 150)
' Save the PDF file.
doc.Save("Sample.pdf")
doc.Close(True)
FindBySerialId(StoreType, Byte[])
Finds the certificate by serial number.
Declaration
public static PdfCertificate FindBySerialId(StoreType type, byte[] certificateID)
Parameters
Type | Name | Description |
---|---|---|
StoreType | type | The certification system store type. |
System.Byte[] | certificateID | The certificate id. |
Returns
Type | Description |
---|---|
PdfCertificate | PDF certificate instance. |
Remarks
This method is not supported in WinRT, Windows Phone, Xamarin, Universal Windows Platform and Silverlight.
Examples
// Creates a new document
PdfDocument document = new PdfDocument();
//Creates a new page and adds it as the last page of the document
PdfPage page = document.Pages.Add();
//Load an existing PDF certificate.
PdfCertificate certificate = new PdfCertificate("certificate.Pfx", "password");
//Get the serial number of the certificate.
byte[] data = certificate.SerialNumber;
//Get the store certificate.
PdfCertificate storeCertificate = PdfCertificate.FindBySerialId(StoreType.MY, data);
//Creates a digital signature.
PdfSignature signature = new PdfSignature(document, page, storeCertificate, "Signature");
signature.Bounds = new RectangleF(new PointF(0, 0), new SizeF(100, 100));
signature.ContactInfo = "johndoe@owned.us";
signature.LocationInfo = "Honolulu, Hawaii";
signature.Reason = "I am author of this document.";
//Save the document.
document.Save("output.pdf");
//Close the document.
document.Close(true);
' Creates a new document
Dim document As New PdfDocument()
'Creates a new page and adds it as the last page of the document
Dim page As PdfPage = document.Pages.Add()
'Load an existing PDF certificate.
Dim certificate As New PdfCertificate("certificate.Pfx", "password")
'Get the serial number of the certificate.
Dim data As Byte() = certificate.SerialNumber
'Get the store certificate.
Dim storeCertificate As PdfCertificate = PdfCertificate.FindBySerialId(StoreType.MY, data)
'Creates a digital signature.
Dim signature As New PdfSignature(document, page, storeCertificate, "Signature")
signature.Bounds = New RectangleF(New PointF(0, 0), New SizeF(100, 100))
signature.ContactInfo = "johndoe@owned.us"
signature.LocationInfo = "Honolulu, Hawaii"
signature.Reason = "I am author of this document."
'Save the document.
document.Save("output.pdf")
'Close the document.
document.Close(True)
FindBySubject(StoreType, String)
Finds the certificate by subject.
Declaration
public static PdfCertificate FindBySubject(StoreType type, string subject)
Parameters
Type | Name | Description |
---|---|---|
StoreType | type | The store type. |
System.String | subject | The certificate subject. |
Returns
Type | Description |
---|---|
PdfCertificate | Returns the PdfCertificate instance. |
Remarks
This method is not supported in WinRT, Windows Phone, Xamarin, Universal Windows Platform and Silverlight.
Examples
// Creates a new document
PdfDocument document = new PdfDocument();
//Creates a new page and adds it as the last page of the document
PdfPage page = document.Pages.Add();
//Find by subject.
PdfCertificate storeCertificate = PdfCertificate.FindBySubject(StoreType.MY, "syncfusion");
//Creates a signature.
PdfSignature signature = new PdfSignature(document, page, storeCertificate, "Signature");
signature.Bounds = new RectangleF(new PointF(0, 0), new SizeF(100, 100));
signature.ContactInfo = "johndoe@owned.us";
signature.LocationInfo = "Honolulu, Hawaii";
signature.Reason = "I am author of this document.";
//Save the document.
document.Save("output.pdf");
//Close the document.
document.Close(true);
' Creates a new document
Dim document As New PdfDocument()
'Creates a new page and adds it as the last page of the document
Dim page As PdfPage = document.Pages.Add()
'Find by subject.
Dim storeCertificate As PdfCertificate = PdfCertificate.FindBySubject(StoreType.MY, "syncfusion")
'Creates a signature.
Dim signature As New PdfSignature(document, page, storeCertificate, "Signature")
signature.Bounds = New RectangleF(New PointF(0, 0), New SizeF(100, 100))
signature.ContactInfo = "johndoe@owned.us"
signature.LocationInfo = "Honolulu, Hawaii"
signature.Reason = "I am author of this document."
'Save the document.
document.Save("output.pdf")
'Close the document.
document.Close(True)
FindBySubject(StoreType, String, StoreRegion)
Finds the certificate by subject
Declaration
public static PdfCertificate FindBySubject(StoreType type, string subject, StoreRegion storeRegion)
Parameters
Type | Name | Description |
---|---|---|
StoreType | type | The Store type |
System.String | subject | Certificate subject |
StoreRegion | storeRegion | The Certificate store Location |
Returns
Type | Description |
---|---|
PdfCertificate | Returns the PdfCertificate instance. |
Examples
// Creates a new document
PdfDocument document = new PdfDocument();
//Creates a new page and adds it as the last page of the document
PdfPage page = document.Pages.Add();
//Find by subject.
PdfCertificate storeCertificate = PdfCertificate.FindBySubject(StoreType.MY, "syncfusion", StoreRegion.LocalMachine);
//Creates a signature.
PdfSignature signature = new PdfSignature(document, page, storeCertificate, "Signature");
signature.Bounds = new RectangleF(new PointF(0, 0), new SizeF(100, 100));
signature.ContactInfo = "johndoe@owned.us";
signature.LocationInfo = "Honolulu, Hawaii";
signature.Reason = "I am author of this document.";
//Save the document.
document.Save("output.pdf");
//Close the document.
document.Close(true);
' Creates a new document
Dim document As New PdfDocument()
'Creates a new page and adds it as the last page of the document
Dim page As PdfPage = document.Pages.Add()
'Find by subject.
Dim storeCertificate As PdfCertificate = PdfCertificate.FindBySubject(StoreType.MY, "syncfusion", StoreRegion.LocalMachine)
'Creates a signature.
Dim signature As New PdfSignature(document, page, storeCertificate, "Signature")
signature.Bounds = New RectangleF(New PointF(0, 0), New SizeF(100, 100))
signature.ContactInfo = "johndoe@owned.us"
signature.LocationInfo = "Honolulu, Hawaii"
signature.Reason = "I am author of this document."
'Save the document.
document.Save("output.pdf")
'Close the document.
document.Close(True)
GetCertificates()
Gets the certificates in all storages.
Declaration
public static PdfCertificate[] GetCertificates()
Returns
Type | Description |
---|---|
PdfCertificate[] | PdfCertificate array. |
Remarks
This method is not supported in WinRT, Windows Phone, Xamarin, Universal Windows Platform and Silverlight.
Examples
PdfDocument doc = new PdfDocument();
PdfPage page = doc.Pages.Add();
PdfSolidBrush brush = new PdfSolidBrush(Color.Black);
PdfPen pen = new PdfPen(brush, 0.2f);
PdfFont font = new PdfStandardFont(PdfFontFamily.Courier, 12, PdfFontStyle.Regular);
PdfCertificate[] pdfCert = GetCertificates();
PdfSignature signature = new PdfSignature(page, pdfCert[0], "Signature");
signature.Bounds = new RectangleF(new PointF(5, 5), page.Size);
signature.ContactInfo = "johndoe@owned.us";
signature.LocationInfo = "Honolulu, Hawaii";
signature.Reason = "I am author of this document.";
PdfGraphics g = signature.Appearence.Normal.Graphics;
string validto = "Version To: " + signature.Certificate.ValidTo.ToString()
string validfrom = "Valid From: " + signature.Certificate.ValidFrom.ToString();
doc.Pages[0].Graphics.DrawString(validfrom, font, pen, brush, 0, 90);
doc.Pages[0].Graphics.DrawString(validto, font, pen, brush, 0, 110);
doc.Pages[0].Graphics.DrawString(" Protected Document. Digitally signed Document.", font, pen, brush, 0, 130);
doc.Pages[0].Graphics.DrawString("* To validate Signature click on the signature on this page \n * To check Document Status \n click document status icon on the bottom left of the acrobat reader.", font, pen, brush, 0, 150);
// Save the PDF file.
doc.Save("Sample.pdf");
doc.Close(true);
Dim doc As PdfDocument = New PdfDocument()
Dim page As PdfPage = doc.Pages.Add()
Dim brush As PdfSolidBrush = New PdfSolidBrush(Color.Black)
Dim pen As PdfPen = New PdfPen(brush, 0.2f)
Dim font As PdfFont = New PdfStandardFont(PdfFontFamily.Courier, 12, PdfFontStyle.Regular)
Dim pdfCert As PdfCertificate() = GetCertificates()
Dim signature As New PdfSignature(page, pdfCert(0), "Signature")
signature.Bounds = New RectangleF(New PointF(5, 5), page.Size)
signature.ContactInfo = "johndoe@owned.us"
signature.LocationInfo = "Honolulu, Hawaii"
signature.Reason = "I am author of this document."
Dim g As PdfGraphics = signature.Appearence.Normal.Graphics
Dim validto As String = "Version To: " + signature.Certificate.ValidTo.ToString()
Dim validfrom As String = "Valid From: " + signature.Certificate.ValidFrom.ToString()
doc.Pages(0).Graphics.DrawString(validfrom, font, pen, brush, 0, 90)
doc.Pages(0).Graphics.DrawString(validto, font, pen, brush, 0, 110)
doc.Pages(0).Graphics.DrawString(" Protected Document. Digitally signed Document.", font, pen, brush, 0, 130)
doc.Pages(0).Graphics.DrawString("* To validate Signature click on the signature on this page " + Constants.vbLf + " * To check Document Status " + Constants.vbLf + " click document status icon on the bottom left of the acrobat reader.", font, pen, brush, 0, 150)
' Save the PDF file.
doc.Save("Sample.pdf")
doc.Close(True)
GetValue(String, PdfCertificateField)
Declaration
public string GetValue(string pdfCertificateDistinguishedName, PdfCertificateField field)
Parameters
Type | Name | Description |
---|---|---|
System.String | pdfCertificateDistinguishedName | |
PdfCertificateField | field |
Returns
Type |
---|
System.String |