1
我試圖生成用下面的代碼的PDF:如果我運行一個控制器的行動在這個代碼wicked_pdf不加載頁眉或頁腳中的ActionMailer
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
,工程巨大,但相同的代碼我的郵件類只是呈現HTML,而不是PDF。然後,如果我叫WickedPdf.new.pdf_from_string(archivo)
生成PDF,但沒有頁眉或頁腳,這是正確的,因爲在生成的HTML不包括頁眉或頁腳。有什麼我失蹤了嗎?請幫忙。 在任何情況下,我使用的是:
- wkhtmltopdf 0.11.0 RC1
- 軌(3.2.3)
- wicked_pdf(0.7.9)
謝謝!
看來'未定義的方法「render_to_string_with_wicked_pdf」爲#' –
@AlterLagos我忘了提及你必須包括PdfHelper,你甚至不能做到這一點在0.7.9適當的,並且必須使用git主,直到一個新的寶石版本出版。我已經證實這是有效的。 – Unixmonkey
現在正與'修訂:488e473b5c6c9af7870d793da5769af49ef1b500'。非常感謝:) –