Analyzing your prompt, please hold on...
An error occurred while retrieving the results. Please refresh the page and try again.
This documentation covers how to set barcode text in the Aspose.BarCode Cloud SDK for Java. The Barcode API supports multiple methods to generate barcodes in different formats using GET and POST requests through the GenerateApi
. Barcodes can be generated by specifying various parameters such as barcode type, data to encode, image format and display options. The data encoding process involves defining the type of data and the actual content.
The GenerateApi
interface includes methods for generating barcodes:
dataType
: Specifies the type of data encoding (can be string, base64, or hex). If not set, the data
value is used as plain text.data
: A string that represents the data to be encoded.Value | Description |
---|---|
STRING_DATA (Default value) | Plain text |
BASE64_BYTES | Base64 encoded binary data |
HEX_BYTES | Hexadecimal encoded binary data |
Below are examples to demonstrate barcode generation using the GenerateApi
methods.
import com.aspose.barcode.cloud.ApiClient;
import com.aspose.barcode.cloud.api.GenerateApi;
import com.aspose.barcode.cloud.model.EncodeBarcodeType;
import com.aspose.barcode.cloud.model.EncodeDataType;
import com.aspose.barcode.cloud.requests.GenerateRequestWrapper;
import java.io.File;
public class GenerateGet {
public static void main(String[] args) {
String accessToken = System.getenv("TEST_CONFIGURATION_ACCESS_TOKEN");
ApiClient client;
if (accessToken != null && !accessToken.isEmpty()) {
client = new ApiClient(accessToken);
} else {
client =
new ApiClient(
"Client Id from https://dashboard.aspose.cloud/applications",
"Client Secret from https://dashboard.aspose.cloud/applications");
}
GenerateApi generateApi = new GenerateApi(client);
try {
GenerateRequestWrapper getRequest =
new GenerateRequestWrapper(EncodeBarcodeType.QR, "Aspose.BarCode.Cloud");
getRequest.dataType = EncodeDataType.STRING_DATA;
File barcodeImage = generateApi.generate(getRequest);
System.out.println("Barcode image saved to file " + barcodeImage.getAbsolutePath());
} catch (Exception e) {
System.err.println("Error");
e.printStackTrace();
System.exit(1);
}
}
}
Result Image is:
import com.aspose.barcode.cloud.ApiClient;
import com.aspose.barcode.cloud.api.GenerateApi;
import com.aspose.barcode.cloud.model.EncodeBarcodeType;
import com.aspose.barcode.cloud.model.EncodeData;
import com.aspose.barcode.cloud.model.EncodeDataType;
import com.aspose.barcode.cloud.model.GenerateParams;
import com.aspose.barcode.cloud.requests.GenerateBodyRequestWrapper;
import java.io.File;
public class GenerateBody {
public static void main(String[] args) {
String accessToken = System.getenv("TEST_CONFIGURATION_ACCESS_TOKEN");
ApiClient client;
if (accessToken != null && !accessToken.isEmpty()) {
client = new ApiClient(accessToken);
} else {
client =
new ApiClient(
"Client Id from https://dashboard.aspose.cloud/applications",
"Client Secret from https://dashboard.aspose.cloud/applications");
}
GenerateApi generateApi = new GenerateApi(client);
try {
EncodeData encodeData = new EncodeData("QXNwb3NlLkJhckNvZGUuQ2xvdWQ=");
encodeData.setDataType(EncodeDataType.BASE64_BYTES);
GenerateParams postParams = new GenerateParams(EncodeBarcodeType.PDF417, encodeData);
GenerateBodyRequestWrapper postRequest = new GenerateBodyRequestWrapper(postParams);
File barcodeImage = generateApi.generateBody(postRequest);
System.out.println("Barcode image saved to file " + barcodeImage.getAbsolutePath());
} catch (Exception e) {
System.err.println("Error");
e.printStackTrace();
System.exit(1);
}
}
}
Result Image is:
import com.aspose.barcode.cloud.ApiClient;
import com.aspose.barcode.cloud.api.GenerateApi;
import com.aspose.barcode.cloud.model.EncodeBarcodeType;
import com.aspose.barcode.cloud.model.EncodeDataType;
import com.aspose.barcode.cloud.requests.GenerateMultipartRequestWrapper;
import java.io.File;
public class GenerateMultipart {
public static void main(String[] args) {
String accessToken = System.getenv("TEST_CONFIGURATION_ACCESS_TOKEN");
ApiClient client;
if (accessToken != null && !accessToken.isEmpty()) {
client = new ApiClient(accessToken);
} else {
client =
new ApiClient(
"Client Id from https://dashboard.aspose.cloud/applications",
"Client Secret from https://dashboard.aspose.cloud/applications");
}
GenerateApi generateApi = new GenerateApi(client);
try {
GenerateMultipartRequestWrapper formRequest =
new GenerateMultipartRequestWrapper(
EncodeBarcodeType.CODE128, "4173706F73652E426172436F64652E436C6F7564");
formRequest.dataType = EncodeDataType.HEX_BYTES;
File barcodeImage = generateApi.generateMultipart(formRequest);
System.out.println("Barcode image saved to file " + barcodeImage.getAbsolutePath());
} catch (Exception e) {
System.err.println("Error");
e.printStackTrace();
System.exit(1);
}
}
}
Result Image is:
This documentation covers how to use the GenerateApi
to set barcodes text.
Analyzing your prompt, please hold on...
An error occurred while retrieving the results. Please refresh the page and try again.