question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Header/Footer HTML Path

See original GitHub issue

When using wkhtmltopdf in command line, I can specify a local HTML file to use as the footer (or header):

wkhtmltopdf --footer-html .\footer.html .\content.html output.pdf

When I pass that reference in the options variable:

options = {"footer-html":"footer.html"}

… PDFKit never works for me. Passing a url (mentioned here) does work:

options = {"footer-html":"http://google.com"}

Two questions:

  1. Is it possible to pass a reference to a local HTML file?
  2. If so, where does the file need to be relative to? I have tried relative and absolute paths, neither seem to work.

Thanks!

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
Jiishcommented, Jul 14, 2017

@arasub I am facing same issue as @gavinr. I want to use a locally stored .html file in my generated pdf. When calling wkhtmltopdf on command line, I can use --footer-html file://path/to/file/file.html, but this does not work with pdfkit. I do not want to access the html via URL, but using file:// locally.

0reactions
JazzCorecommented, Mar 20, 2021

Seems working for me, tried with this:

options = {"footer-html":"footer.html"}
pdfkit.from_string('test data', 'out.pdf', options=options, verbose=True)

Path handling is done by wkhtmltopdf but I think that it can handle both relative and absolute path, working directory for it is the same as the directory for python env.

Feel free to reopen, but please provide a reproducible test case

Read more comments on GitHub >

github_iconTop Results From Across the Web

Make header and footer files to be included in multiple html ...
I'd like to use javascript. Is there a way to do this using only html and JavaScript? I want to load a header...
Read more >
Creating a Header/Footer to be Used on all Pages - Htmlcenter
The path you use in your include statement can be one of many different types of paths. The path can be relative to...
Read more >
Add HTML Header or Footer - Encodian Support
HTML Header / Footer : The HTML fragment to embed within the location specified. Location: Set whether the HTML fragment should be added...
Read more >
<footer> - HTML: HyperText Markup Language - MDN Web Docs
The HTML element represents a footer for its nearest ancestor sectioning content or sectioning root element.
Read more >
Developers - Header/Footer HTML Path - - Bountysource
Header/Footer HTML Path. python-pdfkit. 13 September 2016 Posted by Gavin Rehkemper. When using wkhtmltopdf in command line, I can specify a local HTML...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found