Files

Ruport::Formatter::PDF::DrawingHelpers

This module provides tools to simplify some common drawing operations. It is included by default in the PDF formatter.

Public Instance Methods

bottom_boundary() click to toggle source

Alias for PDF::Writer#absolute_bottom_margin

# File lib/ruport/formatter/pdf.rb, line 347
def bottom_boundary
  pdf_writer.absolute_bottom_margin
end
cursor() click to toggle source

Alias for PDF::Writer#y

# File lib/ruport/formatter/pdf.rb, line 352
def cursor
  pdf_writer.y
end
draw_text(text,text_opts) click to toggle source

Draws text at an absolute location, defined by :y, :x1|:left, :x2|:right

All options to add_text are also supported.

# File lib/ruport/formatter/pdf.rb, line 360
def draw_text(text,text_opts)
  ypos = cursor
  move_cursor_to(text_opts[:y]) if text_opts[:y]
  add_text(text,
    text_opts.merge(:absolute_left => text_opts[:x1] || text_opts[:left],
    :absolute_right => text_opts[:x2] || text_opts[:right]))
  move_cursor_to(ypos)
end
draw_text!(text,text_opts) click to toggle source

Draws text at an absolute location, defined by :y, :x1|:left

The x position defaults to the left margin and the y position defaults to the current cursor location.

Uses PDF::Writer#add_text, so it will ignore any options not supported by that method.

# File lib/ruport/formatter/pdf.rb, line 377
def draw_text!(text,text_opts)
  ypos = cursor
  pdf_writer.add_text(text_opts[:x1] || text_opts[:left] || left_boundary,
    text_opts[:y] || ypos,
    text,
    text_opts[:font_size],
    text_opts[:angle] || 0)
  move_cursor_to(ypos)
end
finalize() click to toggle source
# File lib/ruport/formatter/pdf.rb, line 387
def finalize
  render_pdf
end
horizontal_line(x1,x2) click to toggle source

Draws a horizontal line from x1 to x2

# File lib/ruport/formatter/pdf.rb, line 313
def horizontal_line(x1,x2)
  pdf_writer.line(x1,cursor,x2,cursor)
  pdf_writer.stroke
end
horizontal_rule() click to toggle source

Draws a horizontal line from left_boundary to right_boundary

# File lib/ruport/formatter/pdf.rb, line 319
def horizontal_rule
  horizontal_line(left_boundary,right_boundary)                                            
end
Also aliased as: hr
hr() click to toggle source
Alias for: horizontal_rule
left_boundary() click to toggle source

Alias for PDF::Writer#absolute_left_margin

# File lib/ruport/formatter/pdf.rb, line 332
def left_boundary
  pdf_writer.absolute_left_margin
end
right_boundary() click to toggle source

Alias for PDF::Writer#absolute_right_margin

# File lib/ruport/formatter/pdf.rb, line 337
def right_boundary
  pdf_writer.absolute_right_margin
end
top_boundary() click to toggle source

Alias for PDF::Writer#absolute_top_margin

# File lib/ruport/formatter/pdf.rb, line 342
def top_boundary
  pdf_writer.absolute_top_margin
end
vertical_line_at(x,y1,y2) click to toggle source

Draws a vertical line at x from y1 to y2

# File lib/ruport/formatter/pdf.rb, line 326
def vertical_line_at(x,y1,y2)
  pdf_writer.line(x,y1,x,y2)
  pdf_writer.stroke 
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.