class Prawn::Format::TextObject
Constants
- RENDER_MODES
Public Class Methods
new()
click to toggle source
# File lib/prawn/format/text_object.rb, line 20 def initialize @content = nil @last_x = @last_y = 0 end
Public Instance Methods
add_content(string)
click to toggle source
# File lib/prawn/format/text_object.rb, line 101 def add_content(string) @content << string << "\n" end
character_space(dc)
click to toggle source
# File lib/prawn/format/text_object.rb, line 55 def character_space(dc) @content << "#{dc} Tc\n" self end
close()
click to toggle source
# File lib/prawn/format/text_object.rb, line 30 def close @content << "ET" self end
font(identifier, size)
click to toggle source
# File lib/prawn/format/text_object.rb, line 70 def font(identifier, size) @content << "/#{identifier} #{size} Tf\n" self end
leading(dl)
click to toggle source
# File lib/prawn/format/text_object.rb, line 65 def leading(dl) @content << "#{dl} TL\n" self end
move_by(dx,dy)
click to toggle source
# File lib/prawn/format/text_object.rb, line 39 def move_by(dx,dy) @last_x += dx @last_y += dy @content << "#{dx} #{dy} Td\n" self end
move_to(x, y)
click to toggle source
# File lib/prawn/format/text_object.rb, line 35 def move_to(x, y) move_by(x - @last_x, y - @last_y) end
next_line(dy)
click to toggle source
# File lib/prawn/format/text_object.rb, line 46 def next_line(dy) end
open()
click to toggle source
# File lib/prawn/format/text_object.rb, line 25 def open @content = "BT\n" self end
render(mode)
click to toggle source
# File lib/prawn/format/text_object.rb, line 75 def render(mode) mode_value = RENDER_MODES[mode] || raise(ArgumentError, "unsupported render mode #{mode.inspect}, should be one of #{RENDER_MODES.keys.inspect}") @content << "#{mode_value} Tr\n" self end
rise(value)
click to toggle source
# File lib/prawn/format/text_object.rb, line 81 def rise(value) @content << "#{value} Ts\n" self end
rotate(x, y, theta)
click to toggle source
# File lib/prawn/format/text_object.rb, line 86 def rotate(x, y, theta) radians = theta * Math::PI / 180 cos, sin = Math.cos(radians), Math.sin(radians) arr = [cos, sin, -sin, cos, x, y] add_content "%.3f %.3f %.3f %.3f %.3f %.3f Tm" % arr end
show(argument)
click to toggle source
# File lib/prawn/format/text_object.rb, line 49 def show(argument) instruction = argument.is_a?(Array) ? "TJ" : "Tj" @content << "#{Prawn::PdfObject(argument, true)} #{instruction}\n" self end
to_s()
click to toggle source
# File lib/prawn/format/text_object.rb, line 93 def to_s @content end
to_str()
click to toggle source
# File lib/prawn/format/text_object.rb, line 97 def to_str @content end
word_space(dw)
click to toggle source
# File lib/prawn/format/text_object.rb, line 60 def word_space(dw) @content << "#{dw} Tw\n" self end