How to generate a UPC-E barcode as a PNG file in Salesforce Apex
1 min readJul 11, 2020
Today, we are making barcode generation an absolute breeze using Salesforce Apex. While this would normally be quite difficult to do, bordering on tedious, this method will get you through in no time at all. We shall be making good use of a Cloudmersive API that will create the barcodes for us, letting us sit back and relax.
First download this zip and extract the client folder into your Apex project.
https://github.com/Cloudmersive/Cloudmersive.APIClient.Apex.Barcode/archive/master.zip
Now go ahead and call our function, like this here:
SwagGenerateBarcodeApi api = new SwagGenerateBarcodeApi();SwagClient client = api.getClient();// Configure API key authorization: ApikeyApiKeyAuth Apikey = (ApiKeyAuth) client.getAuthentication('Apikey');Apikey.setApiKey('YOUR API KEY');Map<String, Object> params = new Map<String, Object>{'value' => 'value_example'};try {// cross your fingersBlob result = api.generateBarcodeUPCE(params);System.debug(result);} catch (Swagger.ApiException e) {// ...handle your exceptions}
Boom! Done. Easy.