Question

require 'pdfkit'
html = render_to_string(:layout => 'layouts/test_layout' , :action => print_form.html.erb")
kit = PDFKit.new(html)
send_data(kit.to_pdf, :filename => "Form.pdf", :type => 'application/pdf')

above code generates PDF file without layout specified. How do I create PDF file with layout applied.

layouts/test_layout ->   test.css, test.js

My test_layout contains some JavaScript and CSS files.

Please suggest me, I want to print form in PDF format with specified layout.

Was it helpful?

Solution

Without seeing your render_to_string method we can't tell what's going wrong. Here is example code for generating a pdf with layout: https://github.com/pdfkit/pdfkit#usage

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top