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

こ雲淡風輕ζ 提交于 2019-12-11 02:12:30

问题


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 dynamic text therefore varies alot in length.

Thanks alot Rick


回答1:


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.



来源:https://stackoverflow.com/questions/2085151/ruby-prawn-how-to-wrap-text-around-an-aligned-right-image

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!