Prawn templates not working

I´m trying this simple script:

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')

There is a template.pdf file in the same dir as the script but the output.pdf comes only with the Hello Wordl

Is there anything else that I should be concerned of?

Thanks


If you want to stamp a pdf file with another, and you are using Ubuntu, then try installing pdftk .

Go to a terminal and type this:

sudo apt-get install pdftk

Then go to the pdf directory and type:

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

If you want to do all this within Ruby, you can learn about: Calling shell commands from Ruby

I read about this solution in this link: http://numbers.brighterplanet.com/2011/10/06/stamp-pdfs-with-prawn-and-pdftk/


正如Daniel Nelson在这里所述,模板只在0.10.1版中引入。

链接地址: http://www.djcxy.com/p/25310.html

上一篇: 在Rails中运行Python脚本

下一篇: 虾模板无法正常工作