Iterate through the collection and get a barcode value.
The following example shows how to extract barcodes from a document page:
// 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;}// Extract barcodes from the second document page.
Iterable<PageBarcodeArea>barcodes=parser.getBarcodes(1);// 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: