Wrap text around the image in rails and shrimp

I have a document with a dynamic image and dynamic text, and I need text around the image. The image is right-aligned on the landscape page. Here is what I still have:

pdf.bounding_box([0,pdf.bounds.top - 50], :width => pdf.bounds.width, :height => pdf.bounds.height-50) do pdf.text @article.title, :size => 30, :style => :bold pdf.text @article.content, :align => :left # image pdf.bounding_box([pdf.bounds.right - 250, pdf.bounds.top], :width => 250, :height => 250) do pdf.image image_path, :width => 250 end end 

The text goes right below the image. I tried to do this , but it did not work.

Help evaluate, thanks.

+4
source share
2 answers

If you know the width and height of the image, you can use text_box to place the text box next to the image and collect the returned line of text that does not fit. Then create a second text box or a regular text () call under the image and text box, and you should be good to go.

This example should help: http://github.com/sandal/prawn/blob/0.9.1/examples/text/text_box_returning_excess.rb

+2
source

I don't have much experience with shrimp, so this is just a hunch. Have you tried to put your pdf.text instructions after the frame with the image limit?

 pdf.bounding_box([0,pdf.bounds.top - 50], :width => pdf.bounds.width, :height => pdf.bounds.height-50) do # image pdf.bounding_box([pdf.bounds.right - 250, pdf.bounds.top], :width => 250, :height => 250) do pdf.image image_path, :width => 250 end pdf.text @article.title, :size => 30, :style => :bold pdf.text @article.content, :align => :left end 
0
source

Source: https://habr.com/ru/post/1307700/


All Articles