【问题标题】:wicked_pdf not importing twitter bootstrap styleswicked_pdf 不导入 twitter 引导样式
【发布时间】:2014-10-12 12:45:42
【问题描述】:

我正在通过 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 初始化文件中使用预编译器吗?

提前致谢!

【问题讨论】:

标签: ruby-on-rails wicked-pdf


【解决方案1】:

从不导入所有样式表,只导入

<%= wicked_pdf_stylesheet_link_tag "print.css" -%>

Sow,从文件 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";

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2013-04-05
    • 2012-05-26
    • 2021-08-16
    • 2015-03-06
    • 2012-09-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多