Analyzing your prompt, please hold on...
An error occurred while retrieving the results. Please refresh the page and try again.
This documentation provides a comprehensive guide on how to set the colorscheme for barcodes using the Aspose.BarCode Cloud SDK for Python. The API allows customization of barcode appearance, including foreground and background colors, ensuring your barcodes match your design needs.
The GenerateApi
interface includes methods to generate barcodes using different request formats:
The foreground_color
and background_color
properties enable you to define the colors for the barcode:
Both properties accept standard color names or ARGB values (e.g., AliceBlue
or #FF000000
).
import os
from aspose_barcode_cloud import ApiClient, EncodeBarcodeType, BarcodeImageFormat, 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():
"""Main function to generate QR code barcode."""
configuration = make_configuration()
api_client = ApiClient(configuration=configuration)
generate_api = GenerateApi(api_client=api_client)
file_name = os.path.abspath(os.path.join(os.path.dirname(__file__), "..", "testdata", "qr.png"))
response = generate_api.generate(
EncodeBarcodeType.QR,
"https://products.aspose.cloud/barcode/family/",
foreground_color="DarkBlue",
background_color="LightGray",
image_format=BarcodeImageFormat.PNG,
)
# Write the response to a file
with open(file_name, "wb") as stream:
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,
BarcodeImageParams,
BarcodeImageFormat,
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"))
configuration = make_configuration()
api_client = ApiClient(configuration=configuration)
generate_api = GenerateApi(api_client=api_client)
generate_params = GenerateParams(
EncodeBarcodeType.PDF417,
EncodeData(EncodeDataType.STRINGDATA, "Aspose.BarCode.Cloud"),
BarcodeImageParams(
foreground_color="#FF5733", background_color="#FFFFFF", image_format=BarcodeImageFormat.JPEG
),
)
response = generate_api.generate_body(generate_params)
with open(file_name, "wb") as stream:
stream.write(response.data)
print(f"File '{file_name}' generated.")
# Run the async main function
if __name__ == "__main__":
main()
Result Image is:
import os
from aspose_barcode_cloud import ApiClient, GenerateApi, EncodeBarcodeType, BarcodeImageFormat, Configuration
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", "Code39.png"))
api_client = ApiClient(configuration=make_configuration())
generate_api = GenerateApi(api_client=api_client)
response = generate_api.generate_multipart(
barcode_type=EncodeBarcodeType.CODE39,
data="Aspose",
foreground_color="Green",
background_color="Yellow",
image_format=BarcodeImageFormat.GIF,
)
with open(file_name, "wb") as stream:
stream.write(response.data)
print(f"File '{file_name}' generated.")
if __name__ == "__main__":
main()
Result Image is:
With GenerateApi
in Aspose.BarCode Cloud SDK for Python, you can easily generate barcodes with customized colors. Whether you prefer GET, POST with JSON, or multipart form POST, the flexibility of this API ensures seamless integration and customization of barcodes in your applications.
Analyzing your prompt, please hold on...
An error occurred while retrieving the results. Please refresh the page and try again.