Generate a UPC-E code barcode as PNG File in Python
UPC-E barcode formatting offers a suppressed version of the UPC-A format (which is probably the most common barcode used by retail businesses across the globe). Creating new UPC-E barcodes is made easy by Cloudmersive’s Barcode API — specifically the /barcode/generate/upc-e iteration. This API will generate a 1D UPC-E barcode in PNG format. Let’s run through how you can use this API to generate your own UPC-E barcodes in Python.
The first thing we’ll need to do is use the below snippet to install the Python SDK:
pip install cloudmersive-barcode-api-clientfrom __future__ import print_function
import time
import cloudmersive_barcode_api_client
from cloudmersive_barcode_api_client.rest import ApiException
from pprint import pprint
After that, we’ll add the API authorization key & call the function using the below code:
# Configure API key authorization: Apikey
configuration = cloudmersive_barcode_api_client.Configuration()
configuration.api_key['Apikey'] = 'YOUR_API_KEY'# create an instance of the API class
api_instance = cloudmersive_barcode_api_client.GenerateBarcodeApi(cloudmersive_barcode_api_client.ApiClient(configuration))
value = 'value_example' # str | UPC-E barcode value to generate fromtry:
# Generate a UPC-E code barcode as PNG file
api_response = api_instance.generate_barcode_upce(value)
pprint(api_response)
except ApiException as e:
print("Exception when calling GenerateBarcodeApi->generate_barcode_upce: %s\n" % e)
Just like that, your UPC-E barcode needs are settled. Additional iterations of the Cloudmersive Barcode API enable QR, UPC-A, EAN-13 & EAN-8 barcode creation.