http://plnkr.co/edit/jtMdP3E2LJMBs6CzBzLQ?p=preview我试图在页面底部绘制一组带有条款和条件的签名字段。我是Prawn的新手,所以我对此有点麻烦。我查看了column_box
方法,看起来在某些文档中有一些left_side
和right_side
方法,但这些方法似乎不起作用(我得到了一个NoMethodError
)或其他什么。
我想要的是两个签名字段,每个字段下面都有文字。页面左侧之一,右侧之一。我该怎么做?
我的代码示例:
column_box([0, cursor], :columns => 2, :width => bounds.width) do
text "_______________________"
text "Signature 1"
right_side
text "_______________________"
text "Signature 2"
end
我得到的错误:
undefined local variable or method `right_side' for #<Prawnto::TemplateHandlers::Renderer:0x00000005b3a420>
答案 0 :(得分:3)
您可以使column_box具有2列,然后调整高度以匹配下划线的大小及其下方的文本,这样就会打破它们之间的列。 它会是这样的:
Prawn::Document.generate("hello.pdf") do
column_box([0, cursor],:columns => 2, :width => bounds.width, :height => 75) do
# For default font 2x 25px lines are enough to break an 75px height column
# You should adjust height of the box and font_size to match
# your desired 2-column effect
font_size 25
text("___________")
text("Foo")
text("___________")
text("Bar")
end
end
不要忘记您必须为:columns => 2
指定height
和column_box
属性以获得所需的2列效果。