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 Python. 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:
data_type
: 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 |
---|---|
STRINGDATA (Default value) | Plain text |
BASE64BYTES | Base64 encoded binary data |
HEXBYTES | Hexadecimal encoded binary data |
Below are examples to demonstrate barcode generation using the GenerateApi
methods.
import os
from aspose_barcode_cloud import (
ApiClient,
Configuration,
EncodeBarcodeType,
EncodeData,
EncodeDataType,
GenerateParams,
BarcodeImageParams,
BarcodeImageFormat,
)
from aspose_barcode_cloud.api.generate_api import GenerateApi
def make_configuration():
env_token = os.getenv("TEST_CONFIGURATION_ACCESS_TOKEN")
if env_token:
config = Configuration(access_token=env_token)
else:
config = Configuration(
client_id="Client Id from https://dashboard.aspose.cloud/applications",
client_secret="Client Secret from https://dashboard.aspose.cloud/applications",
)
return config
def main():
"""Main function to generate a QR code."""
file_name = os.path.abspath(os.path.join(os.path.dirname(__file__), "..", "testdata", "qr.png"))
configuration = make_configuration()
api_client = ApiClient(configuration=configuration)
generate_api = GenerateApi(api_client=api_client)
generate_params = GenerateParams(
EncodeBarcodeType.QR, EncodeData(EncodeDataType.STRINGDATA, "Aspose.BarCode.Cloud")
)
response = generate_api.generate_body(generate_params)
with open(file_name, "wb") as file_stream:
file_stream.write(response.data)
print(f"File '{file_name}' generated.")
if __name__ == "__main__":
main()
Result Image is:
import os
from aspose_barcode_cloud import (
ApiClient,
EncodeBarcodeType,
EncodeDataType,
EncodeData,
GenerateParams,
Configuration,
)
from aspose_barcode_cloud.api.generate_api import GenerateApi
def make_configuration():
env_token = os.getenv("TEST_CONFIGURATION_ACCESS_TOKEN")
if env_token:
config = Configuration(access_token=env_token)
else:
config = Configuration(
client_id="Client Id from https://dashboard.aspose.cloud/applications",
client_secret="Client Secret from https://dashboard.aspose.cloud/applications",
)
return config
def main():
file_name = os.path.abspath(os.path.join(os.path.dirname(__file__), "..", "testdata", "pdf417.png"))
config = make_configuration()
api_client = ApiClient(configuration=config)
generate_api = GenerateApi(api_client=api_client)
post_params = GenerateParams(
barcode_type=EncodeBarcodeType.PDF417,
encode_data=EncodeData(data_type=EncodeDataType.BASE64BYTES, data="QXNwb3NlLkJhckNvZGUuQ2xvdWQ="),
)
response = generate_api.generate_body(post_params)
with open(file_name, "wb") as file:
file.write(response.data)
print(f"File '{file_name}' generated.")
if __name__ == "__main__":
main()
Result Image is:
import os
from aspose_barcode_cloud import ApiClient, EncodeBarcodeType, EncodeDataType, Configuration
from aspose_barcode_cloud.api.generate_api import GenerateApi
def make_configuration():
env_token = os.getenv("TEST_CONFIGURATION_ACCESS_TOKEN")
if env_token:
config = Configuration(access_token=env_token)
else:
config = Configuration(
client_id="Client Id from https://dashboard.aspose.cloud/applications",
client_secret="Client Secret from https://dashboard.aspose.cloud/applications",
)
return config
def main():
file_name = os.path.abspath(os.path.join(os.path.dirname(__file__), "..", "testdata", "Code128.png"))
api_client = ApiClient(configuration=make_configuration())
generate_api = GenerateApi(api_client=api_client)
response = generate_api.generate_multipart(
EncodeBarcodeType.CODE128, "4173706F73652E426172436F64652E436C6F7564", EncodeDataType.HEXBYTES
)
with open(file_name, "wb") as stream:
stream.write(response.data)
print(f"File '{file_name}' generated.")
if __name__ == "__main__":
main()
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.