Custom Page Size in Wicked_PDF
Asked Answered
D

1

6

Wicked_pdf docs show that I can use the following to change the page size:

render :pdf => 'file_name', :page_size => "b10"

However, this is limited to "named" page sizes such as "A4" or "Letter". I would like to use wkhtmltopdf's page_height and page_width properties, but the following appears to have no effect in wicked_pdf:

render :pdf => 'file_name', :page_height => 1, :page_width => 1

Is there a way to declare custom PDF page size in wicked_pdf?

Demp answered 24/10, 2011 at 18:30 Comment(0)
T
20

Looking at the wkhtmltopdf documentation it looks like you'll need to specify a unit of measurement for custom page sizes, eg:

render :pdf => 'file_name', :page_height => '5in', :page_width => '7in'

This was merged into the trunk of wkhtmltopdf in Dec 2009, so you'll want to make sure you have a fairly new version of the binary (0.9.9 or higher should be fine) if it still doesn't work.

Turino answered 24/10, 2011 at 20:6 Comment(2)
I've got wkhtmltopdf-binary (0.9.9.3) and wicked_pdf (0.11.0) and :page_height and :page_width does not work :(Tirade
I had to specify :page_size => nil and then it worksTirade

© 2022 - 2024 — McMap. All rights reserved.