对于我的rails 4应用程序,我想将html和Css转换为pdf文件.我使用wkhtmltopdf和wicked_pdf gem如果我使用邪恶的帮助器它不显示css但它只渲染文本
在我的控制器中我有:
respond_to do |format|
format.html
format.pdf do
render :pdf => "#{@card.name}",
:template => 'cards/show.html.slim',
:page_size => "A4",
:disposition => 'attachment'
Run Code Online (Sandbox Code Playgroud)
并在show.html.slim
= link_to "Download PDF", :action => "show", :format => :pdf
Run Code Online (Sandbox Code Playgroud)
aplication.html.erb
<%= wicked_pdf_stylesheet_link_tag "pdf" -%>
<%= wicked_pdf_stylesheet_link_tag "application", media: "all", "data-turbolinks-track" => true %>
<%= wicked_pdf_javascript_include_tag "application", "data-turbolinks-track" => true %>
<link rel="stylesheet" href="//code.jquery.com/ui/1.11.2/themes/smoothness/jquery-ui.css">
<script src="//code.jquery.com/jquery-1.10.2.js"></script>
<script src="//code.jquery.com/ui/1.11.2/jquery-ui.js"></script>
Run Code Online (Sandbox Code Playgroud)