我已经尝试了很多方法来将jQuery和Google Maps API加载到我的Wicked PDF生成器中 . 我正在尝试加载PDF中的地址图像 . 我似乎有一个问题,javascript标签不起作用 .

pdf.erb文件:

<html>
      <head>

    <%= stylesheet_link_tag "https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" %> 
        <%= javascript_include_tag "application" %>

        <script src="https://maps.googleapis.com/maps/api/js?key=######"></script>
        <%= csrf_meta_tags %>

      </head>
      <body>

控制器文件:

respond_to do |format|
      format.html
      format.pdf do
        render :pdf => "location",
               :template => "pdf_generation/location_show.pdf.erb",
               :javascript_delay => 5000,
               :show_as_html => params.key?('debug')
             end
      end

show.html.erb文件:

<div class='row'>
  <div class='col-lg-12'>
    <div class='ibox float-e-margins'>
      <div class='ibox-title'>
        <%= link_to 'Edit', edit_location_path(@location), class: 'btn btn-default' %>
      </div>
      <div class='ibox-content'>
          <iframe src="<%= location_path(@location) %>.pdf" style="width:100%; height:700px;" frameborder="0"></iframe> 
      </div>
    </div>
  </div>
</div>

我试过调试没有成功 . 我可能不明白这个的调试方法 . 现在我也尝试从CDN加载jQuery min文件,并尝试了wicked pdf javascript include标签 . 当我尝试这些方法中的任何一种时,我都会收到以下错误:

Failed to execute: ["/usr/local/rvm/gems/ruby-2.2.1/bin/wkhtmltopdf", "-q",       "--javascript-delay", "5000", "file:////tmp/wicked_pdf20171005-21437-hwy6l4.html", "/tmp/wicked_pdf_generated_file20171005-21437-gop4gw.pdf"] Error: PDF could not be generated! Command Error: Fontconfig warning: ignoring C.UTF-8: not a valid language tag Error: Failed loading page file:////tmp/wicked_pdf20171005-21437-hwy6l4.html (sometimes it will work just to ignore this error with --load-error-handling ignore) Exit with code 1, due to unknown error.

我真的可以使用一些指导 . 我无法加载任何javascript文件 . CSS文件有点困难,例如,如果我尝试加载本地scss文件,它通常不会加载,它似乎只是忽略它 . (即样式表链接标签'应用')

编辑

我发现了有问题的代码 . FontConfig警告与任何资源的加载无关 . 它与我用来将ruby变量传递给javascript的代码有关:

var location = jQuery.parseJSON( '{"main": "<%= @location.main %>", "lat": <%= @location.lat %>, "lng": <%= @location.lng %> }');

我已经修改了谷歌 Map 现在在PDF中显示,但我所做的不是干,它让我觉得有另一种方法将ruby变量传递给我的javascript代码 . 有什么想法或指针吗?