GroupDocs.Parser for Java allows to scan barcodes from PDF, Microsoft Office formats: Word (DOC, DOCX), PowerPoint (PPT, PPTX), LibreOffice formats, images and many others (see full list at supported document formats article).
GroupDocs.Parser’s barcode 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 the simplest scenario - read barcodes from any supported format without additional settings (to resolve complex scenarios see advanced usage section).
How to scan barcode in Java with GroupDocs.Parser
To scan barcodes from your file, simply call getBarcodes method:
Iterable<PageBarcodeArea>getBarcodes()
This method returns a collection of PageBarcodeArea objects.
Here are the steps to extract barcodes from a file:
Iterate through the collection and get a barcode value.
The following example shows how to scan barcodes:
// 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;}// Scan barcodes from the file
Iterable<PageBarcodeArea>barcodes=parser.getBarcodes();// Iterate over barcodes
for(PageBarcodeAreabarcode:barcodes){// Print the page index
System.out.println("Page: "+barcode.getPage().getIndex());// Print the barcode type and value
System.out.println(barcode.getCodeTypeName()+": "+barcode.getValue());}}
Along with full featured Java library we provide simple, but powerful free Apps.
You are welcome to scan barcode from your files or mobile phone camera with our free online GroupDocs Scanner App which is built with GroupDocs.Parser.
Was this page helpful?
Any additional feedback you'd like to share with us?
Please tell us how we can improve this page.
Thank you for your feedback!
We value your opinion. Your feedback will help us improve our documentation.
On this page
Analyzing your prompt, please hold on...
An error occurred while retrieving the results. Please refresh the page and try again.