How to read barcodes in Java using Cloud API (low level) - ByteScout
Announcement
Our ByteScout SDK products are sunsetting as we focus on expanding new solutions.
Learn More Open modal
Close modal
Announcement Important Update
ByteScout SDK Sunsetting Notice
Our ByteScout SDK products are sunsetting as we focus on our new & improved solutions. Thank you for being part of our journey, and we look forward to supporting you in this next chapter!

How to read barcodes in Java using Cloud API (low level)

  • Home
  • /
  • Articles
  • /
  • How to read barcodes in Java using Cloud API (low level)

This sample source code can be used to read barcodes in Java using Cloud API (low level).

It is also possible to generate barcode in Java using ByteScout Cloud API.

POST/GET endpoint:

https://api.pdf.co/v1/barcode/read/from/url

Code Sample:


import Bytescout\Client\API.*;
import Bytescout\Client\API.auth.*;
import Bytescout\Client\API.model.*;
import Bytescout\Client\API.api.DefaultApi;

import java.io.File;
import java.util.*;

public class DefaultApiExample {

    public static void main(String[] args) {
        ApiClient defaultClient = Configuration.getDefaultApiClient();
        
        // Configure API key authorization: api_key
        ApiKeyAuth api_key = (ApiKeyAuth) defaultClient.getAuthentication("api_key");
        api_key.setApiKey("YOUR API KEY");
        // Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null)
        //api_key.setApiKeyPrefix("Token");

        DefaultApi apiInstance = new DefaultApi();
        String types = types_example; // String | Comma-separated list of barcode types to decode. Valid types: AustralianPostCode, Aztec, CircularI2of5, Codabar, CodablockF, Code128, Code16K, Code39, Code39Extended, Code39Mod43, Code39Mod43Extended, Code93, DataMatrix, EAN13, EAN2, EAN5, EAN8, GS1, GS1DataBarExpanded, GS1DataBarExpandedStacked, GS1DataBarLimited, GS1DataBarOmnidirectional, GS1DataBarStacked, GTIN12, GTIN13, GTIN14, GTIN8, IntelligentMail, Interleaved2of5, ITF14, MaxiCode, MICR, MicroPDF, MSI, PatchCode, PDF417, Pharmacode, PostNet, PZN, QRCode, RoyalMail, RoyalMailKIX, Trioptic, UPCA, UPCE, UPU.
        String pages = pages_example; // String | Comma-separated list of page indices (or ranges) to process. Leave empty for all pages. Example: '0,2-5,7-'.
        String url = url_example; // String | URL of the image to decode barcodes from.
        try {
            BarcodeReaderResponseModel result = apiInstance.barcodeReadFromUrlPost(types, pages, url);
            System.out.println(result);
        } catch (ApiException e) {
            System.err.println("Exception when calling DefaultApi#barcodeReadFromUrlPost");
            e.printStackTrace();
        }
    }
}

Tutorials:

prev
next