Imnotapotato
Imnotapotato

Reputation: 5808

wkhtmltopdf: How to set a stretched A4 PDF document?

I have a page I want to convert to PDF, and I want it to look like the ones "Prince" do, but using wkhtmltopdf.

If you look at this example: http://www.princexml.com/samples/invoice/invoicesample.pdf

and look at the original HTML: http://www.princexml.com/samples/invoice/invoicesample.html

You could see that the HTML has 100% width but it shrinks its' width because of the page size (A4).

I had been trying so many options for 'wkhtmltopdf' but didn't get any good results!

This is the list of properties: http://madalgo.au.dk/~jakobt/wkhtmltoxdoc/wkhtmltopdf_0.10.0_rc2-doc.html#Global%20Options

Can you please help me get the right display?

These are the options I tried in so many ways:

$options = array( 
    // 'page-width' => '216mm', 
    // 'page-height' => '279mm', 
    'page-size' => 'A4', 
    //'dpi' => 96, 
    //'image-quality' => 100, 
    //'disable-smart-shrinking', 
    //'no-outline', 
    'no-outline',           // option without argument
    'encoding' => 'UTF-8',  // option with argument
    'user-style-sheet' => $cssPath,
    'margin-top'    => 0,
    'margin-right'  => 0,
    'margin-bottom' => 0,
    'margin-left'   => 0,


    // 'orientation' => 'portrait', 
    // 'images' => true,
    // 'cookie' => array(),
    // 'dpi' => 300,
    // 'image-dpi' => 300
    // Default page options
    //'disable-smart-shrinking'
    );

There are margins at the top-left-right and the display has a wide screen and the 100% elements don't get smaller.

enter image description here

Upvotes: 1

Views: 5849

Answers (1)

Panneer
Panneer

Reputation: 46

enable/disable-smart-shrinking option will help you. By default, wkhtmltopdf scale content to configured page size. You should disable this behavior.

Upvotes: 3

Related Questions