Reputation: 426
I have these installed and using Mountain Lion:
I installed qt and wkhtmltopdf using brew install --devel --build-patched-qt wkhtmltopdf
I am using Rails 3.2 and have these code in my controller:
render pdf: Time.now.to_i.to_s,
layout: false,
template: 'invoices/download',
disposition: 'attachment',
page_size: 'A4',
footer: {
left: Time.now.to_i.to_s,
center: Time.now.to_i.to_s,
right: Time.now.to_i.to_s
}
The content is being generated fine, but no footer. Any suggestion?
Upvotes: 1
Views: 766
Reputation: 5352
At some stage this can be an issue with the way you've installed wkhtmltopdf
as it may not generate the necessary footers. Also noticed your on OSx so I believe you would've downloaded wkhtmltopdf here and then cd to correct directory by doing something cd /usr/local/bin && ln -s /Applications/wkhtmltopdf.app/Contents/MacOS/wkhtmltopdf wkhtmltopdf
.
I believe inside your respond block you should have something like:
respond_to do |format|
format.html
format.pdf do
render :pdf => "#{DateTime.now.to_s}",
:footer=> { left: Time.now.to_s,
center: Time.now.to_s,
right: Time.now.to_s
}
Further to this is was a bit strange you were doing Time.now.to_i.to_s
to from my experience this doesn't make sense and sure as this is not going to output what you want. Because:
Time.now.to_i: This returns the value of the time as an integer of seconds.
Time.now.to_i
#=> "1270968656.89607"
Time.now.to_s: Returns value of time as a string.
Time.now.to_s
#=> "2012-11-10 18:16:12 +0100"
When you are trying to do Time.now.to_i.to_s
when this is executed it will get the time and execute the first method which is to_i
and to illustrate what your output is Imgur - Output. Because from my understanding what you are trying to do is list the time convert it to an integer and then convert it to a string. There is no need for this just simply do Time.now.to_s
that will do. As for your problem regarding the footer issue with wicked_pdf
this can be down to your installation. As earlier mentioned take a look at the link supplied, also revise your setup and consider the suggested setup I've provided. Hope this helps.
Upvotes: 1