html2ps/pdf CSS 3 Compatibility List

Back to table of contents

Margin boxes

html2ps supports margin boxes in accordance to CSS 3. For example, you may render a header using the following CSS code:

@page {
  @top-left {
    content: "My Page";
  }
  @top-right {
    content: "Page " counter(page) " of " counter(pages);
  }
}

As an extension of the margin box specification, html2ps provides '-html2ps-html-content' property. In general, it is similar to 'content' property, except the resulting string is processed by HTML parser. Thus, you may use HTML tags in this property value.

@page {
  @top-left {
    -html2ps-html-content: "<span style="font-weight: bold;">My</span> Page";
  }
  @top-right {
    content: "Page " counter(page) " of " counter(pages);
  }
}

Note that you may set text formatting using usual CSS propeties in margin box context:

@page {
  @top-left {
    color: red;
    content: "My Page";
  }
  @top-right {
    content: "Page " counter(page) " of " counter(pages);
  }
}

For further information please refer to CSS 3 Paged Media Module. Note that html2ps at the moment does not support setting page size and margins via CSS.

Footnotes

Properties

Property Support Note
html2ps/pdf (c) TUFaT.com