4

我在 Prawn 中使用 column_box。它运作良好,但与我在底部用于页脚的 bounding_box 重叠。

如何防止重叠,但不调整边界框的高度?

我可以更多地解释为什么我不想调整高度,但我认为它与这个问题无关。这是我的代码:

def test_section
  column_box([0,cursor], :columns => 2, :width => 396) do
    text ("This is text" * 10 + "This is too\n") * 25
    stroke_color (50,0,50,0)
    stroke_bounds
  end

  bounding_box [margin_box.left, margin_box.bottom + 72], :width => bounds.width, :height => 72 do
    font "Helvetica" do
      stroke_color (0,0,100,0)
      stroke_bounds
      text "And here's a sexy footer", :size => 16
    end
  end
end

谢谢你,安东尼

4

1 回答 1

4

我也遇到了这个问题并找到了解决方案。如果你给你的 column_box 一个最大高度,它会阻止它流入页脚。不知道如何将其限制在最后一页,但我在每一页都有页脚(用 bounding_box 周围的“repeat :all”完成)。

    column_box([0,cursor], :columns => 2, :width => 396, :height => bounds.height - 80) do
        text ("This is text" * 10 + "This is too\n") * 25
        stroke_bounds
      end

    repeat :all do
      bounding_box [margin_box.left, margin_box.bottom + 72], :width => bounds.width, :height => 72 do
        font "Helvetica" do
          stroke_bounds
          text "And here's a sexy footer", :size => 16
        end
      end
    end

如果您不使用 column_box,请将您的页面内容放在具有高度限制的 bounding_box 中。

bounding_box([bounds.left, bounds.top], :width  => bounds.width, :height => bounds.height - 80) do
  #page content
end

干杯,戴夫

于 2014-06-12T01:36:35.540 回答