Sign document with Swiss QR Barcode signature

GroupDocs.Signatureย providesย SwissQRย classย to create Swiss QR. The Swiss QR Barcode is used mostly in the QR-bill, which is a document designed to replace the payment slips and currently used in payment transactions in Switzerland.

Here are the steps how to add Swiss QR signature into document with GroupDocs.Signature:

  • Create new instance ofย Signatureย class and pass source document path as a constructor parameter.
  • Instantiate theย ย SwissQRย object with all required additional options.
  • Instantiate theย ย QrCodeSignOptionsย object with all required additional options and set SwissQR object into Data property.
  • Callย Signย method ofย Signatureย class instance and passย QrCodeSignOptionsย to it.
  • Analyzeย SignResultย result to check newly created signatures if needed.
using (Signature signature = new Signature(filePath))
{
    // create SwissQR data object
    var swissQR = new SwissQR()
    {
        Account = "CH4431999123000889012",
        Amount = 1000.25m,
        Currency = "CHF",
        Reference = "210000000003139471430009017",
        Creditor = new SwissAddress
        {
            Name = "Muster & Sรถhne",
            Street = "Musterstrasse",
            HouseNo = "12b",
            PostalCode = "8200",
            Town = "Zรผrich",
            CountryCode = "CH"
        },

        Debtor = new SwissAddress
        {
            Name = "Muster AG",
            Street = "Musterstrasse",
            HouseNo = "1",
            PostalCode = "3030",
            Town = "Bern",
            CountryCode = "CH"
        }
    };

    // create options
    QrCodeSignOptions options = new QrCodeSignOptions
    {
        EncodeType = QrCodeTypes.QR,
        Left = 100,
        Top = 100,
        // setup Data property to SwissQR instance
        Data = swissQR
    };

    // sign document to file
    var signResult = signature.Sign(outputFilePath, options);
            
    // analyzing result
    Console.WriteLine("List of newly created signatures:");
    int number = 1;
    foreach (BaseSignature temp in signResult.Succeeded)
    {
        Console.WriteLine($"Signature #{number++}: Type: {temp.SignatureType} Id:{temp.SignatureId}, Location: {temp.Left}x{temp.Top}. Size: {temp.Width}x{temp.Height}");
    }
ย }

More resources

GitHub Examples

You may easily run the code above and see the feature in action in ourย GitHub examples:

Free Online Apps

Along with the full-featured .NET library, we provide simple but powerful free online apps.

To generate QR codes and/or sign your files with QR codes for free, you can use the QR Code Generator online app.

To sign PDF, Word, Excel, PowerPoint, and other documents you can use the other online apps from the GroupDocs.Signature App Product Family.