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

Does not show image in PDF #618

Open juanfeorar opened 3 years ago

juanfeorar commented 3 years ago

I am trying generate PDF from simple code, but no show image. Please help me

Code:

pdf.create("Hello <img src='j4.jpg' />").toFile('./pdf/cotizacion.pdf', function (err) { if (err) { console.log(err); } else { console.log("File created successfully "); } });

Result:

image

real-artswan commented 3 years ago

I believe it is related to the new option localUrlAccess And it seems this option doesn't work https://github.com/marcbachmann/node-html-pdf/issues/620

ays-code commented 3 years ago

You have to use the option base: // Rendering options "base": "file:///home/www/your-asset-path/", // Base path that's used to load files (images, css, js) when they aren't referenced using a host