Credit portal




How to Create Digital Certificate in PDF – C#/Vb.NET

how to create certificate in word

In order to verify our own identify or distinguish others’ identify online, Certificate Authority published digital certificate, which includes a public key, information key owner. Digital certificate plays a very important role when delivering information online. It can protect security of personal account, password and other important information when we trade with others online. In this post, I will show the method about how to create digital certificate in a PDF document with C# and VB.NET.

In my example, I prepare a certificate, which is not an official certificate but a simple one for example.

Now, let’s follow the steps to create PDF digital certificate.

At the beginning, I add Spire.PDF dll file as reference because I will use this third-party component in my method.

  1. Create a PDF document and add one page. Because I just want to show an example, so I don’t draw any contents on this blank page.
  2. Create certificate and signature. Firstly. declare a string pfxPath and assign certificate as value to it. Secondly.

    create certificate. It should include two parameters, pfxPath and a password. Thirdly. add signature. There are four parameters, PDF document, page, certificate and signature name.  Finally. set other information, including contact information, document permission.

  3. Save and launch file.

Main Coding:

using System;

using Spire.Pdf;

using Spire.Pdf.Security;

namespace DigitalCertificate

static void Main( string [] args)

//Create Document and Add Page

PdfNewDocument doc = new PdfNewDocument ();

PdfPageBase page = doc.Pages.Add();

//Create Certificate and Signature

String pfxPath = @”D:\work\My Documents\Certificate.pfx” ;

PdfCertificate cert = new PdfCertificate (pfxPath, “e-iceblue” );

Imports Spire.Pdf

Imports Spire.Pdf.Security

Namespace DigitalCertificate

Friend Class Certificate

Shared Sub Main( ByVal args() As String )

‘Create Document and Add Page

Dim doc As New PdfNewDocument()

Dim page As PdfPageBase = doc.Pages.Add()

‘Create Certificate and Signature

Dim pfxPath As String = “D:\work\My Documents\Certificate.pfx”

Dim cert As New PdfCertificate(pfxPath, “e-iceblue” )

Dim signature As New PdfSignature(doc, page, cert, “Certificate” )

Category: Insurance

Similar articles: