html-to-docx
html-to-docx copied to clipboard
Image is not generating in word from html with out base64.
Hi,Thanks for this useful and updated library at first. There is one issue I am facing. I cant add image in doc when converting html to docx. I want to add image with out base64 encoding like normal html image. Is this possible?
@diptobuet Sorry for the delay in answering this, I haven't had the time to go through this repo for sometime now.
What do you mean normal html image?
@privateOmega I think he means
<img src="https://i.picsum.photos/id/816/200/200.jpg?hmac=ZNsj0gw4AJtSDA82gMxujRjh3_5ZHoVje8CtZopmcz4" />
Non-base64 sources.
Currently is there any way to get this working ?
@TheDarkStrix Sorry, i haven't had the time to look at anything on this project for sometime now, and unless we get someone who could help us out in this matter, there isn't much for now, sorry for that.
const imageToBase64 = require('image-to-base64');
...
// loop through img elements before converting html to docx
// img.src = getImageBase64(img.src)
async function getImageBase64(imgSrc) {
const pre = 'data:image/png;base64, ';
return new Promise((resolve, reject) => {
imageToBase64(imgSrc)
.then((res) => { return resolve(pre + res); })
.catch((error) => { return reject(error); })
});
}
<img src="data:image/jpeg;base64,/9j/4AAQSkZJRgAB...">actually it's not work with my inlined base64 image
eventually I chose html-docx-js