README

Html Pptx Module

This module allows to add some HTML to a powerpoint document (pptx).

Limitations

It is not possible to mix different types of HTML elements in a single shape.

In the PPTX format, everything is inside a "box" which is techically called a "shape" (XML tag <p:sp>) , and a box can contain either :

  • one or multiple paragraphs
  • one table
  • one shape
  • one image

The box is statically positioned (x and y coordinate).

In a pptx template, the tag {~~html} will be inside one particular box, so it can't generate multiple boxes (or they would overlap, which would be unreadable).

This is why one HTML tag : {~~html} will alway render one box, so for example the following HTML data would throw an error because it mixes tables and paragraphs :

<p>Hello</p>
<table>
  <tr>
    <td><p>Hello</p></td>
  </tr>
</table>
<p>Hello</p>

The HTML module currently supports:

  • <p>
  • <h1-h6> with some default sizes for each level, the sizes of the titles can be customized
  • <span>
  • <br>
  • <ul>, <ol> and <li> for ordered and unordered lists
  • <strong> and <em>
  • <a href="URL">Linktext</a>

Options

It is possible to set options to the htmlPptxModule in the constructor of the module.

Description of the options :

  • ignoreUnknownTags [default=false]: If this option is set to true, and the module finds an HTML tag that it doesn't handle, it will not fail but instead make as if the tag was of type <span>;
  • ignoreCssErrors [default=false]: If this option is set to true, all CSS errors are ignored and the library tries to parse the CSS with a best-effort algorithm;
  • styleSheet makes it possible to add style to all HTML tags that are inserted.

To ignore all unknown tags:

const module = new HTMLModule({
    ignoreUnknownTags: true
});

CHANGELOG

3.0.1

Add support for <u>, <sub> and <sup> tag and for style : text-decoration: underlined.

3.0.0

Initial release

Edgar Hipp

I'm the creator of docxtemplater. I work on making docxtemplater great since 2013.