I'm trying to create a cover page that has an image
Using wicked_pdf the cover just renders the absolute path of the image. Any help greatly appreciated.
Here's the code snippet in the controller
format.pdf do
render pdf: "MNAZ_Directory", template: '/members/directory.pdf.erb',
:cover =>'/members/cover.pdf.erb',
:show_as_html => params[:debug].present?,
:orientation => 'landscape',
:layout => 'pdf',
您可以在cover.pdf.erb
文件中尝试此操作
<%= wicked_pdf_image_tag('foo') %>
I had the same issue and fixed it by adding render_to_string()
. Please see the sample code below.
respond_to do |format|
format.pdf do
render pdf: "MNAZ_Directory",
template: '/members/directory.pdf.erb',
layout: "pdf",
cover: render_to_string("/members/cover.pdf.erb"),
show_as_html: params[:debug].present?
end
end
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.