【问题标题】:Prawn: Is there a way for vertical alignment of all content in a box?大虾:有没有办法让一个盒子里的所有内容垂直对齐?
【发布时间】:2011-12-11 06:59:39
【问题描述】:

我正在尝试将一些内容垂直居中放置在 bounding_box 中。使用单个文本没问题:

bounding_box([0, bounds.top], :width => pdf.bounds.right, :height => pdf.bounds.top) do
  text "vertically aligned in the surrounding box", :valign => :center
end

但是如果我的边界框中有多个元素,我该怎么办:

bounding_box([0, bounds.top], :width => pdf.bounds.right, :height => pdf.bounds.top) do
  text "vertically aligned in the surrounding box", :valign => :center
  text "vertically aligned in the surrounding box", :valign => :center
end

那不行,当你尝试这个时,文本被覆盖了......

我正在寻找一种方法来对 bounding_box 的全部内容进行分组,然后垂直对齐整个组。有没有办法用大虾做到这一点??

非常感谢您的帮助! 克里斯

【问题讨论】:

    标签: ruby alignment prawn bounding-box valign


    【解决方案1】:

    如果您只有文本行,您仍然可以在文本中使用formatted_text\n

    formatted_text [
        { text: "#{line1}\n" },
        { text: "#{line2}" }
      ],
      valign: :center,
      leading: 6
    

    我仍在试图弄清楚如何处理图片/图例组,因为即使是表格似乎也无法解决问题。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-09-04
      • 2021-03-08
      • 1970-01-01
      • 2020-08-28
      • 2016-05-09
      • 1970-01-01
      相关资源
      最近更新 更多