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

Cloudmersive
1 min readJul 11, 2020

Trying to crack barcode generation is probably not how you want to be spending your afternoon. So that’s why I’m here to rescue you from such a grim fate. Instead of banging our head through a wall of code, we will be skipping out the door after 5 minutes of simple setup. Let’s dive straight in.

First we will download the client library from this github page:

https://github.com/Cloudmersive/Cloudmersive.APIClient.Apex.Barcode/archive/master.zip

Now we can copy the client folder into our project. This will allow us to then call this function here for generating EAN-13 barcodes:

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

Done! Super easy.

--

--

Cloudmersive

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