在Ruby中使用Prawn替换PDF模板中的一些文本 [英] Replace some text in a PDF template using Prawn in Ruby

查看:95
本文介绍了在Ruby中使用Prawn替换PDF模板中的一些文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用模板使用以下代码在Prawn中生成PDF:

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?

查看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

因此它创建了一个新的内容流以防止更改模板中给定的数据-问题是我可以使用Prawn查看并更改现有流吗?

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?

推荐答案

我在 Github上问了这个问题这里.显然这是不可能的,而且比我意识到的要复杂得多.

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

这篇关于在Ruby中使用Prawn替换PDF模板中的一些文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆