Digitally Sign PDF with QR Code in C#

Digitally Sign PDF with QR Code in C#

In the modern era, the digitally signed PDFs with QR code have become more secure and quickly verifiable for automated digital processing systems. Another good reason to use QR codes is that they are capable of containing a lot of useful information. If you are keen to learn how to eSign PDF files with QR code in C#, you have landed at the right place.

The following points will be covered in this article:

C# Library to Digitally Sign PDF with QR Code

You can download the DLL or install it by running the command (as given below) in the NuGet package manager console.

Install-Package GroupDocs.Signature

Steps to Digitally Sign PDF with QR Code in C#

After installation, let’s start to write a few lines of code.

Please follow the steps and the code snippet mentioned below:

  1. Instantiate the Signature class and pass the source document’s path as a constructor parameter.
  2. Initialize an instance of QrCodeSignOptions class and set EncodeType and Text properties.
  3. Invoke Sign method of Signature class and pass output file’s path and QrCodeSignOptions to it.

You can simply copy & paste the following code sample into your C# file:

The output can be seen in the image below:

QR Code Sign

eSign PDF with QR code in C# - Advanced Options

PDF eSign library provides some additional useful options in QrCodeSignOptions class. You can use this class to specify signature alignment, margins, borders, font, colors, and background. Moreover, you can verify the results of a newly created signature by using SignResult class.

Following are the steps to create QR Code with advanced options:

  1. Initialize a new instance of the Signature class by providing the source document’s path as a constructor parameter.
  2. Instantiate an instance of the QrCodeSignOptions class.
  3. Set the signature’s text and encoding type.
  4. Set the signature’s position.
  5. Specify the signature’s alignment, margins, borders, font, colors, and background.
  6. Invoke Sign method of Signature class and pass output file’s path and QrCodeSignOptions to it.
  7. Optionally you can obtain SignResult object to analyze or verify the newly created signatures.

The following C# code shows how to sign a PDF with QR code using advanced options:

You will get the output as seen in the image below:

eSign PDF

Get a Free License

You can avail a free temporary license to test the API without evaluation limitations.

Conclusion

In this article, we have learned how to Digitally Sign PDF with QR Code in C# using an electronic signature library. Besides, you also have gained knowledge about some advanced options to add the QR Code Sign in your PDF documents. You may visit the documentation to know about other features of the digital signature library.

Additionally, we suggest you to follow our Getting Started guide.

Ask a question

You can let us know about your questions or queries on our forum.

See Also