15

I am using prawn to generate a pdf. So far everything has been rather straight forward. I am having a problem defining the leading between lines of text. For example: when using a text_box

pdf.text_box "Ipsum dolor sit amet consectetue?",
  :width    => pdf.bounds.width - 10, :height => 150,
  :overflow => :ellipses

This will generate the text box except I can not find in the docs on how to control the spacing between lines of text. The strings I will be using are typically 5 to 8 lines long.

Thank you in advance

  • 1
    I don't have an answer for you, but if you visit the Prawn source at Github, the examples directory seem reasonably full. You may find it in there: http://github.com/sandal/prawn – Telemachus Dec 23 '09 at 21:17
  • It doesn't seem that a text box has a leading option, and text doesn't seem to automatically control overflow. I have rolled my own for the overflow and used the :leading option on pdf.text to solve this. –  Jan 13 '10 at 15:03

1 Answers1

29

I know this isn't the perfect answer, but you can use the leading option with pdf.text (maybe you figured this out already):

sometext = "My big long string\ncovering multiple lines"  
pdf.text sometext, :size => 10, :leading => 5

Maybe you could use this with a bounding box like so:

 pdf.bounding_box([270,650], :width=>270, :height=>250) do
   pdf.text sometext, :size => 10, :leading => 5
 end
Henry
  • 323
  • 3
  • 5
  • 1
    This should have been accepted. This is the perfect answer especially considering that `:leading` accepts negative values correctly. – Arnaud Meuret Nov 02 '16 at 12:44