Chandrakant
Chandrakant

Reputation: 1981

HTML to PDF page does not converting properly with A4 page size

I'm new b rails, I have successfully produced PDF from the HTML with wkhtmltopdf[0.11.0 rc1] free version, using ruby on rails(3.1).
I want that PDF in A4 printable size. (PDF have multiple pages.)
but it seems generated PDF having small size

my HTML wrapper/main DIV having width: 580px; and wrapper DIV is centered By margin: auto;

I'm already using Wicked-PDF and facing this issue in the generated PDF. using page_size as A4.

pdf = WickedPdf.new.pdf_from_string(render_to_string(
             template: 'assessment_reports/assessment_report.html.haml', 
             layout: "layouts/reports.html.haml", 
             handlers: [ :haml ], margin: { :left => "5mm",:right => "5mm", :top => "20mm", :bottom => "0mm" },
             locals: { :@view_mode => "pdf" }
          ))



Que is- how do i convert/scale its width- 210mm(which is width of A4 paper) and height proportionally while generating pdf? Not require but if possible-resolution should 300DPI.

Any help would be appreciated.

Upvotes: 0

Views: 2327

Answers (1)

user6269864
user6269864

Reputation:

I had a similar issue and this argument to wkhtmltopdf solved the issue for me:

--disable-smart-shrinking

Upvotes: 1

Related Questions