Prawn templates not working
I´m trying this simple script:
require 'prawn'
template_file_name = File.join(File.di开发者_JS百科rname(__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
Templates were introduced only in prawn 0.10.1 as stated by Daniel Nelson here.
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/
精彩评论