File: cursor.rb

package info (click to toggle)
ruby-prawn 1.0.0~rc1%2Bdfsg1-3
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 4,248 kB
  • sloc: ruby: 17,499; sh: 44; makefile: 17
file content (33 lines) | stat: -rw-r--r-- 1,217 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
26
27
28
29
30
31
32
33
# encoding: utf-8
#
# We normally write our documents from top to bottom and it is no different with
# Prawn. Even if the origin is on the bottom left corner we still fill the page
# from the top to the bottom. In other words the cursor for inserting content
# starts on the top of the page.
#
# Most of the functions that insert content on the page will start at the
# current cursor position and proceed to the bottom of the page.
#
# The following snippet shows how the cursor behaves when we add some text to the
# page and demonstrates some of the helpers to manage the cursor position. The
# <code>cursor</code> method returns the current cursor position.
#
require File.expand_path(File.join(File.dirname(__FILE__),
                                   %w[.. example_helper]))

filename = File.basename(__FILE__).gsub('.rb', '.pdf')
Prawn::Example.generate(filename) do
  stroke_axis
  
  text "the cursor is here: #{cursor}"
  text "now it is here: #{cursor}"
  
  move_down 200
  text "on the first move the cursor went down to: #{cursor}"
  
  move_up 100
  text "on the second move the cursor went up to: #{cursor}"
  
  move_cursor_to 50
  text "on the last move the cursor went directly to: #{cursor}"
end