我的控制器:
def show
respond_to do |format|
format.pdf do
#render :pdf => "show",:template => "welcome/show",:footer => { :right => 'Page [page] of [topage]' })
#render :pdf => "show",:template => "welcome/show", :header => {:content => render_to_string({:template => 'welcome/pdf_header.html.erb'})}, :footer=> { :right => 'Page [page] of [topage]' },:margin => { :top => 38, :bottom => 35}
#render :pdf => "show",:handlers => [:html],:template => "welcome/show.pdf.erb", :header => {:content => render_to_string({:layout => 'pdf_header.html.erb'})}, :footer=> { :right => 'Page [page] of [topage]' },:margin => { :top => 38, :bottom => 35}
render :pdf => "show",:template => "welcome/show.pdf.erb", :header => {:content => ActionController::Base.new().render_to_string({:template => 'welcome/pdf_header.html.erb', :layout => false})}, :footer=> { :right => 'Page [page] of [topage]' },:margin => { :top => 38, :bottom => 35}
end
end
end
我越来越有页码沿着PDF,但我不能让图像头。
这是布局:
pdf_header.html.erb
<%= image_tag "gla/image.jpg" ,:width => "90", :height=>"85" %>
<%#= wicked_pdf_image_tag "gla/image.jpg" %>
有一次,我打开pdf_header为HTML文件,我得到的图像显示,但一旦我称之为PDF我不能显示图像
在控制台中我得到这个
Started GET "/welcome/show.pdf" for 127.0.0.1 at 2014-04-17 09:47:05 +0530
Processing by WelcomeController#show as PDF
Rendered welcome/pdf_header.html.erb (0.4ms)
***************WICKED***************
Rendered welcome/show.pdf.erb (0.7ms)
Rendered text template (0.0ms)
Sent data show.pdf (1.8ms)
Completed 200 OK in 782ms (Views: 1.3ms | ActiveRecord: 0.0ms)
该评论的东西是什么,我都试过,而不是成功。 是否有另一种方式在头通过给图片的路径,而不是通过HTML传递直接显示图像?