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

Footers/headers require inline font-size declaration in px in order to display #160

Open
hxlnt opened this issue Apr 12, 2023 · 1 comment

Comments

@hxlnt
Copy link

hxlnt commented Apr 12, 2023

I am not able to see a footer.html get injected into the PDF or debug HTML, either via CLI or the Node API.

For example:
mdpdf topic.md --style=print.css --footer=footer.html --debug --f-height=40px
does not throw any errors and creates a PDF and HTML page, using the CSS provided, but without any footer tags or content in the debug HTML or PDF. (I'm not sure if it's supposed to appear in the debug HTML or if it's injected in the PDF stage.)

Debugging steps I've tried:

  1. Changing footer to header (also doesn't work)
  2. Path to footer.html is confirmed correct (CLI will fail if path is wrong)

footer.html content:
<footer><div style="font-size: 1rem;">TEST</div></footer>

@hxlnt
Copy link
Author

hxlnt commented Apr 12, 2023

Was able to resolve this after looking through puppeteer/puppeteer#1822 and doing some more debugging on my own. Looks like there are two issues with how Puppeteer is rendering text in headers/footers:

  1. The default text size is 0 if not specified (via inline CSS, for example). Font size must be explicitly declared in headers and footers.
  2. rem units are seemingly interpreted as px, so setting font-size: 1rem renders it essentially invisible. Rem units should not be used to set font size in headers and footers.

I suppose this is a quirk with Puppeteer, but since this issue was logged in 2018, I'm not sure if a fix is on the way. It would be great to add this to the documentation and update the samples so others don't experience the same issue.

@hxlnt hxlnt changed the title Footers and headers not inserted (CLI and API) Footers/headers require inline font-size declaration in px in order to display Apr 12, 2023
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

1 participant