use custom fonts with wkhtmltopdf

前端 未结 9 1492
难免孤独
难免孤独 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:52

    I'll just add my answer here too, in case someone might need it.

    I've been using Rotativa which builds upon wkhtmltopdf, and what I ended up using was the following:

    @font-face {
        font-family: "testfont";
        src: url("/UI/Fonts/609beecf-8d23-4a8c-bbf5-d22ee8db2fc9.woff") format("woff"),
             url("/UI/Fonts/1cd9ef2f-b358-4d39-8628-6481d9e1c8ce.svg#1cd9ef2f-b358-4d39-8628-6481d9e1c8ce") format("svg");
    }
    

    ...and it seem's Rotativa is picking up the SVG-version. If I reorder them it still works, but if I remove the SVG-version, it stops working.

    Might be worth a shot. Can't find any good documentation on why this is so, however

提交回复
热议问题