Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

python pdfkit: increase font size

I transformed an HTML file into a pdf simply by:

pdfkit.from_file("cpp.html",'cpp.pdf')

Problem is that the font-size is very small.

How to increase the font-size (both of headers and paragraphs) using pdfkit? Obviously I want the headers font to remain bigger than the paragraphs font.

I guess I have to tweak the options, but I can't find how.

like image 333
Pigna Avatar asked Feb 07 '23 22:02

Pigna


2 Answers

In my case manually setting dpi helped.

options = {
    'dpi':96,
}
pdfkit.from_url(url,out_file,options=options)
like image 175
zuku Avatar answered Feb 11 '23 23:02

zuku


There's also a zoom option, which solved the problem for me. (Takes a Float)

    options = {
    'zoom': 2,
}
pdfkit.from_url(url,out_file,options=options)
like image 45
Woolwit Avatar answered Feb 12 '23 00:02

Woolwit