I used these settings
WickedPdf::config = {
:layout => 'application.pdf.html', # use 'pdf.html' for a pfd.html.erb file
:wkhtmltopdf => '/bin/wkhtmltopdf', # path to binary
:orientation => 'Portrait', # default , Landscape
:page_size => 'A4',
:dpi => '300',
:print_media_type => true,
:no_background => true,
:margin => {:top => 0, # default 10 (mm)
:bottom => 0,
:left => 0,
:right => 0},
}
and set the body style to
body {
margin: 0;
padding: 0;
background-color: #FFF;
width: 210mm;
height: 297mm;
}
and a div of class .page
.page {
display: inline-block;
clear: both;
border: 2px solid #FF0000;
width: 210mm;
height: 297mm;
page-break-after: auto;
}
but when the pdf is created, the .page divs are almost half of the pdf page.
If you are floating your page container, then it won't work. I had the exact same problem and once I removed the floating pro.
So your page container should be:
.page {
display: block;
clear: both;
border: 2px solid #FF0000;
page-break-after: auto;}
Because the inline-block
is just like floating it left.
Try putting in your css
@media print
{ .page {
display: inline-block;
clear: both;
border: 2px solid #FF0000;
width: 210mm;
height: 297mm;
page-break-after: auto;
}
}
Also make sure you add media="all"
if you are referencing external stylesheet:
<link href="/stylesheets/scaffold.css?1304060088"
media="all" rel="stylesheet" type="text/css">
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