File: vertical.rb

package info (click to toggle)
ruby-prawn 2.2.0%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 4,320 kB
  • sloc: ruby: 15,654; sh: 43; makefile: 20
file content (25 lines) | stat: -rw-r--r-- 906 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# To set the vertical position of an image use the <code>:vposition</code>
# option.
#
# It may be <code>:top</code>, <code>:center</code>, <code>:bottom</code> or a
# number representing the y-offset from the top boundary.

require_relative '../example_helper'

filename = File.basename(__FILE__).gsub('.rb', '.pdf')
Prawn::ManualBuilder::Example.generate(filename) do
  bounding_box([0, cursor], width: 500, height: 450) do
    stroke_bounds

    [:top, :center, :bottom].each do |vposition|
      text "Image vertically aligned to the #{vposition}.", valign: vposition
      image "#{Prawn::DATADIR}/images/stef.jpg",
        position: 250, vposition: vposition
    end

    text_box 'The next image has a 100 point offset from the top boundary',
      at: [bounds.width - 110, bounds.top - 10], width: 100
    image "#{Prawn::DATADIR}/images/stef.jpg",
      position: :right, vposition: 100
  end
end