我正在生成PDF,但javascript不起作用。
<script type="text/javascript" charset="utf-8">
$(function() {
// Loading Fonts all the Text Decorations
Utils.loadSummaryFonts();
// Load Colors on all uniforms styles
Colors.loadColorsOnSvgsOnSummary();
});
</script>上面的函数是用来生成字体的,并且在模板上。
@output = Base64.encode64(@out.html_safe)
respond_to do |format|
format.html
format.pdf do
pdf = render_to_string pdf: 'artproof',
template: '/uniforms/artproof.html.erb',
show_as_html: false,
javascript_delay: 5000,
viewport_size: '1244x1480',
orientation: 'Landscape',
page_height: '10in'
send_data(pdf, filename: "artproof-#{@uniform.id}.pdf", type: :pdf)这就是我生成PDF的方式。
javascript函数适用于html格式,但在呈现PDF时不起作用。问题可能是什么?
我尝试插入jquery CDN,但没有成功。
发布于 2018-10-08 12:00:14
你有没有尝试在布局pdf文件中添加javascript标签?就像下面这样。重要的是您必须重新启动rails server
<!doctype html>
<html>
<head>
<%= wicked_pdf_javascript_include_tag "http://code.jquery.com/jquery-1.10.0.min.js" %>https://stackoverflow.com/questions/49650557
复制相似问题