从Rails 3生成pdf-选择哪种工具? [英] Generate pdf from Rails 3 - what tool to choose?

查看:72
本文介绍了从Rails 3生成pdf-选择哪种工具?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要能够将 Rails 3 项目中的某些视图呈现为PDF.我以前从未将PDF生成技术与ruby/rails一起使用,因此我研究了一些流行的方法,例如 Prawn PDF :: Writer ,但是所有示例和文章我发现到目前为止似乎已经过时,并且仅适用于rails2.x.我还没有看到一个可用的Rails3示例.尝试安装对虾和对虾宝石,并复制此Railscasts情节中描述的示例,但我收到无法识别prawnto方法的错误.我不确定这是实现错误还是不兼容的迹象,但是看到其他人在Web上分享了 prawn 在Rails3中不再对他们有用,所以我没有在意进一步编码.

I need to be able to render some views as PDFs from a Rails 3 project. I've never before used PDF generation techniques with ruby/rails, so I researched a few popular approaches such as Prawn and PDF::Writer, but all the examples and articles I found so far seem outdated and only applicable for rails 2.x. I haven't yet seen a working Rails3 example; tried myself installing prawn and the prawnto gems and reproducing the example described in this Railscasts episode, but I'm getting error of prawnto method not being recognized. I'm uncertain of whether this was an implementation error or just a sign of incompatibility, but seeing other people share on the web that prawn is no longer working for them in Rails3 I didn't bother tracing the code further.

是否有人在Rails3中找到了一个可行的可生成pdf的可靠解决方案?您能否分享一下或将我指向外部资源和文档? 非常感谢!

Has anyone found a working reliable solution for pdf generation in Rails3? Could you possibly share it or point me to external resources and documentation? Big thanks!

推荐答案

一个旧问题的新答案,以防其他人偶然发现:WickedPDF(与PDFkit一样使用wkhtmltopdf)使这个问题变得轻而易举.

New answer to an old question, in case others stumble across this: WickedPDF (which uses wkhtmltopdf just like PDFkit) makes this a snap.

https://github.com/mileszs/wicked_pdf

这篇关于从Rails 3生成pdf-选择哪种工具?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆