[英]wicked_pdf + rails 3.1 asset pipeline
I'm having an issue with wicked_pdf. 我在wicked_pdf时遇到问题。 It's not taking into account any of my javascript. 它没有考虑到我的任何JavaScript。 The report is being generated and the text that is rendered is "Page undefined of undefined". 正在生成报告,并且呈现的文本是“页面未定义或未定义”。 Any help on linking up javascript into wicked_pdf would be greatly appreciated! 将JavaScript链接到wicked_pdf的任何帮助将不胜感激!
Markup: 标记:
<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>
Controller action: 控制器动作:
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
That code was given as example in the wkhtmltopdf documentation, and only works when provided in a header or footer file like so: 该代码在wkhtmltopdf文档中作为示例给出,并且仅在像这样的页眉或页脚文件中提供时才有效:
format.pdf do
render :pdf => "hello.pdf",
:template => "reports/templates/#{params[:report]}.pdf.erb",
:footer => {
:html => {
:template => "reports/templates/#{params[:report]}.pdf.erb"
}
}
end
When this is run, the inner template shows page undefined of undefined
, but the footer shows page 1 of 1
. 运行此命令时,内部模板显示page undefined of undefined
,但是页脚显示page 1 of 1
。 I think this has to do with the internals of page splitting in wkhtmltopdf. 我认为这与wkhtmltopdf中的页面拆分内部有关。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.