You are currently offline, serving cached version
7th May 2026 : If you are using angular-expressions to parse expressions such as {user.name}, {#users.length > 10}, please upgrade asap to angular-expressions@1.5.2 for security reasons : View Github issue

Browser docxtemplater full version

Description

This project provides a library usable in the browser with advanced features for docxtemplater (including all modules).

It allows a user to load a template file, fill it with predefined data, and then save the generated document.

Features

  • Loads a DOCX/PPTX/XLSX template from a URL
  • Populates the template with sample user data
  • Generates a DOCX/PPTX/XLSX file
  • Handles errors and saves documents with comments if issues arise
  • Add images using the {%logo} syntax
  • Add HTML using the HTML module
  • Access to all 18 modules
  • Configuration with the same object as the docker version
  • Filters for data

Installation

Once you've downloaded the code, you can have a look at our demo by opening index.html in a browser.

To use the software, simply add a single script tag like this :

<script src="built/docxtemplater.umd.js"></script>

Detailed Usage Explanation

  1. Retrieve the docGeneration Object:

    /* eslint-disable-next-line no-unused-vars */
    const dg = window.docGeneration;
    
    • The docGeneration object is accessed from the window object, which is provided globally by the library.
  2. Load the DOCX Template:

    /* eslint-disable-next-line no-undef,no-unused-vars */
    const content = await dg.loadFile(
        "https://docxtemplater.com/ang-example.docx"
    );
    
    • This loads the document template from a given URL.
  3. Define the Data to Inject:

    /* eslint-disable-next-line no-unused-vars */
    const data = {
        first_name: "John",
        last_name: "Doe",
        phone: "John",
        organization: {
            companyName: "Acme Ecorp",
        },
        description: "The long description",
    };
    
    • This object contains the key-value pairs that will replace placeholders in the template.
  4. Generate the Document:

    const configuration = {};
    /* eslint-disable-next-line no-undef,no-unused-vars */
    const { blob, errorLocation } = await dg.generateDocument(
        /* eslint-disable-next-line no-undef */
        content,
        data,
        configuration
    );
    
    • The generateDocument function processes the template and applies the provided data.
    • If there are errors, errorLocation will be true.

    The configuration object has the same configuration keys as the docker version.

  5. Save the Output:

    /* eslint-disable-next-line no-undef */
    if (errorLocation) {
        /* eslint-disable-next-line no-undef */
        dg.saveAs(blob, "template-with-errors-comments.docx");
    } else {
        /* eslint-disable-next-line no-undef */
        dg.saveAs(blob, "output.docx");
    }
    
    • If errors are detected, the document is saved with comments highlighting them.
    • Otherwise, the correctly generated document is saved as output.docx.

Changing delimiters

It is possible to change the delimiters by using the following code :

const configuration = {};
/* eslint-disable-next-line no-undef,no-unused-vars */
const { blob, errorLocation } = await dg.generateDocument(
    /* eslint-disable-next-line no-undef */
    content,
    data,
    configuration,
    {
        query: { delimiters: "[[ ]]" },
    }
);

License

Full license information can be found here

CHANGELOG

3.2.2

Add additional security measures (previous versions were already secure thanks to the CSP option which was set to true by default)

  • Update to angular-expressions 1.5.2
  • Update @xmldom/xmldom to 0.9.10
  • Update docxtemplater to 3.68.7
  • Update filters to use Object.create(null)
  • Update chart module to v3.21.1
  • Update html module to v3.68.1
  • Update pptx-sub module to v3.1.15
  • Update qrcode module to v3.5.6
  • Update xlsx module to v3.38.6

3.2.1

Bugfix error that would always happen with 3.2.0 :

Cannot read properties of undefined (reading 'getValue')

This is now fixed

3.2.0

  • Update to add ImageModule as submodule of HtmlPptxModule for support for
  • Update to add ImageModule as submodule of HtmlXlsxModule for support for
  • Update chart-module-3.21.0
  • Update docxtemplater to 3.68.4
  • Update html-module-3.67.1
  • Update html-pptx-module-3.12.0
  • Update html-xlsx-module-3.7.7
  • Update image-module-3.35.7
  • Update qrcode-module-3.5.5
  • Update slides-module-3.8.8
  • Update subtemplate-module-3.22.0
  • Update table-module-3.31.4
  • Update xlsx-module-3.38.3

3.1.0

  • Update html-xlsx v3.7.4
  • Update html v3.66.2
  • Update slides v3.8.6
  • Update error-location v3.10.2
  • Update chart v3.20.2
  • Update xlsx v3.38.0
  • Update image v3.35.3
  • Update table v3.31.3
  • Update word-run v3.3.1
  • Update subtemplate v3.21.5
  • Update subsection v3.6.1
  • Update styling v3.10.3
  • Update qrcode v3.5.4
  • Update pptx-sub v3.1.14
  • Update paragraph-placeholder v3.5.11
  • Update meta v3.17.4
  • Update html-pptx v3.11.2
  • Update footnotes v3.5.1

3.0.1

  • Update footnotes v3.4.8
  • Update html-pptx v3.7.0
  • Update html-xlsx v3.2.9
  • Update html v3.56.6
  • Update image v3.31.3
  • Update paragraph-placeholder v3.5.10
  • Update slides v3.7.1
  • Update table v3.26.2
  • Update xlsx v3.29.2

3.0.0

Initial version

Talk with sales Contact us