1

I am generating a PDF in Prawn using a template using code similar to:

Prawn::Document.new(:template => "template.pdf")

This works great, and I can add to the document in the normal way - however I would like to search for and replace some text that gets added from the template. Is this possible with Prawn?

Looking at the Prawn code it does the following:

 if options[:template]
   fresh_content_streams(options)
   go_to_page(1)
 else
   .....
 end

 .....

 # adds a new, empty content stream to each page. Used in templating so
 # that imported content streams can be left pristine
 #
 def fresh_content_streams(options={})
   .....
 end

So it creates a new content stream to prevent changing the data given in the template - the question is can I look into and change the existing stream with Prawn?

maxpenguin
  • 5,039
  • 6
  • 28
  • 22

1 Answers1

2

I asked about this at Github here. Apparently it is not possible, and is a lot more complex than I realized.

maxpenguin
  • 5,039
  • 6
  • 28
  • 22
  • 1
    Yep, i looked for a way to do pdf templates some time ago, and it turns out to be pretty difficult.. the closest thing i found was to use pdf forms with something like this : https://github.com/moessimple/prawn-fillform . If you find a solution i would be glad to know ! – vdaubry Mar 10 '13 at 21:50