Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

wkhtmltopdf Default Settings?

I am using laravel-snappy as a wrapper for wkhtmltopdf for creating PDFs out of HTML.

While running the same code with the same configuration, I am getting different outputs:

CentOS output: enter image description here (centered correctly but with big margin at the bottom)

macOS output: enter image description here (right part is cropped, and also theres a big margin at the bottom)

Both environments are using wkhtmltopdf 0.12.4 (with patched qt), any ideas for this difference?

like image 544
Broshi Avatar asked Jan 30 '23 10:01

Broshi


1 Answers

There are a couple of things you can try:

--disable-smart-shrinking

--dpi 96 Experiment with this number to get consistent results (could be around 130)

--zoom 1.33

Set a font family that is common across platforms (see http://www.apaddedcell.com/sites/www.apaddedcell.com/files/fonts-article/final/index.html). Set with font-family: xxx, xxx, xxx, sans-serif

Another thing that has been mentioned before is to set the page dimensions in px instead of mm --page-width 1588px --page-height 1210px

like image 95
kerrin Avatar answered Feb 05 '23 06:02

kerrin