I am using wicked_pdf to generate pdffrom htmlin my rails project. This is a rendering template, but I was not able to print the sections header/footer. Below is my code that only prints a templatesection
render pdf: "pdf_name",
layout: 'application',
template: 'reports/show',
formats: [:html],
margin: { top: 10, bottom: 10, left: 10, right: 10 },
disable_javascript: true,
show_as_html: params[:debug],
header: {
html: { template: 'shared/header' },
spacing: 10
},
footer: {
html: { template: 'shared/footer' },
spacing: 30,
line: true
}
If I try to use WickedPdf.new.pdf_from_string render_to_string, it shows an error Failed to load PDF document, even a simple one WickedPdf.new.pdf_from_string('<html><body><h1>Hello There!</h1></body></html>')does not work.
I tried to use render_to_string_with_wicked_pdf, render_with_wicked_pdf, but did not succeed. My version of the Rails 3.2.19, wicked_pdfversion gem - 1.1.0and wkhtmltopdfversion wkhtmltopdf-0.13.0-alpha-7b36694_linux-trusty-amd64.deb. I also tried using the wkhtmltopdfversion 0.12.0.
My questions
- Why is my implementation above not working?
- Why
pdf_from_stringdoesn’t work?
Any help is appreciated. Thank.