Image in PDF Report using wkhtmltopdf on rails -
i want pdf report image in record.
the html report works fine below code:
<% if @student.photo.file? %> <%= image_tag @student.photo.url %> <% end %>
but when try pdf report following code doesnt work. pls help.
<% if @student.photo.file? %> <%= wicked_pdf_image_tag @student.photo.url %> <% end %>
and 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 have installed in /opt
directory at: /opt/wkhtmltopdf-amd64
and wickedpdf.config is
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 have installed in /opt /opt/wkhtmltopdf-amd64
and wickedpdf.config is
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
Comments
Post a Comment