Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using lists in prawn

Im using prawn to create pdfs that contain much data in table format and some lists. The problem with the lists is that Im just using text as lists because there is no semantic equivalent to ul > li lists like I use them in the webfrointend. So the lists arent justified. A list point that uses more than one line looks creapy because I doesnt fit the list icon. How can I implement lists in prawn that dont look like crap?

like image 988
davidb Avatar asked May 09 '12 09:05

davidb


1 Answers

One go-around is to create a method similar to crm's answer. The difference is that it won't break when the text goes to another page and you can have multiple levels as well.

def bullet_item(level = 1, string)
    indent (15 * level), 0 do
        text "• " + string
    end
end

Simply call this method like so:

bullet_item(1, "Text for bullet point 1")
bullet_item(2, "Sub point")

Feel free to refactor.

like image 172
Artem Kalinchuk Avatar answered Oct 16 '22 22:10

Artem Kalinchuk