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
Declaration
public string IssuerName { get; }
Property Value
Type | Description |
---|---|
System.String |
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
Declaration
public string SubjectName { get; }
Property Value
Type | Description |
---|---|
System.String |
ValidFrom
Declaration
public DateTime ValidFrom { get; }
Property Value
Type | Description |
---|---|
System.DateTime |
ValidTo
Declaration
public DateTime ValidTo { get; }
Property Value
Type | Description |
---|---|
System.DateTime |
Version
Declaration
public int Version { get; }
Property Value
Type | Description |
---|---|
System.Int32 |
Methods
FindByIssuer(StoreType, String)
Declaration
public static PdfCertificate FindByIssuer(StoreType type, string issuer)
Parameters
Type | Name | Description |
---|---|---|
StoreType | type | |
System.String | issuer |
Returns
Type | Description |
---|---|
PdfCertificate |
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()
Declaration
public static PdfCertificate[] GetCertificates()
Returns
Type | Description |
---|---|
PdfCertificate[] |
GetValue(String, PdfCertificateField)
Declaration
public string GetValue(string pdfCertificateDistinguishedName, PdfCertificateField field)
Parameters
Type | Name | Description |
---|---|---|
System.String | pdfCertificateDistinguishedName | |
PdfCertificateField | field |
Returns
Type | Description |
---|---|
System.String |