【发布时间】:2015-02-06 16:25:43
【问题描述】:
对于我的 rails 4 应用程序,我想将 html 和 Css 转换为 pdf 文件。 我使用 wkhtmltopdf 和 wicked_pdf gem 如果我使用 wicked helper,它不会显示 css,但只会呈现文本
在我的控制器中我有:
respond_to do |format|
format.html
format.pdf do
render :pdf => "#{@card.name}",
:template => 'cards/show.html.slim',
:page_size => "A4",
:disposition => 'attachment'
在show.html.slim中
= link_to "Download PDF", :action => "show", :format => :pdf
应用程序.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>
【问题讨论】:
-
我以前从未见过
-%>。是这样写的,还是打错字了? -
我知道,我都试过了,但是 -%> 是文档所说的......github.com/mileszs/wicked_pdf
-
显然是打错了...至于其余的,你不要写
"pdf",我认为:你应该用它们来替换助手javascript_include_tag或stylesheet_link_tag(我认为,再次) -
编辑代码^* application.html.erb
标签: ruby-on-rails pdf wkhtmltopdf wicked-pdf