Advanced search for QR Code signatures

GroupDocs.SignatureΒ providesΒ QrCodeSearchOptionsΒ classΒ to specify different options to search for QR-code signatures.

Here are the steps to search for barcode signatures within the document with GroupDocs.Signature:

This example shows how to make advanced search for QR-code signature in the document with enabled options of grabbing QR-code image content.

using (Signature signature = new Signature("sample.pdf"))
{
    QrCodeSearchOptions options = new QrCodeSearchOptions()
    {
        // specify special pages to search on
        AllPages = false,
        PageNumber = 1,
        PagesSetup = new PagesSetup() { FirstPage = true, LastPage = true, OddPages = false, EvenPages = false },
        // specify special QRCode type to search
        EncodeType = QrCodeTypes.Aztec,
        // specify text match type
        MatchType = TextMatchType.Contains,
        // specify text pattern to search
        Text = "John",
        // set field for QRCode images returning
        ReturnContent = true,
        // specify type of returned QRCode images
        ReturnContentType = FileType.PNG
    };
    // search for signatures in document
    List<QrCodeSignature> signatures = signature.Search<QrCodeSignature>(options); //For evaluation version is 0
    Console.WriteLine("\nSource document contains following signatures.");
    foreach (QrCodeSignature qrCodeSignature in signatures)
    {
        Console.WriteLine("QRCode signature found at page {0} with type {1} and text {2}", qrCodeSignature.PageNumber, qrCodeSignature.EncodeType, qrCodeSignature.Text);
        Console.WriteLine("QRCode signature size {0} and format {1}", qrCodeSignature.Content?.Length, qrCodeSignature.Format);
        Console.WriteLine($"Location at {qrCodeSignature.Left}-{qrCodeSignature.Top}. Size is {qrCodeSignature.Width}x{qrCodeSignature.Height}.");
    }
    //Save QRCode images
    string outputPath = System.IO.Path.Combine(Constants.OutputPath, "SearchForQRCodeAdvanced");
    if (!Directory.Exists(outputPath))
    {
        Directory.CreateDirectory(outputPath);
    }
    int i = 0;
    foreach (QrCodeSignature qrCodeSignature in signatures)
    {
        string outputFilePath = System.IO.Path.Combine(outputPath, $"image{i}{qrCodeSignature.Format.Extension}");
        using (FileStream fs = new FileStream(outputFilePath, FileMode.Create))
        {
            fs.Write(qrCodeSignature.Content, 0, qrCodeSignature.Content.Length);
        }
        i++;
    }
}

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 sign PDF, Word, Excel, PowerPoint, and other documents you can use the online apps from the GroupDocs.Signature App Product Family.