我通过wicked_pdf gem渲染pdf文件:
format.pdf do
render :pdf => 'oferta',
:template => 'templates/show_offer.pdf.erb',
:layout => "layouts/templates.html.erb",
:print_media_type => true,
:page_size => "A4",
:disable_smart_shrinking => true,
:footer => { :right => '[page] of [topage]' }
end
我的布局文件如下所示:
<%= javascript_include_tag "jquery", "application"%>
<%= stylesheet_link_tag "templates", media: "all" %>
<%= wicked_pdf_javascript_include_tag "number_pages" %>
<%= wicked_pdf_stylesheet_link_tag "templates", media: "all" %>
我的templates.css文件:
/*
*= require bootstrap_and_overrides
*= require on_the_spot
*= require_self
*/
但是,我渲染的pdf文件包含来自此文件的样式,而不包括引导样式(颜色等)
我做错了什么?我应该在wicked_pdf.rb初始化文件中使用预编译器吗?
提前致谢!
答案 0 :(得分:3)
永远不要导入所有样式表,只有
<%= wicked_pdf_stylesheet_link_tag "print.css" -%>
播种,从文件print.css.scss
导入所有样式表示例:
@import "bootstrap-sprockets";
@import "bootstrap";
@import "bootstrap/variables";
@import "bootstrap/mixins";
@include make-grid(sm);
@include make-grid(md);
@include make-grid(lg);
@import "theme.css";