Question

I wish to make some bounding boxes rounded. Is there a way to do this easily?

I understand that one can draw a rounded box separately and have it overlap a text box, but it is too cumbersome. This is because I am using a grid to generate all my boudning boxes, while the rounded box function takes in parameters relative to the entire document.

Était-ce utile?

La solution

You can create a bounding_box, then draw a rounded_rectangle around it, using the initial and current cursor location to determine the bounds of the rectangle. Here's a hard-coded example from my code:

  PADDING = 10
  @current_cursor = cursor

  bounding_box([0, @current_cursor], width: WIDTH) do
    image1 = "#{Rails.root}/app/assets/images/app-icon.png"
    image2 = "#{Rails.root}/app/assets/images/gui-logo.png"

    clinic_data = [[' '],
                   ['<font size="13"><b>Los Angeles Test Medical Center</b></font>'],
                   ['<font size="9">56 Berent Ave. New York, NY 07002</font>'],
                   ['<font size="9">Tel: 212-541-1900 Fax: 212-541-1199</font>']
    ]
    clinic_table = make_table clinic_data, column_widths: [275], cell_style: {borders: {}, inline_format: true, padding: 1, align: :center}

    data = [[{image: image1, image_width: 50, image_height: 50, position: :center, vposition: :center},
             '<font size="11">Structured Ultrasound Reporting<font>',
             clinic_table,
             {image: image2, image_width: 75, vposition: :center, position: :right}]]

    table(data, column_widths: [75, 80, 275], cell_style: {borders: {}, inline_format: true, valign: :center})
  end

  stroke do
    rounded_rectangle [0, @current_cursor + 5], WIDTH + 5, @current_cursor - cursor + PADDING, 10
  end
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top