Wicked PDF can not show footer Rails

82 views Asked by At

I just want to show the pdf have body and footer. Body shown successfully, but footer don't display anymore. it logged render both footer and body. I used wicked_pdf 2.6.3 and wkhtmltopdf 0.12.6

  pdf_file =  WickedPdf.new.pdf_from_string(
        ActionController::Base.new.render_to_string(
          layout: 'layouts/v1/stocks/delivery_notes/delivery_note_document',
          template: 'pdfs/stocks/delivery_notes/body_temp',
        ),
        footer: {
          content: ActionController::Base.new.render_to_string(
            layout: 'layouts/v1/stocks/delivery_notes/footer',
            template: 'pdfs/stocks/delivery_notes/footer_temp',
          ),
        }
      )

enter image description here

I tried multple times to add footer. but dont show

1

There are 1 answers

1
Nikhil bhatt On

If You are about to add wicked_pdf gem in your project I would suggest not to go with it. as it is no longer maintained and has issues while rendering Javascript / Images .

Check out this discussion related to wicked_pdf usage. https://discuss.rubyonrails.org/t/successor-to-wkhtmltopdf-wicked-pdf/84251

If you still want to go with this wicked_pdf gem update your code as follows.

ac = ApplicationController.new

WickedPdf.new.pdf_from_string(
  ...,
  footer: {
    content: ac.render_to_string('pdfs/stocks/delivery_notes/footer_temp', formats: [:html])
  }
)

For full guide check this.

https://github.com/mileszs/wicked_pdf#advanced-usage-with-all-available-options