Iterate through the collection and get a barcode value.
The following example shows how to extract barcodes from the upper-right corner:
// Create an instance of Parser class
try(Parserparser=newParser(Constants.SamplePdfWithBarcodes)){// Check if the document supports barcodes extraction
if(!parser.getFeatures().isBarcodes()){System.out.println("Document doesn't support barcodes extraction.");return;}// Create the options which are used for barcodes extraction
PageAreaOptionsoptions=newPageAreaOptions(newRectangle(newPoint(590,80),newSize(150,150)));// Extract barcodes from the upper-right corner.
Iterable<PageBarcodeArea>barcodes=parser.getBarcodes(options);// Iterate over barcodes
for(PageBarcodeAreabarcode:barcodes){// Print the page index
System.out.println("Page: "+barcode.getPage().getIndex());// Print the barcode value
System.out.println("Value: "+barcode.getValue());}}
More resources
GitHub examples
You may easily run the code above and see the feature in action in our GitHub examples: