开发者

ruby prawn how to wrap text around an aligned right image?

开发者 https://www.devze.com 2022-12-16 22:03 出处:网络
s it posible to align an image to the right and wrap text around the image like it is in html and css using the float:right property ?

s it posible to align an image to the right and wrap text around the image like it is in html and css using the float:right property ?

If so how do you do this ?

I can align an image but dont't know how to wrap the text around it. The text is dynam开发者_运维技巧ic text therefore varies alot in length.

Thanks alot Rick


One suggestion is to try nested bounding boxes. The main bounding box would have the text inside it. with at some point another bounding box for the image. Something along the lines of

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

You may be able to simply use the image without the bounding box, but the bounding box would ensure that the text flows around it.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号