【问题标题】:Replace some text in a PDF template using Prawn in Ruby在 Ruby 中使用 Prawn 替换 PDF 模板中的一些文本
【发布时间】:2013-03-07 03:26:56
【问题描述】:

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

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

这很好用,我可以以正常方式添加到文档中 - 但是我想搜索并替换一些从模板中添加的文本。对虾有可能吗?

查看 Prawn 代码,它执行以下操作:

 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 查看并更改现有的流吗?

【问题讨论】:

  • 似乎基于意见。

标签: ruby pdf prawn


【解决方案1】:

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

【讨论】:

  • 是的,我前段时间寻找了一种制作 pdf 模板的方法,结果发现它非常困难.. 我发现最接近的方法是使用类似这样的 pdf 表单:@987654322 @ .如果您找到解决方案,我很高兴知道!
猜你喜欢
  • 2011-06-19
  • 1970-01-01
  • 2019-09-19
  • 2015-05-08
  • 1970-01-01
  • 2019-04-14
  • 1970-01-01
  • 2012-04-27
  • 1970-01-01
相关资源
最近更新 更多