Is there a way to keep text as a same block when a new page (don't break it). If it exists, what is the command?
I mean for example, I have a paragraph of five lines. When a new page starts I don't want two lines in the first page and three lines in the second page. I want the lines to stay together. Another way to do it : put the five lines in the second page.
After group was removed I did it this way:
I get the height of the text block
height = pdf.height_of_formatted([{ :text => my_text, size: 14, style: :bold }])
And compare the height with the remaining space on the page. If there's no space for the whole text block, I start a new page before printing.
if pdf.cursor < height
pdf.start_new_page
end
I know, this is more complicated than it was to create a simple group-block, but at least it works and can be altered to all kinds of situations and formattings.
You could just do :
pdf.group do
#Your code
end
Is that what you were looking for ??
Im a newbie so dont take me seriously. But there seems to be these block text holders in prawn. You can make the borders invisible. So you put the text in one of the boxes and maybe it moves automatically to a new page if the whole box doesnt fit on the last page?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With