ruby prawn如何围绕对齐的右图包装文字?

时间:2010-01-18 10:01:15

标签: ruby-on-rails ruby pdf-generation prawn prawnto

可以将图像右对齐并使用float:right属性在html和css中包围图像周围的文本吗?

如果是这样,你怎么做?

我可以对齐图像,但不知道如何将文本包裹起来。文本是动态文本因此长度变化很多。

非常感谢 瑞克

1 个答案:

答案 0 :(得分:2)

一个建议是尝试嵌套的边界框。主边界框内有文本。在某些时候,图像的另一个边界框。

的内容
bounding_box([x,y], :width => bounds.width, :height => 400) do
    text "blah"
    text "blah"
    # image
    bounding_box([bounds.right - image_width, 0], :width => image_width) do
          image("path_to_file", :at => [0,0], :width =>  bounds)
    text "more blah"


end

您可以简单地使用没有边界框的图像,但边界框将确保文本在其周围流动。