node-html-pdf: Bold text are ignored from html to pdf
Hello, it seens I can’t get the bold text in html files passed to the pdf. I tried different ways to get my text bold but none of the attempts were successful.
My attempts
- HTML element
<strong></strong> - HTML element
<b></b> - CSS property
font-weight: bold;
Maybe there is a problem?
About this issue
- Original URL
- State: open
- Created 6 years ago
- Reactions: 30
- Comments: 34
A solution that works for my needs : include in the HTML the google font link :
not perfect but it does the job for me
@sulaysumaria No it isn’t, but as I said above, it doesn’t effect production (on linux), only dev on my mac. So I don’t care.
A workaround is to use something like font-weight: 700; property. I am using it and it works pretty fine.
Maybe this helps others as well, I ended up using Puppeteer for pdf creation:
For anyone still looking:
I was importing fonts from google. I added the “bold” fonts also when selecting fonts and it worked.
Posting here because I didn’t find this solution anywhere else.
@MarcGodard Thanks for reporting, but before deploying an app to heroku you will probably want to test it, and the best way to do this is locally. It looks like an OS fonts/PhanthomJS problem, but this issue is helping people to address the problem so I’ll let it here.
In my case, It’s working when we are defining in CSS
<style> b{ font-weight: bold; } </style>Now, use b tags to make fonts bold.
It’s happening to me in Mojave. However, once deployed to Heroku, works fine.