How to create a pdf file with the layout applied to it. Using pdfkit gem

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') 

The above code generates a PDF file without specifying a layout. How to create a PDF file using layout.

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

My test_layout contains some JavaScript and CSS files.

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

+4
source share
1 answer

Without seeing our render_to_string method, we cannot say what is going wrong. Here is an example code for generating pdf with a layout: https://github.com/pdfkit/pdfkit#usage

0
source

Source: https://habr.com/ru/post/1480641/


All Articles