Wicked PDF ignores bootstrap grid system

I’ve came across the same problem. There are several solutions:

  1. Upgrade your wkhtmltopdf binary to version >= 0.12, then add :viewport_size option to render, something like this:
respond_to do |format|
  format.html
  format.pdf do
    render pdf: "my_pdf",
           viewport_size: '1280x1024'
  end
end
  1. Or you can just use col-xs-* classes
  2. Or create pdf.css.scss (I’m using bootstrap-sass) with following content:
@import "bootstrap/variables";
@import "bootstrap/mixins";

@include make-grid(sm);
@include make-grid(md);
@include make-grid(lg);

Don’t forget to include it with <%= wicked_pdf_stylesheet_link_tag "pdf.css" -%>

For plain css you will have to copy-paste all .col-sm-*, .col-md-*, .col-lg-* rules from bootstrap.css into your pdf.css, BUT without @media wrappers, it’s important.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)