我遇到了 wicked_pdf 的问题。它没有考虑到我的任何javascript。正在生成报告,呈现的文本是“未定义的页面未定义”。任何有关将 javascript 链接到 wicked_pdf 的帮助将不胜感激!
标记:
<html>
<head>
<script>
function number_pages() {
console.log('hi');
var vars={};
var x=document.location.search.substring(1).split('&');
for(var i in x) {var z=x[i].split('=',2);vars[z[0]] = unescape(z[1]);}
var x=['frompage','topage','page','webpage','section','subsection','subsubsection'];
for(var i in x) {
var y = document.getElementsByClassName(x[i]);
for(var j=0; j<y.length; ++j) y[j].textContent = vars[x[i]];
}
}
</script>
</head>
<body onload="number_pages()">
Page <span class="page"></span> of <span class="topage"></span>
</body>
</html>
控制器动作:
def generate_report
respond_to do |format|
format.html
format.pdf do
render :pdf => "hello.pdf", :template => "reports/templates/#{params[:report]}.pdf.erb", :disable_javascript => false
end
end
end