Wicked PDF
在这里查看可用选项
-
在中为pdf文档创建布局
views/layouts/pdf.html.erb
<!DOCTYPE html>
<html>
<head>
<title>My PDF</title>
<%#= wicked_pdf_stylesheet_link_tag "style" -%>
</head>
<body>
<div class='my_container'>
<%= yield %>
</div>
</body>
</html>
2-在控制器(您必须添加选项作为
disposition: 'inline'
在新选项卡中打开)
def show
respond_to do |format|
format.pdf do
render pdf: "show",
disposition: 'inline',
stream: false,
layout: 'layouts/pdf.html.erb'
end
end
end
3-Pdf html文档名称应以结尾
.erb
app/views/app/letters/show.pdf.erb
<div>
<p>test</p>
</div>