GroupDocs.Parser for Java allows to scan QR Codes from PDF, MS Word (DOC, DOCX), MS PowerPoint (PPT, PPTX), LibreOffice formats, images and many others (see full list at supported document formats article).
GroupDocs.Parser’s QR Code scanner is easy to use and powerful at the same time. Its algorithms allow to read even damaged barcodes.
This article demonstrates how to implement QR Code reader for any supported format.
Iterate through the collection and get a QR Code value.
The following example shows how to scan QR Codes:
// Create an instance of Parser class
try(Parserparser=newParser(Constants.SamplePdfWithBarcodes)){// Check if the file supports barcodes extraction
if(!parser.getFeatures().isBarcodes()){System.out.println("The file doesn't support barcodes extraction.");return;}// Create the options to scan barcodes with "QR" type only
BarcodeOptionsoptions=newBarcodeOptions(QualityMode.Low,QualityMode.Low,"QR");// Scan QR Codes from the file
Iterable<PageBarcodeArea>qrcodes=parser.getBarcodes(options);// Iterate over QR Codes
for(PageBarcodeAreaqrcode:qrcodes){// Print the page index
System.out.println("Page: "+qrcode.getPage().getIndex());// Print the QR Code value
System.out.println("Value: "+qrcode.getValue());}}
Alternatively, scan all barcodes with getBarcodes() and keep the ones whose getCodeTypeName method returns "QR":
// Iterate over all barcodes
for(PageBarcodeAreabarcode:parser.getBarcodes()){// Skip barcodes of other types
if(!"QR".equals(barcode.getCodeTypeName())){continue;}// Print the QR Code value
System.out.println("Value: "+barcode.getValue());}