letter-spacing is too large with wkhtmltopdf

Its a known issue. https://github.com/wkhtmltopdf/wkhtmltopdf/issues/1575 . No fix for it. Only to avoid using letter-spacing


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.


I had the same problem, I set the dpi to 96 (in wkhtmltopdf options) and worked, not sure why though.

Tags:

Wkhtmltopdf