加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

ruby-on-rails – wicked_pdf不导入twitter bootstrap样式

发布时间:2020-12-17 02:23:02 所属栏目:百科 来源:网络整理
导读:我通过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 = {
我通过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初始化文件中使用预编译器吗?

提前致谢!

解决方法

永远不要导入所有样式表

<%= 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";

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读