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

Barcodes are a crucial part of many businesses, but they can be quite difficult to generate, especially when using Apex. But don’t worry! I have just the thing for you: an API that can generate and read many types of barcodes. And to sweeten the deal even further, it works after just a few minutes of setup. Let’s get started.

First download this zip here and copy the client folder into your project.

Now we can call generateBarcodeUPCA:

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.generateBarcodeUPCA(params);System.debug(result);} catch (Swagger.ApiException e) {// ...handle your exceptions}

And look at that, we are already finished. Talk about a breeze.

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