guigrpa / docx-templates

Template-based docx report creation
MIT License
882 stars 145 forks source link

Injecting images in Html #336

Closed loizos01 closed 8 months ago

loizos01 commented 10 months ago

Hello, there are similar issues but nothing worked for me, I am trying to inject images in html. I tried with base64 and with the url it self but nothing works. Any idea?

const dataUrl = await imageToBase64(`http://docxtemplater.com/puffin.png`);
questionHtml +=`<p><img  style="height:100px" src="data:image/png;base64, ` + dataUrl + `" alt="test"/></p>`; 

The following is in a for loop but ignore that, the rest of the information is displayed only the , <img> element is not shown
``+++HTML `
<meta charset="UTF-8">
<style>
table {
table-layout: fixed;
border-collapse: collapse;
margin: 0 auto;
width: 17cm;
}
th {
border: 1px solid #585858;
padding: 2px 4px;
}
td {
padding: 0 4px;
border: 1px solid #585858;
}
</style>
<body>
 ${questionsListTableHtml[$question]}
</body>
`+++
jjhbw commented 9 months ago

I can't really tell from this example what goes wrong. Can you provide executable code to reproduce this?