Question

I am trying to test out a simple page that I wish to use to generate an A4 PDF at 300 DPI. Which I calculated to be 2480px wide and 3507px high;

This is the HTML which I expected to create a single page PDF that has a red border around the edges. The problem is that I am getting PDF that is four pages long.

<html>
    <head>
        <style>
            body {
                margin: 0;
                padding: 0;
                width:2480px;
                height:3507px;
            }
        </style>
    </head>
    <body>
        <div style="width:2480px; height:3507px; border:1px solid red;"/>
    </body>
</html>

This is the command I am using to generate the PDF:

wkhtmltopdf --disable-smart-shrinking --page-size A4 --dpi 300 --margin-bottom 0 --margin-left 0 --margin-right 0 --margin-top 0 test.html test.pdf

I can't work out if I am doing something wrong, such as missing a setting or calculating the size of my page incorrectly?

Any help would be appreciated.

Pas de solution correcte

Autres conseils

dpi is not working in wkhtmltopdf version 0.12.4

the default value is 96. Try to use zoom setting with value 96/300 = 0.32

As of wkhtmltopdf version 0.12.6, the CLI option of --dpi 600 works successfully.

(At least I had a DPI problem now, and specifying --dpi changed the document and solved the "pixelisation" problem for me.)

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top