Cara membuat gambar barcode di Java

Barcode ada di mana-mana dalam perdagangan dan ritel untuk membantu pelacakan, pembelian, dan inventaris produk. Mereka memungkinkan organisasi untuk menyimpan catatan akurat tentang persediaan, barang, dan barang lain yang merupakan kunci operasi mereka. Untuk penggunaan internasional dan nasional, ada barcode berbeda yang digunakan dalam konteks tertentu. Misalnya, kode batang UPC dan EAN terlihat sama dalam formatnya dan dapat digunakan dengan cara yang sama, tetapi UPC pada dasarnya adalah sistem pengkodean Amerika Utara; namun, UPC dan EAN digunakan di seluruh dunia. Kode QR juga digunakan di seluruh dunia, tetapi biasanya digunakan untuk bertukar kumpulan informasi yang kompleks, seperti detail produk atau tautan ke situs web.





  API-  - .  -, .  ,   . 





API, SDK Maven Gradle.  Maven,   Jitpack  pom.xml: 





<repositories>
    <repository>
        <id>jitpack.io</id>
        <url>https://jitpack.io</url>
    </repository>
</repositories>
      
      



:





<dependencies>
<dependency>
    <groupId>com.github.Cloudmersive</groupId>
    <artifactId>Cloudmersive.APIClient.Java</artifactId>
    <version>v3.54</version>
</dependency>
</dependencies>
      
      



Gradle, build.gradle :





allprojects {
    repositories {
        ...
        maven { url 'https://jitpack.io' }
    }
}
      
      



build.gradle:





dependencies {
   implementation 'com.github.Cloudmersive:Cloudmersive.APIClient.Java:v3.54'
}
      
      



- UPC : UPC-A UPC-E. UPC-A — - UPC, 12 , . UPC-E , 12- 6 . UPC , UPC-E. , . - UPC-A, SDK, , :





// Import classes:
//import com.cloudmersive.client.invoker.ApiClient;
//import com.cloudmersive.client.invoker.ApiException;
//import com.cloudmersive.client.invoker.Configuration;
//import com.cloudmersive.client.invoker.auth.*;
//import com.cloudmersive.client.GenerateBarcodeApi;

ApiClient defaultClient = Configuration.getDefaultApiClient();

// Configure API key authorization: Apikey
ApiKeyAuth Apikey = (ApiKeyAuth) defaultClient.getAuthentication("Apikey");
Apikey.setApiKey("YOUR API KEY");

// Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null)
//Apikey.setApiKeyPrefix("Token");

GenerateBarcodeApi apiInstance = new GenerateBarcodeApi();

String value = "value_example"; // String | UPC-A barcode value to generate from

try {
    byte[] result = apiInstance.generateBarcodeUPCA(value);
    System.out.println(result);
} catch (ApiException e) {
    System.err.println("Exception when calling GenerateBarcodeApi#generateBarcodeUPCA");
    e.printStackTrace();
}
      
      



, , — - UPC, . , - PNG. API , :





  • - UPC .





  • API, 800 API. - Cloudmersive.





UPC-E, , :





// Import classes:
//import com.cloudmersive.client.invoker.ApiClient;
//import com.cloudmersive.client.invoker.ApiException;
//import com.cloudmersive.client.invoker.Configuration;
//import com.cloudmersive.client.invoker.auth.*;
//import com.cloudmersive.client.GenerateBarcodeApi;

ApiClient defaultClient = Configuration.getDefaultApiClient();

// Configure API key authorization: Apikey
ApiKeyAuth Apikey = (ApiKeyAuth) defaultClient.getAuthentication("Apikey");
Apikey.setApiKey("YOUR API KEY");

// Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null)
//Apikey.setApiKeyPrefix("Token");

GenerateBarcodeApi apiInstance = new GenerateBarcodeApi();
String value = "value_example"; // String | UPC-E barcode value to generate from

try {
    byte[] result = apiInstance.generateBarcodeUPCE(value);
    System.out.println(result);
} catch (ApiException e) {
    System.err.println("Exception when calling GenerateBarcodeApi#generateBarcodeUPCE");
    e.printStackTrace();
}
      
      



- EAN , . EAN — EAN-13 EAN-8, EAN-13 . UPC, EAN , . EAN-13 13 , , , . EAN-8 8 , EAN-13.





EAN-13, SDK, , :





// Import classes:
//import com.cloudmersive.client.invoker.ApiClient;
//import com.cloudmersive.client.invoker.ApiException;
//import com.cloudmersive.client.invoker.Configuration;
//import com.cloudmersive.client.invoker.auth.*;
//import com.cloudmersive.client.GenerateBarcodeApi;

ApiClient defaultClient = Configuration.getDefaultApiClient();

// Configure API key authorization: Apikey
ApiKeyAuth Apikey = (ApiKeyAuth) defaultClient.getAuthentication("Apikey");
Apikey.setApiKey("YOUR API KEY");

// Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null)
//Apikey.setApiKeyPrefix("Token");

GenerateBarcodeApi apiInstance = new GenerateBarcodeApi();
String value = "value_example"; // String | Barcode value to generate from

try {
    byte[] result = apiInstance.generateBarcodeEAN13(value);
    System.out.println(result);
} catch (ApiException e) {
    System.err.println("Exception when calling GenerateBarcodeApi#generateBarcodeEAN13");
    e.printStackTrace();
}
      
      



EAN-8 :






// Import classes:
//import com.cloudmersive.client.invoker.ApiClient;
//import com.cloudmersive.client.invoker.ApiException;
//import com.cloudmersive.client.invoker.Configuration;
//import com.cloudmersive.client.invoker.auth.*;
//import com.cloudmersive.client.GenerateBarcodeApi;

ApiClient defaultClient = Configuration.getDefaultApiClient();

// Configure API key authorization: Apikey
ApiKeyAuth Apikey = (ApiKeyAuth) defaultClient.getAuthentication("Apikey");
Apikey.setApiKey("YOUR API KEY");

// Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null)
//Apikey.setApiKeyPrefix("Token");

GenerateBarcodeApi apiInstance = new GenerateBarcodeApi();
String value = "value_example"; // String | Barcode value to generate from

try {
    byte[] result = apiInstance.generateBarcodeEAN8(value);
    System.out.println(result);
} catch (ApiException e) {
    System.err.println("Exception when calling GenerateBarcodeApi#generateBarcodeEAN8");
    e.printStackTrace();
}
      
      



- , , . , , QR- 2D. QR-, Quick Return code ( ), , QR-, . , .





QR-, :





// Import classes:
//import com.cloudmersive.client.invoker.ApiClient;
//import com.cloudmersive.client.invoker.ApiException;
//import com.cloudmersive.client.invoker.Configuration;
//import com.cloudmersive.client.invoker.auth.*;
//import com.cloudmersive.client.GenerateBarcodeApi;

ApiClient defaultClient = Configuration.getDefaultApiClient();

// Configure API key authorization: Apikey
ApiKeyAuth Apikey = (ApiKeyAuth) defaultClient.getAuthentication("Apikey");
Apikey.setApiKey("YOUR API KEY");

// Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null)
//Apikey.setApiKeyPrefix("Token");

GenerateBarcodeApi apiInstance = new GenerateBarcodeApi();
String value = "value_example"; // String | QR code text to convert into the QR code barcode

try {
    byte[] result = apiInstance.generateBarcodeQRCode(value);
    System.out.println(result);
} catch (ApiException e) {
    System.err.println("Exception when calling GenerateBarcodeApi#generateBarcodeQRCode");
    e.printStackTrace();
}
      
      



, , .





Semua fungsi ini mengembalikan file PNG yang berisi gambar kode batang Anda untuk digunakan pada produk atau item apa pun. Jika Anda memiliki pertanyaan tentang penggunaan API ini, atau pertanyaan tentang solusi API lainnya, Anda dapat mengunjungi situs web Cloudmersive, di mana tim kami akan dengan senang hati membantu Anda dengan apa pun yang mungkin Anda butuhkan.








All Articles