應用主版面:如何獲得jQuery風格pdf與Rails 4中的wicked_pdf生成的?
這應該用於HTML。
<head>
<%= stylesheet_link_tag "application" %>
<%= stylesheet_link_tag "print", media: 'print' %>
<%= javascript_include_tag "application" %>
<%= csrf_meta_tags %>
</head>
在PDF佈局:
這應該用於PDF文件。
<head>
<title>Cassa</title>
<%= stylesheet_link_tag "application" %>
<%= stylesheet_link_tag "print", media: 'print' %>
<%= wicked_pdf_javascript_include_tag "application-pdf" %>
</head>
控制器:
respond_to do |format|
format.html
format.pdf do
render pdf: "your_assessment_printout.pdf",
disposition: "inline",
template: "assessments/show.pdf.erb",
layout: "application-pdf.html.erb"
end
format.html
end
show.pdf.erb是具有HTML構建一個表中的模板,被用在<%= variable_name %>
時尚必要的對象填充。
我可以得到PDF生成,但我可以風格的唯一方法是內聯。 EX)
<tr style="
background-color: #cdcdcf;
padding: 5em 0;">
<td>...</td>
</tr>
jQuery的應用pdf.js腳本,我想使用:
$(document).ready(function() {
$('#summary-half table tr:odd').css('background-color', '#cdcdcf');
$('#summary-half table tr:even').css('background-color', '#fff');
$('#summary-half table li:odd').css('background-color', '#cdcdf');
$('#summary-half table li:even').css('background-color', '#fff');
});
我不能夠動態風格<tr></tr>
和<li></li>
元素。我已經註釋掉了application.html.erb樣式表和javascript標籤,並且只啓用了pdf特定的並且仍然沒有改變。
有沒有人使用wicked_pdf動態通過JavaScript/jQuery有任何運氣樣式元素?