加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

ruby-on-rails – 如何创建应用了布局的pdf文件.使用pdfkit gem

发布时间:2020-12-17 02:04:32 所属栏目:百科 来源:网络整理
导读:require 'pdfkit'html = render_to_string(:layout = 'layouts/test_layout',:action = print_form.html.erb")kit = PDFKit.new(html)send_data(kit.to_pdf,:filename = "Form.pdf",:type = 'application/pdf') 上面的代码生成PDF文件,没有指定布局.如何创建
require 'pdfkit'
html = render_to_string(:layout => 'layouts/test_layout',:action => print_form.html.erb")
kit = PDFKit.new(html)
send_data(kit.to_pdf,:filename => "Form.pdf",:type => 'application/pdf')

上面的代码生成PDF文件,没有指定布局.如何创建应用了布局的PDF文件.

layouts/test_layout ->   test.css,test.js

我的test_layout包含一些JavaScript和CSS文件.

请建议我,我想打印具有指定布局的PDF格式的表格.

解决方法

没有看到你的render_to_string方法我们无法分辨出什么问题.以下是使用布局生成pdf的示例代码: https://github.com/pdfkit/pdfkit#usage

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读