use custom fonts with wkhtmltopdf

前端 未结 9 1459
难免孤独
难免孤独 2020-12-03 01:12

I am trying to use custom fonts in my PDF generated with wkhtmltopdf. I read that you can\'t use google webfonts and that wkhtmltopdf uses truetype .ttf file. Can anyone con

9条回答
  •  情歌与酒
    2020-12-03 01:43

    If you have .ttf file or .woff file then use following syntax

    @font-face {
       font-family: 'Sample Name';
       src: url(/PathToFolderWhereContained/fontName.ttf) format('truetype');
       }
    

    don't use ttf that will not work rather use full name 'truetype' and if you have .woff then use 'woff' in format. For my case it worked.

    However the best practice is to use links to Google fonts API that is best if not getting that matching your criteria then use this above technique it will work

提交回复
热议问题