I have reproduced my problem below :
I draw a 210x297 rectangle on a web page
<!DOCTYPE html>
<html>
<style>
div.rectangle {
border: solid 1px;
width: 210mm;
height: 297mm;
}
</style>
<head>
</head>
<body>
<div class="rectangle">
<img/>
</div>
</body>
</html>
I transform this html document to pdf with pdfkit in Python
import pdfkit
options = {
'page-size':'A4',
'encoding':'utf-8',
'margin-top':'0cm',
'margin-bottom':'0cm',
'margin-left':'0cm',
'margin-right':'0cm'
}
pdfkit.from_file('test.html', 'test.pdf', options=options)
I obtain a pdf file with a rectangle at the top left corner whose size is roughly 5 times too small...
I would really appreciate if you can have a look !
For me manual set up of the DPI works as workaround:
options={'page-size':'A4', 'dpi':400}
you can try to disable shrinking through the options as below
options = { 'disable-smart-shrinking': ''}
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