in my template x.pdf.erb site i have linked all the stylesheets and javascript tags:
<%= wicked_pdf_stylesheet_link_tag "bootstrap.css" -%> <%= wicked_pdf_stylesheet_link_tag "style.css" -%> <%= wicked_pdf_stylesheet_link_tag "styleUmowa.css" -%> <%= wicked_pdf_stylesheet_link_tag "animate.css" -%> <%= wicked_pdf_javascript_include_tag "application" %>
When the pdf site is generated, everything is good except bootstrap grid system, i mean wicked pdf ignores my:
<div class="container"> <div class="row"> <div class="col-lg-4"></div> <div class="col-lg-4"></div> <div class="col-lg-4"></div> </div> </div>
So, it`s displayed like normal divs without bootstrap grid. Can you help me with this?
If we want to place the content precisely on a page, then CSS Grid is better, but if we want the flexibility of the layout, then we should go for Bootstrap.
Basic Structure of a Bootstrap Grid So, to create the layout you want, create a container ( <div class="container"> ). Next, create a row ( <div class="row"> ). Then, add the desired number of columns (tags with appropriate .col-*-* classes). Note that numbers in .col-*-* should always add up to 12 for each row.
I've came across the same problem. There are several solutions:
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
col-xs-*
classespdf.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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With