mileszs/wicked_pdf — Issue #98: Proper Method to Render PDF for attachment to email that will include header/footer
Author: rposborne
Created: 2012-03-05 21:14:01+00:00
State: open

How Specifically do I Render a PDF with all of wicked_pdf's features mainly header and footer for mailing with Action Mailer 3?

Current Code.

``` ruby
def proposal_email(order)
@user = order.user
@account = order.account
@order = order
attachments["proposal_#{@order.id}_#{@account.company_name}_#{@order.order_summary}.pdf"] = WickedPdf.new.pdf_from_string(
render_to_string(:pdf => "proposal_#{@order.id}_#{@account.company_name}_#{@order.order_summary}.pdf",:template => 'orders/proposal.html', :layout => 'pdf.html',:header => {:html => { :template => "orders/proposal_header.html"}},
:footer => { :right => '[page] of [topage]' },
:margin => { :top => 35 })
)
mail(:to => @user.email,:cc => Setting.get(:proposal_emails) , :subject => "Proposal for #{@account.company_name}") do |format|
format.html
format.text
end
end