Продвинулись, чтобы получить wicked_pdf, генерирующий PDF-файлы в Rails 3.2.3. Однако я хочу, чтобы ссылки на моих страницах отображались на экране в виде HTML из файла .html.erb, но когда я просматриваю PDF-файл, созданный на основе этого шаблона, я не хочу видеть эти ссылки.
Я пытался следовать тому, что сделал Райан Бейтс в PDFKit Railscast 220, но у меня это не работает в Rails 3.2.3 на Ruby 1.9.3.
Вот моя сокращенная часть кода представления:
<h2>Client Setup (Only when Patients module is not available)</h2>
<p>
The setup program installs your Clients module using default settings. After the installation, you can use this program to customize settings to meet your particular needs.
</p>
<p>
<%= pdf_image_tag("clients/blank/.png", alt: "Client Setup (Only when Patients Module is not available) - not-populated") %>
<table>
<thead>
<tr>
<th>Form Item</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td>Default Value Added Tax (Percent)</td>
<td>
The package offers a default Value Added Tax, expressed as a percentage of the invoice, to be added to the invoice. Numbers from 0 to 999.99 are allowed.
</td>
</tr>
</tbody>
</table>
</p>
<hr />
<form class="form-inline">
<a href="#to_top" class="btn btn-to_top btn-mini">Back to Top</a>
<%= link_to "Genie Help Index", help_path, class: "btn btn-main-menu pdf_link" %>
<p id="pdf_link"><%= link_to "Client Help Index", static_page_path("clients/index"), class: "btn btn-help" %></p>
<%= link_to "Download PDF", static_page_path(:format => :pdf), class: "btn btn-pdf" %>
<%= link_to image_tag("file_type_pdf.png", height: "24px", width: "24px" , alt: "Download page as PDF"), static_page_path(:format => :pdf) %>
</form>
<p><%= link_to "Client Help Index", static_page_path("clients/index") %></p>
<p><%= link_to "Download as PDF", static_page_path(:format => "pdf"), class: "pdf_link" %></p>
<p id="pdf_link"><%= link_to "Download as PDF", static_page_path(:format => :pdf) %></p>
<% if request.try(:format).to_s == 'pdf' %>
<%= link_to "Download this PDF", static_page_path(:format => "pdf") %>
<% end %>
#<% if params[:media] = 'all' %>
# <%= link_to "Download me as a PDF", static_page_path(:format => "pdf") %>
#<% end %>
<div id="pdf-no"><%= link_to "Get me as a PDF file", static_page_path(:format => "pdf") %></div>
Контроллер: (show page — это имя отображаемой страницы)
class StaticPages::GenieHelpController < ApplicationController
def static_page
respond_to do |format|
format.html do
render :template => show_page,
:layout => 'application'
end
format.pdf do
render :pdf => show_page,
:layout => 'generic',
:template => "#{show_page}.html.erb",
:handlers => :erb,
:disable_external_links => true,
:print_media_type => true
end
end
end
end
Файл макета в файле views/layouts/generic.pdf.erb выглядит следующим образом:
<!DOCTYPE html>
<html>
<head>
<title><%= full_title(yield(:title)) %></title>
<%= wicked_pdf_stylesheet_link_tag "static_pages/genie_v23_help", :refer_only => true %>
<!-- <%#= wicked_pdf_stylesheet_link_tag "static_pages/pdf" %> -->
<%= javascript_include_tag "application" %>
<%= csrf_meta_tags %>
</head>
<body>
<div class="container">
<%= yield %>
<%= debug(params) if Rails.env.development? %>
</div>
</body>
</html>
Соответствующий файл css в старом месте public/stylesheets/static_pages/genie_help.css:
@media print {
body { background-color: LightGreen; }
#container {
width: auto;
margin: 0;
padding: 0;
border: 2px;
}
#pdf_link {
display: none;
}
}
.pdf_link {
display: none;
}
#pdf-no {
display:none;
}
Когда я отображаю html-страницу, ссылки внизу отображаются (как и ожидалось), когда формат html.

Что я делаю не так с этим. Я предполагаю, что если это можно сделать с помощью промежуточного программного обеспечения PDFKit, то оно поддерживается в wkhtmltopdf, поскольку и PDFKit, и wicked_pdf основаны на этом.
Спасибо
отметка