mardi 10 janvier 2017

Wicked pdf not rendering header/footer

I am using wicked_pdf for generating pdf from html on my rails project. It is rendering template but I could not manage to print header/footer sections. Below is my code that print only template section

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 show Failed to load PDF document error even simple WickedPdf.new.pdf_from_string('<html><body><h1>Hello There!</h1></body></html>') does not work.

I have tried to use render_to_string_with_wicked_pdf, render_with_wicked_pdf but did not success. My Rails version is 3.2.19, wicked_pdf gem version is 1.1.0 and wkhtmltopdf version is wkhtmltopdf-0.13.0-alpha-7b36694_linux-trusty-amd64.deb. I also tried to use wkhtmltopdf version 0.12.0.

My questions are

  1. Why my above implementation does not work?
  2. Why pdf_from_string does not work?

Any kind of help is appreciated. Thanks.

Aucun commentaire:

Enregistrer un commentaire