Generating a Downloadable Word Document in the Browser

As a developer, generating files for a user to download from a website is a fairly common task. The use cases range from providing a PDF of event tickets or a receipt, to generating a custom image from user-entered data. Regardless of the purpose, a developer is faced with a decision, “Do I generate the file server- or client-side?” In most cases, generated files for user download should be created on the server.

One reason to generate files server-side is security. For example, when applying an image watermark client-side anyone can use a proxy or browser developer tools to get the original image. If the watermark is applied server-side the user never has access to the original image and cannot strip out the watermark.