Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Images and internal links don't work? #508

Open
chris-bingham opened this issue May 24, 2019 · 3 comments
Open

Images and internal links don't work? #508

chris-bingham opened this issue May 24, 2019 · 3 comments

Comments

@chris-bingham
Copy link

I am unable to get images to work in the generated PDF, if i prefix the base value with file:// i get a broken image, otherwise I just get the image alt text.

I have links within the HTML to various elements within the same page, these don't work and are prefixed with the value of the base property.

Any help with images would be greatly appreciated, and is it possible to have internal links?

Heres my code:

var html = fs.readFileSync(htmlName, "utf8");
var options = {
    phantomPath: require("phantomjs-prebuilt").path,
    base: "file://" + path.resolve(".")
};

pdfFromHtml.create(html, options).toFile(pdfName, function(err, res) {});
@Serhioromano
Copy link

Try to save your HML to file first and open that file from the folder you saved it and see if you see images. It is obviously a problem with images path.

@Joshmamroud
Copy link

Try ending the base path with a "/". That worked for me.

tymekg added a commit to tymekg/node-html-pdf that referenced this issue Oct 4, 2019
@btlakal
Copy link

btlakal commented Oct 13, 2020

Please let me know if anyone got the solution for the internal links

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants