Saturday, 15 January 2011

ruby on rails - Prawn: Formatting a bounding box -



ruby on rails - Prawn: Formatting a bounding box -

i programming , ruby novice, trying utilize prawn generate pdf. next prawn manual having problems putting text in bounding box. here code, comes prawn manual... :

pdf.bounding_box([200, pdf.cursor - 100], :width => 200, :height => 100) pdf.text "just regular bounding box" pdf.transparent(0.5) { pdf.stroke_bounds } end

if remove line: pdf.transparent(0.5) { stroke_bounds }, code work can't see text box. need change?

i'm not sure understand issue. when

the code work, can't see text box

do mean can't see box's borders, can still see text? or can't see text either? expect former, since stroke_bounds causes borders drawn.

so reply "what need change", depends on you're trying accomplish:

if need text don't need box borders, can remove `pdf.transparent(0.5) { pdf.stroke_bounds }, job draw semi-transparent (i.e. gray) border around bounding box

if want border, leave line in

if want border, want height of box conform height of text, remove :height => 100 first line. bounding_box height adjust fit text.

ruby-on-rails prawn

No comments:

Post a Comment