You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi, thanks for this awesome package. I noticed when using it that it does not grab the alt text from the Word doc into the HTML img element, so I edited the code to do so.
In the DocumentParser.parsePicture() method, at line 1080, I changed the result object to include an altText prop: var result = { type: dom_1.DomType.Image, src: "", cssStyle: {}, altText: "" };
... then at line 1086 I added the following three lines to grab the alt text from the .docx file: var nvPicPr = xml_parser_1.default.element(elem, "nvPicPr"); var cNvPr = xml_parser_1.default.element(nvPicPr, "cNvPr"); result.altText = xml_parser_1.default.attr(cNvPr, "descr");
Finally, in the HtmlRenderer.renderImage() method at line 3088, I added the new prop in the call to createElement(): let result = this.createElement("img", {alt: elem.altText});
Hopefully, this is something you can use! Thanks again!
The text was updated successfully, but these errors were encountered:
Hi, thanks for this awesome package. I noticed when using it that it does not grab the alt text from the Word doc into the HTML img element, so I edited the code to do so.
In the DocumentParser.parsePicture() method, at line 1080, I changed the result object to include an altText prop:
var result = { type: dom_1.DomType.Image, src: "", cssStyle: {}, altText: "" };
... then at line 1086 I added the following three lines to grab the alt text from the .docx file:
var nvPicPr = xml_parser_1.default.element(elem, "nvPicPr"); var cNvPr = xml_parser_1.default.element(nvPicPr, "cNvPr"); result.altText = xml_parser_1.default.attr(cNvPr, "descr");
Finally, in the HtmlRenderer.renderImage() method at line 3088, I added the new prop in the call to createElement():
let result = this.createElement("img", {alt: elem.altText});
Hopefully, this is something you can use! Thanks again!
The text was updated successfully, but these errors were encountered: