I'm trying to generate a pdf with the following code:
archivo = render_to_string(
:pdf => "formulario_de_registro.pdf",
:template => 'pdf/profile_download.pdf.haml',
:layout => 'pdf/body.pdf.haml',
:margin => { :bottom => 40, :top => 30 },
:header => {
:html => { :template => 'layouts/pdf/header.pdf.haml'},
:font_size => 13},
:footer => {
:html => { :template => 'layouts/pdf/footer.pdf.haml'},
:line => true}
)
# from here is just for debugging purposes
save_path = Rails.root.join('tmp','prueba.pdf')
File.open(save_path, 'wb') do |file|
file << archivo
end
If I run this code inside of a controller's action, works great, but the same code in my mailer class just render a HTML, not a PDF. Then if I call WickedPdf.new.pdf_from_string(archivo)
generates a PDF, but without the header or footer, which is right, because in the generated HTML doesn't include both header or footer. Is there something that I'm missing? Please help.
In any case, I'm using:
- wkhtmltopdf 0.11.0 rc1
- rails (3.2.3)
- wicked_pdf (0.7.9)
Thanks!