PDFTron Conversion to DOCX format with applied template values

Product: PDFTron Salesforce Integration

Product Version: Using the same static resource as provided in GitHub - PDFTron/salesforce-webviewer-docgen

Please give a brief summary of your issue:
Unable to extract a .docx document with merged template values

Please describe your issue and provide steps to reproduce it:

Hi,

We are currently working on a POC for a client in which the requirement is to be able to fill in template values for placeholders provided within {{ }} from a .docx file attached to a record in Salesforce.

Source File → .docx file with {{ }} placeholders
Desired Target Output →

  1. .pdf file with placeholder values merged [WORKING]
  2. .docx file with placeholder values merged [NOT WORKING]

We are able to load the document within a web viewer and fire an event with the JSON key values to fill in the placeholders. However, when trying to extract the document with the merged values from the web viewer to salesforce (using a base64 encoded string), we are unable to retrieve the merged document in .docx format.

We are able to get the desired result while trying to extract a pdf with merged values by specifying the downloadtype parameter as ‘pdf’ within doc.getFileData() in the config_apex.js file. Changing the same downloadtype parameter to ‘office’ is returning the document in Docx format WITHOUT replacing the placeholders (although the web viewer shows the updated document).

Is there a way to get the .docx format from the webviewer and also retain the merged values?

Thanks in advance for taking the time to read this .

Thanks for your post Parjanya!

We already discussed this on a call, but wanted to re-iterate here in case anyone else is running into this:

The expected behaviour for our document generation in WebViewer is to output a PDF from MS Office files. This is because under the hood, the docx file is converted to PDF, and during conversion the template tags are replaced, so this is expected behaviour.

To fill a MS Office template and get MS Office output, another conversion step is required (f.e. using PDF to Office Conversion SDK | PDFTron )

Best,
Thomas