letter-spacing is too large with wkhtmltopdf

后端 未结 9 1217
情书的邮戳
情书的邮戳 2021-02-06 07:30

I\'m using wkhtmltopdf to download a webpage as pdf.

But the css property letter-spacing seems doesn\'t work

font-size:20px; letter-spacing:0px;
<         


        
9条回答
  •  甜味超标
    2021-02-06 07:54

    Issue every one face with letter spacing, perfect solution is here.

    import pdfkit
    #SnippetBucket.com code for pdfkit
    path_wkthmltopdf = r'/var/www/aukcnydom/wkhtmltox/bin/wkhtmltopdf'
    config = pdfkit.configuration(wkhtmltopdf=path_wkthmltopdf)
    #more better and more accurate code for DPI set
    config.default_options = {
            'page_size': 'A4',
            'print_media_type': True,
            'dpi': 96
        }
    pdfkit.from_string(mark_safe(unicode(self.document)),settings.MEDIA_ROOT +"/"+ path, options=options, css=style,  configuration=config)
    

    Than in css. Add your letter-spacing.

    p{letter-spacing: 0.4mm !important; text-align: justify ; font-kerning: normal; text-rendering: optimize-speed;}
    /* SNIPPETBUCKET.COM, CSS CODE WITH LETTER SPACING */
    

    This way simply resolve your issue and work perfectly letter spacing.

    Note: I had given sample, you may apply applicable changes with your code.

提交回复
热议问题