open-xml-templating/docxtemplater

pStyle on <img> tags

micahvandeusen opened this issue · 3 comments

Environment

  • Version of docxtemplater : 3.36.1
  • Used docxtemplater-modules : Image, HTML
  • Runner : Browser

How to reproduce my problem :

With the following in the JS file it does not appear to apply the style to <img> tags. It works for <pre> tags so does not appear to be an issue with the template.

  htmlModuleOptions.elementCustomizer = function (element) {
    if (element.name === "img") {
      return {
          pStyle: "Image",
      };
    }
  }

Please use the email address that you can find at https://docxtemplater.com/ in the "Contact Us" button next time.

I will hopefully provide a bugfix for this tomorrow.

Best,

Edgar

I'm guessing that you want this only for block images (since inline images don't have a pStyle).

Hello @micahvandeusen ,

This was now fixed in the new version of the HTML/image module :

HTML module : 3.35.4
Image Module : 3.19.2

You have to upgrade both in order to make it work.

The simplest is to update all your docxtemplater related dependencies
using following command :

npm install docxtemplater && npx -y update-docxtemplater && npm install