我是Ruby on rails的新手。我在Rails 5上工作。我有一个在数据库中的细节点击按钮生成PDF文档的要求,这是我使用虾宝石实现的。现在有一个要求,点击一个按钮,我应该得到一个选项,在其中我应该能够选择是否生成PDF或可编辑格式(DOCX或任何其他格式)的文档。
我们能用rails 5中的PRWAN gem实现这一点吗?
如果有其他选择,请推荐给我。
发布于 2019-04-02 20:57:57
gem Prawn只适用于pdf格式。
我相信你所需要的就是gem htmltoword
用法:
require 'htmltoword'
# Configure the location of your custom templates
Htmltoword.config.custom_templates_path = 'some_path'
my_html = '<html><head></head><body><p>Hello</p></body></html>'
document = Htmltoword::Document.create(my_html, word_template_file_name)
file = Htmltoword::Document.create_and_save(my_html, file_path, word_template_file_name)https://stackoverflow.com/questions/55473283
复制相似问题