Wicked_Pdf Is Not Rendering Header

Wicked PDF header not showing up

For anyone else reaching here... it was a CSS issue. The header was there but "invisible" and no matter what margin I set on the render options it was a CSS issue. After starting the CSS from scratch, the header appeared! I could not debug it with the flag show_as_html: true because header and footer are not rendered in that mode, only the body.

If anyone reads this and happens to be in the same situation, use the search tool in the PDF document to find a word you know that's in the header. If it finds something but it's invisible, then you know you have a CSS problem.
Also don't forget to check if you included in the html of the header the <!DOCTYPE html>. Thanks @joaolell for this.

Another thing to check, is that you have the version with patched qt of the wkhtmltopdf library (0.12.4 and above) that supports header and footer. Previous versions won't

Wicked pdf not rendering header/footer

Use a version of wkhtmltopdf built with patched qt, which properly works with footer and header.

$ wget http://download.gna.org/wkhtmltopdf/0.12/0.12.4/wkhtmltox-0.12.4_linux-generic-amd64.tar.xz
$ tar xf wkhtmltox-0.12.4_linux-generic-amd64.tar.xz
$ sudo mv wkhtmltox /usr/local/share/
$ sudo update-alternatives --install /usr/local/bin/wkhtmltopdf wkhtmltopdf /usr/local/share/wkhtmltox/bin/wkhtmltopdf 1005

check the version:

$ wkhtmltopdf --version

it should say:

wkhtmltopdf 0.12.4 (with patched qt)

test it:

$ wkhtmltopdf --footer-center 'footer' http://www.google.com google.pdf

you can also install the wkhtmltoimage:

$ sudo update-alternatives --install /usr/local/bin/wkhtmltoimage wkhtmltoimage /usr/local/share/wkhtmltox/bin/wkhtmltoimage 1005

you can use a script like this: wkhtmltox installer

wicked_pdf not loading header or footer in ActionMailer

WickedPdf doesn't alias_method_chain :render_to_string in ActionMailer like it does for ActionController.

First, update wicked_pdf to version 0.8.0 or git master. This will allow you to include it on an actionmailer class:

Then you get around this by manually including the PdfHelper module and just calling the method directly like so:

# Mailer
class Notifications < ActionMailer::Base
include PdfHelper

def send_email
archivo = render_to_string_with_wicked_pdf(
:pdf => "formulario_de_registro.pdf",
:footer => { :html => { :template => 'layouts/pdf/footer.pdf.haml' } }
# etc...
)
attachments['formulario_de_registro.pdf'] = archivo
mail :to => 'person@example.com'
end
end

Wicked_PDF not rendering correct template

I want to say thanks to @dollarchills and @nourza. Both were great helps with this one.

It turns out that the other developer had installed the following

If you would like to have WickedPdf automatically generate PDF views
for all (or nearly all) pages by appending .pdf to the URL, add the
following to your Rails app:

in application.rb (Rails3) or environment.rb (Rails2)

require 'wicked_pdf'
config.middleware.use WickedPdf::Middleware

which overwrites everything else

Wicked PDF - images are not showing

After trying all kinds of solutions, here is what worked for me:

<%= wicked_pdf_image_tag(polymorphic_url(@certificate.certificate_template.brand_logo), width: "400px") %>


Related Topics



Leave a reply



Submit