1
votes

How can I make wkhtmltopdf fit it's output to the width of a page despite of the html not being the dimension needed to fit the PDF page? For example a page of 248 pixels wide being fitted to the 2480 pixel width of an A4 PDF page.

1

1 Answers

1
votes

First of all, please observe how the output pdf for your corresponding html page is fitted to A4 PDF page.
After that you can adjust the page according to your requirement by passing certain arguments as shown belowenter image description here

observe the line switches = "-q -s A4 -O Portrait --zoom 1.5 --no-background - ";
In the same way you can pass arguments to get desired result. Let me summerize few arguments :

--zoom           : Zooms the page   
--margin-bottom  : Set the page bottom margin  
--margin-left    : Set the page left margin  
--margin-right   : Set the page right margin  
--margin-top     : Set the page top margin  
--page-height    : Page Height 

Using these objects we can adjust output PDF. You can find more about these arguments at wkhtmltopdf