eSign Documents and Images with QR Code using C#

In the last post, we discussed attaching QR codes with documents and images using Java. However, today this article will look, how to programmatically add QR codes to electronically sign documents and images using C#.

Add QR Code to documents and images in CSharp .NET

The following topics will be converted in this article:

.NET API for QR Codes

GroupDocs.Signature for .NET

GroupDocs.Signature for .NET is the API to add QR codes in PDF files, word processing documents, spreadsheets, presentations, and images. It supports various electronic signatures for a large list of supported file formats. There are different types of QR codes. The API supports Aztec Code, DataMatrix Code, GS1 DataMatrix, GS1 QR, QR types.

In the examples below, I will be using this API, so I would recommend you to either install it from the NuGet package manager or get the MSI installer, and DLLs from the downloads section. You may also use the following command in your Package Manager Console.

PM> Install-Package GroupDocs.Signature

For the details, you may visit the API Reference.

Add QR Code to PDF, Word, Excel, PPT in C#

The Signature and QrCodeSignOptions classes help to quickly add different types of QR codes to documents and images within .NET application. The following steps show how to add QR code in a PDF document using C#:

  1. Initialize the Signature class object with the source document.
  2. Set the QR code properties using the QrCodeSignOptions class.
  3. Most importantly, select the appropriate from the available QR code types. (Aztec, DataMatrix, GS1 DataMatrix, GS1 QR, QR)
  4. Call the Sign method, passing the resultant document path and QR code options.

The following C# code implements the above steps. Similarly, you can provide a word document, spreadsheet, presentation, or any other supported document format to attach the QR codes.

This is the PDF file with QR code as an output of the above code.

QR Code added to PDF using Signature API
PDF file with added QR code using GroupDocs.Signature for .NET API

Add QR Code to JPG, PNG, or WebP Images in C#

Image with QR Code

We can use the same above code to add QR codes to the images as well. The API allows us to add QR codes to JPG/JPEG, PNG, WebP, BMP, GIF, SVG, CMX, and TIFF images and some more image file formats as well.

We can also change the background color, forecolor, transparency, and some more properties to alter the appearance of the QR codes. The below code changes the background color to black and sets the forecolor to white.

// Change Appearance of QR code.
// Setting background color, forecolor, transparency, etc.)
Background = new Background()
{
    Color = Color.Black,
    Transparency = 0.5
},
//set text color and Font
ForeColor = Color.White

Conclusion

I believe, now you can easily add QR codes to sign your documents and images electronically with C# using GroupDocs.Signature for .NET. You can change the appearance of the QR codes that suits your brand.

See Also