2

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

Ricardo Acras
  • 34,766
  • 15
  • 66
  • 109

2 Answers2

2

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/

Community
  • 1
  • 1
zenw0lf
  • 1,137
  • 11
  • 22
2

Templates were introduced only in prawn 0.10.1 as stated by Daniel Nelson here.

Ricardo Acras
  • 34,766
  • 15
  • 66
  • 109