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 543 forks source link

Promlem with fonts #564

Open AlexanderKudryavsky opened 4 years ago

AlexanderKudryavsky commented 4 years ago

If you look at the screenshot, you can see that some letters are indented. photoeditorsdk-export I add the font like this: @font-face { font-family: "Roboto-Regular"; font-weight: 500; src: url("../../../static/fonts/Roboto-Regular.ttf"); } base path is correct! Anyone have a solution?

andypopa commented 4 years ago

The way I do it is I install the fonts on the server running the app.

I use Times New Roman, Arial on an Ubuntu 18.04 server.

You can install these fonts with sudo apt-get --reinstall install ttf-mscorefonts-installer

hm2206 commented 4 years ago

I have a similar problem, what happens is that the font size is out of square on my production server. in the local font size comes out normal and when I upload it to my remote server (ubuntu 18.04) the letters come out bigger

andypopa commented 4 years ago

I’ve had this issue with HTML documents made on Windows and uploaded to Ubuntu 18.04. The ones made on macOS work fine.

Op vr 31 jul. 2020 om 01:45 schreef jocker2206 notifications@github.com

I have a similar problem, what happens is that the font size is out of square on my production server. in the local font size comes out normal and when I upload it to my remote server (ubuntu 18.04) the letters come out bigger

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/marcbachmann/node-html-pdf/issues/564#issuecomment-666753537, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABZY2PVPRH5OJTUYXMEBFSTR6HZYJANCNFSM4L2L5D4Q .

andypopa commented 4 years ago

Also, the the ttf-mscorefonts are different from the fonts used on a Windows machine. They don’t contain diacritics. If you were to install the fonts from a Windows machine in Ubuntu, you’d get the diacritics - however I don’t know if this is legal as far as licensing goes.

golakotisowmya commented 4 years ago

I am also facing this issue .Is there any way to solve this?

golakotisowmya commented 4 years ago

If you look at the screenshot, you can see that some letters are indented. photoeditorsdk-export I add the font like this: @font-face { font-family: "Roboto-Regular"; font-weight: 500; src: url("../../../static/fonts/Roboto-Regular.ttf"); } base path is correct! Anyone have a solution?

did u got any solution?

latobibor commented 3 years ago

The solution before localUrlAccess: false was to use url('file:///<absolute path>'). But now it is impossible. What do you suggest @marcbachmann ?

marcbachmann commented 3 years ago

localUrlAccess: true is safe to use if you don't have any secrets where the process is running. e.g. with docker when you have an isolated service.

The most compatible solution is to run a local http server that serves the assets. That's also a good solution when you plan the migration to a headless chromium together with puppeteer or another library.