How to generate a UPC-A barcode as a PNG file in Salesforce Apex
1 min readJul 11, 2020
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.
https://github.com/Cloudmersive/Cloudmersive.APIClient.Apex.Barcode/archive/master.zip
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.