当我尝试以下代码时:
text "Hello "
text "World"
它们在 Hello 之后将 Hello 渲染在 World 之上而不是 World 之上。我在一行上需要一些复杂的格式(突出显示、不同的字体大小等)。我知道该:inline_formatting
选项存在,但使用该选项似乎太复杂了。
我有以下代码:
highlight_callback.rb:
class HighlightCallback
def initialize(options)
@color = options[:color]
@document = options[:document]
end
def render_behind(fragment)
original_color = @document.fill_color
@document.fill_color = @color
@document.fill_rectangle(fragment.top_left,
fragment.width,
fragment.height)
@document.fill_color = original_color
end
end
order.pdf.prawn:
highlight = HighlightCallback.new(:color => 'ffff00', :document => self)
#code....
text "Authorized Signature: "
formatted_text [{:text => "_" * 15, :callback => highlight }], :size => 20
正在生成附加图像。如何获得与文本相同级别的签名行?