Power Community

Power Community

Using Forms Recognizer to Extract Bar Code Information

A brief guide on how to use the Azure service to read bar codes from scanned documents.

Forms recognizer is a cognitive service that uses machine learning to analyze and extract data from forms and documents. It can handle various types of documents, such as invoices, receipts, business cards, and identity documents. One of the features of forms recognizer is that it can read bar codes from scanned documents and extract the encoded information.

I’ll provide a summary of how to use forms recognizer to extract bar code information from scanned documents. It will cover the following topics:

  • What are bar codes and how are they used?
  • What are the types of bar codes that forms recognizer can read?
  • How to use the forms recognizer API to extract bar code information?
  • How to use the forms recognizer portal to test and train models for bar code extraction?

A bar code is a machine-readable representation of data that consists of a series of parallel lines or dots of varying widths or colors. Bar codes are used to store information such as product codes, serial numbers, dates, and prices. Bar codes can be scanned by optical devices, such as bar code readers, cameras, or smartphones, to retrieve the encoded information.

Bar codes are widely used in various industries and applications, such as retail, logistics, manufacturing, health care, and identification. For example, bar codes can be used to track inventory, manage shipments, verify prescriptions, and authenticate documents.

Forms recognizer can read the following types of bar codes from scanned documents:

  • One-dimensional (1D) bar codes: These are linear bar codes that consist of a series of vertical lines or bars of varying widths. Examples of 1D bar codes are Code 39, Code 128, EAN-13, and UPC-A.
  • Two-dimensional (2D) bar codes: These are matrix bar codes that consist of a grid of dots or squares of varying sizes or colors. Examples of 2D bar codes are QR code, Data Matrix, and PDF417.

Forms recognizer can extract the text value of the bar code, as well as the type and the page number of the document where the bar code is located.

To use the forms recognizer API to extract bar code information from scanned documents, you need to follow these steps:

Create a forms recognizer resource in Azure

Once you have created a new Resource Group in Azure, Create a new Forms Recognizer resource.

















Once the resource has been created, navigate to the Keys and Endpoints.  You will need one of the keys to process the document and retrieve the barcode value.

















Configure Power Automate

Prepare your scanned documents. You can use PDF, JPEG, PNG, or TIFF files, with a maximum size of 50 MB and a maximum page count of 2000 pages. You can also use multipage documents, as long as each page contains only one type of bar code.

I’ll be using Power Automate to send a newly uploaded document from a SharePoint document library to Forms Recognizer where the extracted barcode and value will be returned so we can update the document library with the value.  You can also use this extracted value to do a line of business lookup or fit it into other business processes.

Post the file

Once a file has been added to a document library, get the file content and POST it to Forms Recognizer where it will process the document.

  • The initial POST call is below.  Note that for the Ocp-Apim-Subscription-Key value, this is the Forms Recognizer key we created earlier.
















  • Once the file has been posted, the response to the POST request will contain the Operation-Location value. 
  • There is a short delay while Forms Recognizer processes the file, noted by the Delay activity.
  • Using the Operation-Location value, we will GET the JSON response from Forms Recognizer that contains the barcode types and values.



  • Here is a sample output of the JSON response.  You can see that Forms Recognizer will determine the barcode value and associated symbology such as QR code, Code 39, or EAN-13.
















  • Since you document could contain multiple barcodes, we need to loop through all the Barcode nodes in the JSON response.












  • The value of the barcode can then be saved back to the document library as metadata or used for further business processing.

If you want to test and train models for bar code extraction without writing code, you can use the forms recognizer portal. The portal is a web-based tool that allows you to upload your scanned documents, analyze them, and review the results. You can also use the portal to create and train custom models for extracting data from your specific forms and documents.




















NOTE:  Portions of this blog post were created using M365 Copilot in Word.

This post was originally published on this site

- Advertisement -spot_img


Please enter your comment!
Please enter your name here

- Advertisement - Advertisement

Latest News

Preferred Solution | New feature | Microsoft Dataverse

Click on the below image to navigate to my YouTube Channel. Please like and share your valuable feedback on this...

More Articles Like This

- Advertisement -spot_img