This method returns a Java Iterable collection of PageBarcodeArea objects:
Member
Description
getPage()
The page that contains the barcode.
getRectangle()
The rectangular area on the page that contains the barcode.
getValue()
A string value that represents a value of the barcode page area.
getCodeTypeName()
A string value that represents a type name of the barcode.
Here are the steps to extract barcodes from a page area:
Instantiate the Parser object for the initial document;
Check if the document supports barcodes extraction;
Instantiate PageAreaOptions with the rectangular area;
Call the getBarcodes(PageAreaOptions) method and obtain the collection of PageBarcodeArea objects;
Iterate through the collection and get a barcode value.
The following example shows how to extract barcodes from the upper part of the pages (the area that contains QR codes in Barcodes.pdf):
constgroupdocs=require('@groupdocs/groupdocs.parser');// Create an instance of Parser class
constparser=newgroupdocs.Parser('Barcodes.pdf');try{// Check if the document supports barcodes extraction
if(!parser.getFeatures().isBarcodes()){console.log("Document doesn't support barcodes extraction.");}else{// Create the options which are used for barcodes extraction
constoptions=newgroupdocs.PageAreaOptions(newgroupdocs.Rectangle(newgroupdocs.Point(400,50),newgroupdocs.Size(200,150)));// Extract barcodes from the page area
constit=parser.getBarcodes(options).iterator();// Iterate over barcodes
while(it.hasNext()){constbarcode=it.next();// Print the page index
console.log('Page: '+barcode.getPage().getIndex());// Print the barcode value
console.log('Value: '+barcode.getValue());}}}finally{parser.close();}process.exit(0);
Only barcodes that lie inside the rectangle are returned. Use barcode.getRectangle() from the Extract barcodes from document example to find the barcode coordinates in your document.
More resources
Free online document parser App
Along with the full-featured library we provide simple but powerful free Apps.
You are welcome to extract data from PDF, DOC, DOCX, PPT, PPTX, XLS, XLSX, Emails and more with our Free Online Document Parser App.
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.