【发布时间】:2017-10-27 08:59:24
【问题描述】:
我正在使用 Prawn.rb 生成 pdf 并遇到一个问题:
我在每个页面上都有一个标题,当我使用 span 时,span 中的文本会流动到下一页并与标题重叠,但如果我使用 bounding_box,其中的文本将从 bounding_box所在的光标处开始> 从文本流到下一页时开始。
这是我的标题:
repeat(:all) do
transparent(0.5) do
bounding_box [bounds.left, bounds.top], :width =>
bounds.width do
image "#{Rails.root}/app/assets/images/logo-of-
nextcode.png", height: 20
move_down 2
stroke_horizontal_rule
end
bounding_box [bounds.left, bounds.bottom + 50], :width => bounds.width do
text_box 'PRIVATE & CONFIDENTIAL', align: :center, valign: :bottom, size: 10
end
end
这里是长文本:
span(bounds.width) do
object.actions.each_with_index do |a, i|
text "#{i + 1}. Description: #{a.message}"
text_box "Expected Completion Date: #{a.expected_completion_time&.strftime('%F')}", at: [0, cursor]
move_down 15
text_box "Actual Completion Date: #{a.actual_completion_time&.strftime('%F')}", at: [0, cursor]
move_down 20
end
end
我的问题是:如果使用 span 如何避免与标题重叠,如果使用 bounding_box ?
【问题讨论】:
标签: ruby-on-rails pdf prawn