How to convert Word DOCX to PDF in Salesforce Apex

Document format conversion is about as boring as it gets. Good thing for you, we already have an API ready to take care of this headache for you. Here’s how to implement this solution in just a few minutes.

  1. Download the API client and drop the client folder into your project directory.

2. Call convertDocumentDocxToPdf:

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

3. Enjoy all the time you just saved, because you are done!

We have numerous other functions available that cover all your document editing and converting needs.

Image for post
Image for post

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