【发布时间】:2012-02-17 11:11:09
【问题描述】:
我在rails 3.0 应用程序中使用Prawn Gem 0.12.0。
我的文档显示良好:
class TemplatePdf < Prawn::Document
def initialize
filename= "#{Prawn::BASEDIR}/data/pdfs/RMA_Formular.pdf"
super(:template => filename)
text_box "2005-xxxx1055", :at=>[40,472]
text_box "#{current_user.email}", :at =>[280, 472]
text_box ...
...
end
text_box 预填充了 RMA 表单的多个表单域。
我想使用 pdf 表单字段的字段名称,而不是使用 text_box "xxx", :at=>[x, y] 手动定位它们。
那么有没有办法将例如用户的电子邮件发送到电子邮件表单字段?
我希望有一些类似的代码
template.fields[:email] => current_user.email
这将按预期填充 pdf 的表单字段,并使我免于硬编码每个模板设计的绝对位置。
【问题讨论】:
标签: ruby-on-rails templates prawn