How to convert a PDF to PNG array in Salesforce Apex

Cloudmersive
1 min readFeb 19, 2020

--

Today’s article is going to tackle how to perform file format conversion between PDFs and PNG arrays. Through the use of one of our handy APIs, this is going to be a snap.

First step, download our Document/Conversion client here. Then extract its contents into your Apex project’s folder.

We shall proceed by invoking the convertDocumentPdfToPngArray function:

SwagConvertDocumentApi api = new SwagConvertDocumentApi();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>{'inputFile' => Blob.valueOf('Sample text file\nContents')};try {// cross your fingersSwagPdfToPngResult result = api.convertDocumentPdfToPngArray(params);System.debug(result);} catch (Swagger.ApiException e) {// ...handle your exceptions}

That’s it! We will be returned a list of URLs that correspond to each PNG image in the array.

--

--

Cloudmersive
Cloudmersive

Written by Cloudmersive

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

No responses yet