How to generate a UPC-E barcode as a PNG file in Salesforce Apex

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.

Image for post
Image for post

Written by

There’s an API for that. Cloudmersive is a leader in Highly Scalable Cloud APIs.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store