Node-html-pdf: @font-face not working in pdf format

Created on 18 Aug 2017  路  4Comments  路  Source: marcbachmann/node-html-pdf

Hi
i want to using a persian font and it works fine in html but when converting to pdf the font does not working , i think it can not read the local saved font

@font-face {
  font-family: Shabnam;
  src: url('Shabnam.ttf') format('truetype');
}

what should i do?

Most helpful comment

If you like to load the assets from the local file system, you'll need to use an absolute path to your file: file:///absolute/path/to/asset

There's also a base option to set that by default.
https://github.com/marcbachmann/node-html-pdf/blob/d7ae2439ef8082475a80f3045ddfa6dce7c5054e/bin/index.js#L27

On windows that's file:///C:/absolute/path/to/asset

All 4 comments

Experiencing the same issue. the difference is I'm using

@font-face{
font-family: 'Code128bWin';
src: url('/fonts/Code128bWin.eot');
src: url('/fonts/Code128bWin.eot?iefix') format('eot'),
url('/fonts/Code128bWin.woff') format('woff'),
url('/fonts/Code128bWin.ttf') format('truetype'),
url('/fonts/Code128bWin.svg#webfont') format('svg');
}

I'm using [email protected]

@marcbachmann can you help us please

If you like to load the assets from the local file system, you'll need to use an absolute path to your file: file:///absolute/path/to/asset

There's also a base option to set that by default.
https://github.com/marcbachmann/node-html-pdf/blob/d7ae2439ef8082475a80f3045ddfa6dce7c5054e/bin/index.js#L27

On windows that's file:///C:/absolute/path/to/asset

@marcbachmann thanks for the help! I used http host to load the fonts.

@font-face{
font-family: 'Code128bWin';
src: url('https://testurl.com/test/fonts/Code128bWin.eot');
src: url('https://testurl.com/test/fonts/Code128bWin.eot?iefix') format('eot'),
url('https://testurl.com/test/fonts/Code128bWin.woff') format('woff'),
url('https://testurl.com/test/fonts/Code128bWin.ttf') format('truetype'),
url('https://testurl.com/test/fonts/Code128bWin.svg#webfont') format('svg');
}

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ascsi picture ascsi  路  3Comments

anmolgoyal74 picture anmolgoyal74  路  4Comments

rayax86 picture rayax86  路  5Comments

jimit-hothi picture jimit-hothi  路  4Comments

hishamabutt picture hishamabutt  路  4Comments