I have an html page with simple css2 rules. All of the content is contained in a div, which is 930px wide. In the browser, this looks as expected, and when printing (from chrome) it fits neatly to the page with a decent font size.
Once I try to create a PDF from this file using weasyprint, the font look much bigger, and the document exceeds the page width.
HTML(string=html, base_url=server_base_url).write_pdf(target=target)
I'm not really sure how to debug the issue. Weasyprint does not seem to suppose print scaling, which is what I assume chrome is doing. Taking the document, rendering it, and then scaling it to fit on the page.
I tried using the zoom
parameter of the write_pdf
method .write_pdf(target=target, zoom=0.7)
, but it seems to zoom the page size AND the content size, so that is no help, really. I tried combining it with css to make the page bigger. So I zoom down with weasy and scale up with css
@page {
size: XXXin YYYin
}
This just ended up looking weird. So where do I go from here?
Have you tried using
@page {
size: Letter;
margin: 0in 0.44in 0.2in 0.44in;
}
You can adjust the margin as you like, but the Letter size should be the standard page size
page size
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With