Replace some text in a PDF template using Prawn in Ruby

穿精又带淫゛_ 提交于 2019-12-11 09:18:41

问题


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?


回答1:


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



来源:https://stackoverflow.com/questions/15262548/replace-some-text-in-a-pdf-template-using-prawn-in-ruby

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!