How to convert Word DOCX to PDF in Salesforce Apex

Cloudmersive
1 min readFeb 16, 2020

--

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.

--

--

Cloudmersive
Cloudmersive

Written by Cloudmersive

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

No responses yet