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

Fonts don't work properly on server #693

Open gesangseto opened 2 years ago

gesangseto commented 2 years ago

Hello, I tried to load font , on localhost it all went smoothly, but it was different from the server

Depency:

"dependencies": {
    "body-parser": "^1.19.0",
    "bwip-js": "^3.1.0",
    "cors": "^2.8.5",
    "dotenv": "^8.2.0",
    "ejs": "^3.1.8",
    "express": "^4.17.1",
    "express-fileupload": "^1.2.1",
    "express-group-routes": "^1.1.0",
    "fs": "^0.0.1-security",
    "html-pdf-node": "^1.0.8",
    "moment": "^2.29.1",
    "sequelize": "^6.21.4",
    "tedious": "^15.1.0"
  }

Load font:

@font-face {
     font-family: "OCRB";
     src: url("/assets/font/OCRB_Medium.ttf");
 }
 .ocrb-font {
      font-family: "OCRB";
 }

Class:

<p class="ocrb-font">
      BATCH:  {...data}
      MFG / EXP:  {...data}
 </p>

In Local (font OCRB load): image

In Server (font not load): image

Development : Windows 10 x64 Server : Windows 10 x64

stevebaros commented 1 year ago

Having the same problem

any way out ?

Acidias commented 1 year ago

Hi,

I had the same issue. The problem may be on the server. Try to install those or look for other styles, and font packages for the Linux you're using. Firstly I would recommend to install/update puppeteer, that should fix it. But I couldn't install that so find a way to install separately some packages

I installed those: sudo yum install -y gconf-service libasound2 libatk1.0-0 libc6 libcairo2 libcups2 libdbus-1-3 libexpat1 libfontconfig1 libgcc1 libgconf-2-4 libgdk-pixbuf2.0-0 libglib2.0-0 libgtk-3-0 libnspr4 libpango-1.0-0 libpangocairo-1.0-0 libstdc++6 libx11-6 libx11-xcb1 libxcb1 libxcomposite1 libxcursor1 libxdamage1 libxext6 libxfixes3 libxi6 libxrandr2 libxrender1 libxss1 libxtst6 ca-certificates fonts-liberation libappindicator1 libnss3 lsb-release xdg-utils Also, try: yum install at-spi2-atk yum install libdrm.so.2 yum install libdrm yum install libgbm yum install xmms yum install xorg-x11-fonts-75dpi.noarch

gesangseto commented 1 year ago

Hi,

I had the same issue. The problem may be on the server. Try to install those or look for other styles, and font packages for the Linux you're using. Firstly I would recommend to install/update puppeteer, that should fix it. But I couldn't install that so find a way to install separately some packages

I installed those: sudo yum install -y gconf-service libasound2 libatk1.0-0 libc6 libcairo2 libcups2 libdbus-1-3 libexpat1 libfontconfig1 libgcc1 libgconf-2-4 libgdk-pixbuf2.0-0 libglib2.0-0 libgtk-3-0 libnspr4 libpango-1.0-0 libpangocairo-1.0-0 libstdc++6 libx11-6 libx11-xcb1 libxcb1 libxcomposite1 libxcursor1 libxdamage1 libxext6 libxfixes3 libxi6 libxrandr2 libxrender1 libxss1 libxtst6 ca-certificates fonts-liberation libappindicator1 libnss3 lsb-release xdg-utils Also, try: yum install at-spi2-atk yum install libdrm.so.2 yum install libdrm yum install libgbm yum install xmms yum install xorg-x11-fonts-75dpi.noarch

Yes, you're right, I just need to install the font directly onto the server, in this case I'm using a Windows server so I only need to double click the font to install. it's not just the font, but the css that I made is also not exactly the same as Local when it's built on a server, so every time I build an application on another server, I have to adjust the css and font.

shreyasgombi commented 1 year ago

Hi,

I had the same issue. The problem may be on the server. Try to install those or look for other styles, and font packages for the Linux you're using. Firstly I would recommend to install/update puppeteer, that should fix it. But I couldn't install that so find a way to install separately some packages

I installed those: sudo yum install -y gconf-service libasound2 libatk1.0-0 libc6 libcairo2 libcups2 libdbus-1-3 libexpat1 libfontconfig1 libgcc1 libgconf-2-4 libgdk-pixbuf2.0-0 libglib2.0-0 libgtk-3-0 libnspr4 libpango-1.0-0 libpangocairo-1.0-0 libstdc++6 libx11-6 libx11-xcb1 libxcb1 libxcomposite1 libxcursor1 libxdamage1 libxext6 libxfixes3 libxi6 libxrandr2 libxrender1 libxss1 libxtst6 ca-certificates fonts-liberation libappindicator1 libnss3 lsb-release xdg-utils Also, try: yum install at-spi2-atk yum install libdrm.so.2 yum install libdrm yum install libgbm yum install xmms yum install xorg-x11-fonts-75dpi.noarch

Facing a similar issue for my Azure's App Service & GCP's App Engine. Any suggestion? I also see that the emails are getting missed randomly without throwing any error. My assumption is that some of these libraries are missing as well.