Manipulate Barcodes using Java Cloud SDK

In today’s fast-paced economies, BarCodes are an essential and viable solution for vendors and merchants to store product details. Furthermore, over the years, they have proved to be a valuable and viable choice for businesses looking to improve efficiency and reduce overhead, barcodes are both cost-effective and reliable. Among other benefits of using BarCode, specified below are 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
  • Barcodes enable precise inventory control, and hence Inventory control improves
  • 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 manipulate existing BarCodes. Similar to our other Cloud APIs, Aspose.BarCode Cloud Java SDK requires you to register an account with Aspose Cloud and lookup/create App Key and App SID at Cloud Dashboard. If you already have registered an account, you may continue using it. Once you have the account ready, use the AppKey and AppSID to access the Cloud services. Furthermore, you may consider using Aspose Cloud storage or, use any third-party cloud storage services for file storage and retrieval.

Supported formats

The SDK supports numerous Barcode symbologies (more than 60) such as EAN, UPC, Codabar, PDF417, QR, MicroQR, Postnet, Planet, RM4SCC, etc and the output can be saved 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 variety of formats. It also enables you to 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, where text color is specified as Navy, Horizontal, and Vertical resolution is specified as 200, BarColor is specified as Orange, the background color is set as silver and output format is JPEG raster image.

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>" -H  "x-aspose-client: Containerize.Swagger"

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

Output generated with Aspose.BarCode Cloud Java SDK
Image 1:- Resultant BarCode preview.

Recognize Barcodes

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 to 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

Image with Barcode
Image 2:- Image with sample Barcode.

If you run the above code on the above-specified image, the Response body will render 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": ""
    }
  ]
}