How to screenshot a website/URL in Salesforce Apex

Cloudmersive
1 min readFeb 15, 2020

--

Need a quick solution for screenshotting websites? We’ve got you covered. You’ll be done in a handful of minutes.

Right out of the gate, we need to begin by downloading our API Client. Now unzip it and drop the client folder into your Apex project.

Moving on, we are ready to call convertWebUrlToScreenshot:

SwagConvertWebApi api = new SwagConvertWebApi();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>{'input' => SwagScreenshotRequest.getExample()};try {// cross your fingersBlob result = api.convertWebUrlToScreenshot(params);System.debug(result);} catch (Swagger.ApiException e) {// ...handle your exceptions}

And just like that, we’re already finished.

--

--

Cloudmersive
Cloudmersive

Written by Cloudmersive

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

No responses yet