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(Signaturesignature=newSignature("sample.pdf")){QrCodeSearchOptionsoptions=newQrCodeSearchOptions(){// specify special pages to search onAllPages=false,PageNumber=1,PagesSetup=newPagesSetup(){FirstPage=true,LastPage=true,OddPages=false,EvenPages=false},// specify special QRCode type to searchEncodeType=QrCodeTypes.Aztec,// specify text match typeMatchType=TextMatchType.Contains,// specify text pattern to searchText="John",// set field for QRCode images returningReturnContent=true,// specify type of returned QRCode imagesReturnContentType=FileType.PNG};// search for signatures in documentList<QrCodeSignature>signatures=signature.Search<QrCodeSignature>(options);//For evaluation version is 0Console.WriteLine("\nSource document contains following signatures.");foreach(QrCodeSignatureqrCodeSignatureinsignatures){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 imagesstringoutputPath=System.IO.Path.Combine(Constants.OutputPath,"SearchForQRCodeAdvanced");if(!Directory.Exists(outputPath)){Directory.CreateDirectory(outputPath);}inti=0;foreach(QrCodeSignatureqrCodeSignatureinsignatures){stringoutputFilePath=System.IO.Path.Combine(outputPath,$"image{i}{qrCodeSignature.Format.Extension}");using(FileStreamfs=newFileStream(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: