Skip to content

Instantly share code, notes, and snippets.

@EminenceHC
Created June 15, 2015 22:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save EminenceHC/fe6b0afe9b3b3e7aaca0 to your computer and use it in GitHub Desktop.
Save EminenceHC/fe6b0afe9b3b3e7aaca0 to your computer and use it in GitHub Desktop.
PDF stylesheet
def show
@intake_agreement = IntakeAgreement.find(params[:id])
respond_to do |format|
format.html do
render layout: 'pdf'
end
format.pdf do
render pdf: 'filename',
layout: 'pdf',
template: 'intake_agreements/show.html.erb',
#header: { html: { layout: 'pdf_header'}},
header: { html: { template: 'layouts/pdf-header.html.erb', # use :template OR :url
}},
footer: { html: { template: 'layouts/pdf-footer.html.erb', # use :template OR :url
}},
save_to_file: Rails.root.join('public', 'PDF', 'filename2.pdf')
end
end
end
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8"/>
<%= wicked_pdf_stylesheet_link_tag "application", media: "all" %>
</head>
<body>
<%= yield(:layout) %>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment