bubkoo / html-to-image

✂️ Generates an image from a DOM node using HTML5 canvas and SVG.
MIT License
5.41k stars 505 forks source link

NodeJS support? #338

Open webhype opened 1 year ago

webhype commented 1 year ago

Hi, is NodeJS support planned or is there a workaround to run this under NodeJS without loading a whole Chromium with it? There are a few Puppeteer/Chromium based libraries out there but they are rather heavyweight and the Chromium has to be compatible with the target OS. Thanks!

vivcat[bot] commented 1 year ago

👋 @webhype

Thanks for opening your first issue here! If you're reporting a 🐞 bug, please make sure you include steps to reproduce it. To help make it easier for us to investigate your issue, please follow the contributing guidelines.

We get a lot of issues on this repo, so please be patient and we will get back to you as soon as we can.

saltire commented 1 year ago

This would be cool and very useful, though I don't know how heavy it would be.

I tried running this with a jsdom node, but it didn't work: this library expects certain browser objects, such as HTMLCanvasElement, to be in global scope. I'm pretty sure jsdom implements those objects to some degree, but I'm not sure how complete they are, or how to bridge the gap so html-to-image can find them. Would be interesting to try though.