html-to-docx icon indicating copy to clipboard operation
html-to-docx copied to clipboard

Image is not generating in word from html with out base64.

Open diptobuet opened this issue 4 years ago • 7 comments

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 avatar Mar 02 '21 10:03 diptobuet

@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 avatar Apr 19 '21 06:04 privateOmega

@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 avatar Aug 09 '21 13:08 TheDarkStrix

@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.

privateOmega avatar Aug 15 '21 13:08 privateOmega

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); })
    });
}

pbw3 avatar Jan 28 '22 01:01 pbw3

<img src="data:image/jpeg;base64,/9j/4AAQSkZJRgAB...">actually it's not work with my inlined base64 image

Arman19941113 avatar Mar 09 '22 09:03 Arman19941113

eventually I chose html-docx-js

Arman19941113 avatar Mar 09 '22 09:03 Arman19941113