4

I am rendering a pdf file through wicked_pdf gem:

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

My layout file looks like this:

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

And my templates.css file:

/*
*= require bootstrap_and_overrides
*= require on_the_spot
*= require_self
*/

However, my rendered pdf file includes styling from this file, only not the bootstrap styling (colors etc.)

What am I doing wrong? Should I use a precompiler in the wicked_pdf.rb initializer file?

Thanks in advance!

Bogdan Popa
  • 1,099
  • 1
  • 16
  • 37

1 Answers1

3

Never import all stylesheets, only

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

Sow, import all stylesheets from file print.css.scss

Example:

@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";