0

I have a visualforce page that is renedered in word (.doc). This visualforce is used to represent a contract document. After clicking a custom button, the visualforce page is invoked and then the content of the document is saved as Attachment (.doc file). Then, we use a managed package to send through e-mail this attachment. The problem is that when opening the .doc file through mobile device (e.g. IOS/Android), the source html code is shown instead of the word format content. When opening from desktop pc, everything is fine. What i observed is that event from my PC, after downloading the document, when trying to save it, the default type is Web Page.

  1. Has anyone faced similar issue and how was it handled?
  2. I tried to save the file as .docx but then it is not opened even from desktop pc. Is it possible to generate docx file through Salesforce?

1 Answer 1

1

Salesforce does not support generating native .doc files or .docx files. As per Salesforce documentation the visualforce page implementation is just an workaround. Visualforce pages can generate HTML and CSS content that may be returned to the browser as a file with .doc extension. This file may in turn be parsed by Microsoft Word, and a document may be presented to the end user assuming that the used markup meets Microsoft Word's requirements. This is due to Microsoft Word's ability to read old .doc files as .docx files.

This is really down to the browser/device capability rather than Visualforce to open this HTML page as word file.

You can use docx.js javascript library with LWC to generate native .docx files.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .