How to screenshot a website/URL in Salesforce Apex

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.

Image for post
Image for post

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