How to Create and Read Barcodes with C# .NET REST API

Share on FacebookTweet about this on TwitterShare on LinkedIn

Barcodes are widely used around the world for the necessary data collection. A barcode is an encoded image used to represent data in a visual and machine-readable form. As a developer, you came across a number of scenarios, where you need to create and read barcodes in your application. In this article I will share a RESTful solution, Aspose.BarCode Cloud, for working with the barcode in your application. It eliminates the requirement to install and maintain a separate software to create and read barcodes.  

Aspose.BarCode Cloud is a platform independent barcode generation and recognition solution. It enables developers to create and read 1D (Linear), 2D and postal barcodes of 60+ symbologies that can be integrated universally into any workflow, html page, web application and desktop application. While creating new barcodes you can set barcode configurations, such as, barcode bar height, its dimensions, barcode image format and so on. The API generate and recognize barcode images in a variety of image formats: JPEG, PNG, GIF, BMP, TIFF, EMF, WMF, EXIF and ICON.

I’m using Aspose.BarCode Cloud SDK for .NET in this article. However, Aspose.BarCode Cloud also provides SDKs of all popular programming languages via GitHub and external Package Managers, so you can directly implement Aspose.BarCode Cloud in your favorite platform directly, with ease.

Here we go, we will follow these steps:

How to create the barcode

Step 1

First thing first, sign up with aspose.cloud to get your AppSID and AppKey

Step 2

Create a new project in Visual Studio and install Aspose.BarCode SDK for .NET package from NuGet

PM> Install-Package Aspose.BarCode-Cloud

Step 3

Copy paste the following code in the new project to create a barcode. I have used GetBarGenerate API method in this example, it creates the barcode with specified settings and returns the result in the response stream. I have created 2D barcode(datamatrix) in this example, you can create any barcode from the supported barcode types.

Step 4

Run the code, it will save the barcode image as PNG image format. You can use response stream as per your use case.

How to read the barcode

Repeat the above steps 1-2, if required.

Step 3

Copy paste the following code in the new project to read the barcode image from local drive. It recognizes the barcode image and return the barcode type and value.

Step 4

Run the code, the API reads all the barcode images from provided image and return the details in the response.

And that’s it. You see how easy is it to create a new barcode or read a barcode image with few lines of code.

What’s Next

In case you still haven’t met the API and haven’t worked with it, free trial is right here waiting for you to give it a try and explore the power of the Aspose.BarCode Cloud API. All you need is to sign up with the aspose.cloud and visit our developer resources for a quick start: