Analyzing your prompt, please hold on...
An error occurred while retrieving the results. Please refresh the page and try again.
This documentation explains how to customize the appearance of barcodes using the Aspose.BarCode Cloud SDK for Python. It provides details on the available methods, customization options, and examples of usage.
When generating a barcode, you can customize various aspects of its appearance using the properties of the request classes.
Key Properties:
QR, Aztec, Pdf417, Code39, etc).Png, Jpeg, Svg).AliceBlue or #FF000000).Below, Above, None).Pixel, Inch, Millimeter).In addition to the common appearance settings above, the API exposes advanced parameters that apply only to specific barcode types. They are ignored when a different barcode type is generated.
Auto, Extended, Binary, ECI).LevelL, LevelM, LevelQ, LevelH).Auto, Version01–Version40). Auto selects the smallest version that fits the data.UTF8, ISO_8859_1).0 to 1.Auto, M1–M4). Used when the barcode type is MicroQR.Auto, R7x43–R17x139). Used when the barcode type is RectMicroQR.Auto, CodeA, CodeB, CodeAB, CodeC, CodeAC, CodeBC).Auto, Binary, ECI, Extended).Level0–Level8).1–30, or 0 for auto).3–90, or 0 for automatic).2–5 for MicroPDF417; 3–5 for PDF417 and MacroPDF417).None, Macro05, Macro06).import os
from aspose_barcode_cloud import (
ApiClient,
EncodeBarcodeType,
BarcodeImageFormat,
BarcodeImageParams,
CodeLocation,
Configuration,
QrParams,
QREncodeMode,
QRErrorLevel,
QRVersion,
)
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():
configuration = make_configuration()
api_client = ApiClient(configuration=configuration)
generate_api = GenerateApi(api_client=api_client)
response = generate_api.generate(
EncodeBarcodeType.QR,
"Aspose.BarCode.Cloud",
barcode_image_params=BarcodeImageParams(
image_format=BarcodeImageFormat.PNG,
foreground_color="Black",
background_color="White",
text_location=CodeLocation.BELOW,
resolution=300,
image_height=200,
image_width=200,
),
qr_params=QrParams(
qr_encode_mode=QREncodeMode.AUTO,
qr_error_level=QRErrorLevel.LEVELM,
qr_version=QRVersion.AUTO,
qr_aspect_ratio=0.75,
),
)
file_name = os.path.abspath(os.path.join(os.path.dirname(__file__), "..", "testdata", "qr.png"))
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,
Configuration,
EncodeBarcodeType,
EncodeDataType,
EncodeData,
GenerateParams,
BarcodeImageParams,
BarcodeImageFormat,
QrParams,
QREncodeMode,
QRErrorLevel,
QRVersion,
)
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
# Main function to generate barcode
def main():
# Set up the configuration and API client
configuration = make_configuration()
api_client = ApiClient(configuration)
generate_api = GenerateApi(api_client=api_client)
# Define the file path for the generated barcode
file_name = os.path.abspath(os.path.join(os.path.dirname(__file__), "..", "testdata", "qr-custom.jpeg"))
# Set up the generation parameters
generate_params = GenerateParams(
barcode_type=EncodeBarcodeType.QR,
encode_data=EncodeData(data="Aspose", data_type=EncodeDataType.STRINGDATA),
barcode_image_params=BarcodeImageParams(
foreground_color="#FF0000",
background_color="#FFFF00",
image_format=BarcodeImageFormat.JPEG,
rotation_angle=90,
),
qr_params=QrParams(
qr_encode_mode=QREncodeMode.AUTO,
qr_error_level=QRErrorLevel.LEVELM,
qr_version=QRVersion.AUTO,
qr_aspect_ratio=0.75,
),
)
# Generate barcode
response = generate_api.generate_body(generate_params)
# Save the generated image to a file
with open(file_name, "wb") as stream:
stream.write(response.data)
print(f"File '{file_name}' generated.")
# To run the main function if this script is executed
if __name__ == "__main__":
main()
Result Image is: 
import os
from aspose_barcode_cloud import (
ApiClient,
EncodeBarcodeType,
BarcodeImageFormat,
BarcodeImageParams,
CodeLocation,
Configuration,
Pdf417Params,
Pdf417EncodeMode,
Pdf417ErrorLevel,
)
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.svg"))
api_client = ApiClient(configuration=make_configuration())
generate_api = GenerateApi(api_client=api_client)
# Generate barcode
response = generate_api.generate_multipart(
barcode_type=EncodeBarcodeType.PDF417,
data="Aspose.BarCode.Cloud",
barcode_image_params=BarcodeImageParams(
text_location=CodeLocation.ABOVE,
image_format=BarcodeImageFormat.SVG,
),
pdf417_params=Pdf417Params(
pdf417_encode_mode=Pdf417EncodeMode.AUTO,
pdf417_error_level=Pdf417ErrorLevel.LEVEL2,
pdf417_aspect_ratio=3,
),
)
with open(file_name, "wb") as stream:
stream.write(response.data)
print(f"File '{file_name}' generated.")
if __name__ == "__main__":
main()
Result Image is:
Analyzing your prompt, please hold on...
An error occurred while retrieving the results. Please refresh the page and try again.