How to generate a EAN-8 barcode as a PNG file in Salesforce Apex

I’m going to take a guess that you are not enthused at the idea of figuring out barcode generation using Apex. It’s definitely not my choice for an evening’s entertainment. However, there is hope in sight. I am here today to show you how to set up a barcode generation system for EAN-8 that will be ready in just a few short minutes, with minimal effort required.

First we will need to download this file and extract the client folder to our project:

Now we can go ahead and call our barcode generation function:

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

Whew! Already done.

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