Skip to content

Instantly share code, notes, and snippets.

@hayeah
Created May 2, 2011 10:30
Show Gist options
  • Save hayeah/951416 to your computer and use it in GitHub Desktop.
Save hayeah/951416 to your computer and use it in GitHub Desktop.
def print
@doc = Document.find(params[:id])
respond_to do |format|
format.html {
render "final", :layout => "print"
}
format.pdf {
html = render_to_string "final", :layout => "print"
p [:output,html]
kit = PDFKit.new(html, :page_size => 'Letter')
send_data(kit.to_pdf, :filename => @doc.name, :type => "application/pdf")
}
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment