[英]Image in PDF Report using wkhtmltopdf on rails
I want a PDF report with image in record. 我想要记录图像的PDF报告。
the html report works fine with below code: html报告可以在以下代码中正常工作:
<% if @student.photo.file? %>
<%= image_tag @student.photo.url %>
<% end %>
but when I try pdf report with following code it doesnt work. 但是当我尝试使用以下代码的pdf报告时,它不起作用。 pls help.
请帮助。
<% if @student.photo.file? %>
<%= wicked_pdf_image_tag @student.photo.url %>
<% end %>
and this is my def in controller 这是我在控制器中的定义
def generate_id_card
@student = Student.find(params[:id])
render :pdf=>'generate_id_card',
:show_as_html => true
which wkhtmltopdf
shows nothing but I have it installed in /opt
directory at: /opt/wkhtmltopdf-amd64
which wkhtmltopdf
什么都没有显示,但是我将其安装在/opt
目录中: /opt/wkhtmltopdf-amd64
and the WickedPdf.config is 和WickedPdf.config是
WickedPdf.config = {
# :wkhtmltopdf => '/opt/wkhtmltopdf',
:wkhtmltopdf => '/opt/wkhtmltopdf-amd64',
:layout => "pdf.html",
:margin => { :top=> 40,
:bottom => 20,
:left=> 30,
:right => 30},
:header => {:html => { :template=> 'layouts/pdf_header.html'}},
:footer => {:html => { :template=> 'layouts/pdf_footer.html'}}
which wkhtmltopdf show nothing but I have it installed in /opt /opt/wkhtmltopdf-amd64 哪个wkhtmltopdf不显示任何内容,但我已将其安装在/ opt / opt / wkhtmltopdf-amd64中
and the WickedPdf.config is 和WickedPdf.config是
WickedPdf.config = {
# :wkhtmltopdf => '/opt/wkhtmltopdf',
:wkhtmltopdf => '/opt/wkhtmltopdf-amd64',
:layout => "pdf.html",
:margin => { :top=> 40,
:bottom => 20,
:left=> 30,
:right => 30},
:header => {:html => { :template=> 'layouts/pdf_header.html'}},
:footer => {:html => { :template=> 'layouts/pdf_footer.html'}}
rendered_id_card = render_to_string(:template => "students/generate_id_card.pdf.erb", :show_as_html => true )
pdf = WickedPdf.new.pdf_from_string rendered_id_card
try this 尝试这个
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.