【问题标题】:How to generate an editable document using prawn如何使用虾生成可编辑文档
【发布时间】:2019-08-23 16:35:51
【问题描述】:

我是 Ruby on rails 的新手。我在 Rails 5 上工作。我需要通过单击带有数据库中详细信息的按钮来生成 PDF 文档,这是我使用 PRAWN gem 实现的。现在有一个要求,点击一个按钮我应该得到一个选项,我应该能够选择是否生成 PDF 或可编辑格式(DOCX 或任何其他格式)的文档。

我们可以在 Rails 5 中使用 PRWAN gem 实现这一点吗?

如果还有其他可用的选项,请建议我。

【问题讨论】:

    标签: ruby-on-rails prawn


    【解决方案1】:

    gem Prawn 仅适用于 pdf。

    我相信你所需要的只是宝石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)
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-04-22
      • 1970-01-01
      • 2012-06-04
      • 2011-02-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多