How to develop a Barcode scanner App using Java SDK. Implement QR scan capabilities in your Web, Mobile and Desktop Applications.

Barcode scanner

Scan barcode online | QR code scanner

In this article, we are going to discuss the details of how to develop a Barcode scanner and a QR code scanner app using Java REST API. We understand that in today’s fast-paced economies, Barcodes are an essential and viable solution for vendors and merchants for storing product details. Over the years, they have proved to be a valuable and viable choice for businesses. They have greatly improved efficiency and have reduced overhead. The barcodes are both cost-effective and reliable. Among other benefits of using BarCode, specified below are a few more advantages of using them

  • Barcodes eliminate the possibility of human error
  • Using a barcode system reduces employee training time
  • Barcodes are extremely versatile and can be used for any kind of necessary data collection
  • They enable precise inventory control, and hence Inventory control improves
  • Furthermore, the Barcodes provide better data i.e. a single barcode may provide inventory and pricing details

Pertinent to all such features, Aspose.BarCode Cloud Java SDK empowers Java developers to create as well as scan Barcode online using Java language. Similar to our other Cloud APIs, Aspose.BarCode Cloud Java SDK requires you to register an account at Cloud Dashboard. If you already have registered an account, you may continue using it. Once you have your account ready, you are good to use the Cloud Services through AppKey and AppSID.

You may consider using Aspose Cloud storage or, use any third-party cloud storage services for file storage and retrieval.

Supported Barcode Symbologies

The SDK supports numerous Barcode symbologies (more than 60) such as EAN, UPC, Codabar, PDF417, QR, MicroQR, Postnet, Planet, RM4SCC, etc. You also get the option to load existing BarCode information and save the output into popular image formats, such as JPEG, PNG, GIF, BMP, TIFF, EMF, WMF, SVG, EXIF, and ICON. For a complete list of supported symbologies, please visit Aspose.BarCode Cloud Java SDK.

Generate Barcode

The SDK offers you to create Linear, 2D, and postal barcode images in a plethora of formats. You can specify barcode image attributes like image width, height, border style, and output image format. You may also specify the barcode type and text attributes such as text location and font styles as per your application requirements. It also provides the capabilities to set the height of bars & rotate barcode images at an angle.

The following example shows the steps to create Code39Standard Barcode, placed on the Top-Center alignment of the page. The text color is specified as Navy, Horizontal, and Vertical resolution is specified as 200. The BarColor is specified as Orange, the background color is set as silver and the output format is JPEG format.

Before we proceed further, we recommend you to visit the following link as a JWT token is necessary when accessing the API using the cURL command.

cURL

curl -X PUT "https://api.aspose.cloud/v3.0/barcode/MySample.jpeg/generate?Type=Code39Standard&Text=BarCode%20processing&TextLocation=Above&TextAlignment=Center&TextColor=Navy&FontSizeMode=Auto&Resolution=200&ResolutionX=200&BackColor=silver&BarColor=Orange&BorderColor=Blue&format=jpeg" \
-H  "accept: application/json" \
-H  "authorization: Bearer <JWT Token>"

Request URL

https://api.aspose.cloud/v3.0/barcode/MySample.jpeg/generate?Type=Code39Standard&Text=BarCode%20processing&TextLocation=Above&TextAlignment=Center&TextColor=Navy&FontSizeMode=Auto&Resolution=200&ResolutionX=200&BackColor=silver&BarColor=Orange&BorderColor=Blue&format=jpeg

Java

Online barcode scanner

Image 1:- Resultant BarCode preview.

Barcode Reader Online

QR scan

Image 2: QR code scanner

The Cloud API is also capable of recognizing information from existing barcodes. You get the option to specify the Barcode type details for quick retrieval or let the API determine the type automatically. You may also specify ChecksumValidation details, DetectEncoding, or let the API determine them over the runtime.

cURL

curl -X POST "https://api.aspose.cloud/v3.0/barcode/recognize?Type=all&DetectEncoding=true" \
-H  "accept: application/json" \
-H  "authorization: Bearer <JWT Token>" \
-H  "Content-Type: multipart/form-data" \
-H  "x-aspose-client: Containerize.Swagger" -d {"image":{}}

Request URL

https://api.aspose.cloud/v3.0/barcode/recognize?Type=all&DetectEncoding=true

Java

2d barcode

Image 3:- 2D barcode preview.

If you run the above code on the above-specified image, the Response body will render the output as

Response body

{  "barcodes":  [  {  "barcodeValue":  "12345678",  "type":  "Code39Standard",  "region":  [  {  "x":  **28**,  "y":  **3**  },  {  "x":  **222**,  "y":  **3**  },  {  "x":  **222**,  "y":  **74**  },  {  "x":  **28**,  "y":  **74**  }  ],  "checksum":  ""  }  ]  }

Conclusion

In this article, we have learned the steps on how to develop a Barcode scanner App using Java REST API. Similarly, the API also enables you to implement a QR code reader from image file. Apart from using the Java SDK, we also get an option to scan barcode online using cURL commands. No additional software download or installation is required. In case you encounter any issues while using the API, please feel free to contact us via the free product support forum.

We also recommend visiting the following links to learn more about: