node-html-pdf icon indicating copy to clipboard operation
node-html-pdf copied to clipboard

Fonts don't work properly on server

Open gesangseto opened this issue 3 years ago • 4 comments

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

gesangseto avatar Sep 15 '22 06:09 gesangseto

Having the same problem

any way out ?

stevebaros avatar Oct 12 '22 12:10 stevebaros

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

Acidias avatar Nov 18 '22 21:11 Acidias

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.

gesangseto avatar Nov 19 '22 02:11 gesangseto

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.

shreyasgombi avatar Jun 19 '23 05:06 shreyasgombi