marcbachmann / node-html-pdf

This repo isn't maintained anymore as phantomjs got dreprecated a long time ago. Please migrate to headless chrome/puppeteer.
MIT License
3.56k stars 545 forks source link

Image is transparent after generating to PDF #545

Open shivamcipl opened 4 years ago

shivamcipl commented 4 years ago

Hi, I tried converting HTML with images to PDF. But the image is transparent after the conversion.

AndroConsis commented 4 years ago

What is the image source you are using to show the Images, If you are using local images, then you need to give the absolute path of the image file in the source <img src="file:///C:/wamp/www/site/img/mypicture.jpg"/>

Notice the file:/// in the path

zivchen commented 4 years ago

same here

sankarpetro commented 4 years ago

same here

shivamcipl commented 4 years ago

@AndroConsis I was using, <td class="logo-area" style="padding: 20px 50px 20px 50px;"><img src="logo-brand-10.png" alt="" /></td>

And the file:/// path I have provided in the options tag of html-pdf like, base: 'file://' + path.resolve('public/files/uploads/') + '/'

zivchen commented 4 years ago

For me the issue has been resolved when i removed format A4 from the config (left it with out format just width and height)

bowdentheo commented 3 years ago

Setting the image's class to position: relative; fixed it for me.

My options:

var options = { width: '210mm', height: '297mm', format: "A4", }