Google Web Fonts and PDF generation from HTML with wkhtmltopdf

前端 未结 9 2138
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-11-30 18:58

I am using wkhtmltopdf to convert HTML files in PDF format; it gives surprisingly good results, rendering the PDF exactly as WebKit would do.

I am using Google Web F

相关标签:
9条回答
  • 2020-11-30 19:30

    I've just tested that using the @importnotation works:

    <style>
    @import 'https://fonts.googleapis.com/css?family=Montserrat';
    </style>
    

    I'm using django-wkhtmltopdf version 2.0.3

    0 讨论(0)
  • 2020-11-30 19:34

    To convert HTML to PDF by wkhtmltopdf try to avoid woff font face. Use the truetype format of the Google Web Fonts with base64 encode.

    Recently I tried to use a Google web font from Google Web Fonts. In the browser it shows correctly but it doesn't show after converting HTML to PDF.

    After searching the web extensively, at last, I found tools to encode fonts to the base64 format and also got CSS for @font-face.

    Read the solution here.

    0 讨论(0)
  • 2020-11-30 19:34

    Make sure you're not declaring what font you are printing with in your print stylesheet.

    0 讨论(0)
提交回复
热议问题