2012-07-31 61 views

回答

0

這裏是代碼爲我的作品(你可以將PDF的d = 1見HTML版本?):

def index 
    render :pdf => "pdf_with_map", 
     :disposition => "attachment", 
     :show_as_html => (params[:d] == "1"), 
     :layout => "pdf", 
     :orientation => 'Landscape' 
end 

這裏是PDF佈局:

!!! 
%html 
    %head{:xmlns => 'http://www.w3.org/1999/xhtml', :lang => 'en', 'xml:lang' => 'en'} 
    %meta{:charset => "utf-8"} 
    %title PDF 
    = wicked_pdf_stylesheet_link_tag 'pdf' 
    = wicked_pdf_javascript_include_tag 'jquery', 'jquery-jvectormap', 'jquery-jvectormap-world-en', 'regionVectorMap' 
    = csrf_meta_tags 

    %body 
    #content 
     = yield 

當您使用調試你會看到助手將JavasSript嵌入到HTML中。地圖沒有爲我工作,如果jquery是在寶石,我移動jquery到我的應用程序/資產,以便wicked_pdf_javascript_include_tag可以找到源;-)