【问题标题】:Prawn templates not working虾模板不起作用
【发布时间】:2011-01-25 11:29:09
【问题描述】:

我正在尝试这个简单的脚本:

require 'prawn'

template_file_name = File.join(File.dirname(__FILE__), 'template.pdf')
pdf_file = Prawn::Document.new(:template => template_file_name)
pdf_file.text('Hello World')
pdf_file.render_file('output.pdf')

在与脚本相同的目录中有一个 template.pdf 文件,但 output.pdf 仅随 Hello Wordl 提供

我还有什么需要注意的吗?

谢谢

【问题讨论】:

    标签: ruby pdf prawn


    【解决方案1】:

    如 Daniel Nelson here 所述,模板仅在 prawn 0.10.1 中引入。

    【讨论】:

    • 我有 Prawn 0.12.0 并且遇到了同样的问题。
    【解决方案2】:

    如果您想用另一个 pdf 文件标记一个 pdf 文件,并且您使用的是 Ubuntu,那么请尝试安装 pdftk

    转到终端并输入:

    sudo apt-get install pdftk
    

    然后进入pdf目录,输入:

    pdftk content.pdf stamp template.pdf output final.pdf
    

    如果你想在 Ruby 中完成这一切,你可以了解:Calling shell commands from Ruby

    我在此链接中了解了此解决方案:http://numbers.brighterplanet.com/2011/10/06/stamp-pdfs-with-prawn-and-pdftk/

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多