Search code examples
ruby-on-rails-3pdfprawn

How to add background/fill color to a bounding_box in Prawn


Is it possible to add a background color to a bounding_box in Prawn?

 bounding_box([100, cursor], width: 80, height: 20) do
    pad_top(7) { text "THIS IS TEXT", size: 8, align: :center }
    stroke_bounds
 end 

Ive tried adding this to the bounding_box block

     background_color: "CCCCCC"

Ive tried adding this inside the block

    fill_color "CCCCCC"
    background_color "CCCCCC"

Nothing seems to work with a bounding_box


Solution

  • Here the code

        bounding_box([200,cursor], :width => 350, :height => 80) do
            stroke_color 'FFFFFF'
            stroke_bounds
            stroke do
                stroke_color 'FFFF00'
                fill_color '36DA5C'
                fill_and_stroke_rounded_rectangle [cursor-80,cursor], 350, 80, 10
                fill_color '000000'
            end
        end