Class: RGhost::TextIn

Inherits:
PsObject show all
Includes:
RubyToPs
Defined in:
lib/rghost/text_in.rb

Overview

TextIn is a helper to combine the cursor positioning and text output into one step.

Constant Summary collapse

DEFAULT_OPTIONS =
{:x=> :limit_left,:y=> :current_row, :tag => :default_font, :write => "Ruby Ghost API - current_row = %row% "}

Constants included from RubyToPs

RubyToPs::UTF8_ENCODINGS

Instance Method Summary collapse

Methods included from RubyToPs

#array_to_stack, #hash_to_array, #pack_string, #ps_escape, #string_eval, #to_array, #to_bool, #to_string, #to_string_array

Methods inherited from PsObject

#<<, #call, #graphic_scope, #raw, #set, #to_s

Constructor Details

#initialize(options = {}) ⇒ TextIn

Options

  • :x and :y - Initial position.

  • :tag or :with - Use predefined tag.

  • :color - Override color of the tag.

  • :text or :write - The text.

Examples

doc=RGhost::Document.new doc.text_in :x => 3, :y => 4, :write => “Foo Bar Baz”, :tag => :h1

Rotating

doc.newpath do

translate :x => 3, :y=> 4
 rotate 45
 text_in :x => 0, :y => 0, :write => "Foo Bar Baz1", :tag => :font2

end

Eval postscript internal

TextIn will eval postscript internal variables you pass in between % signs. Sounds complex, huh? Let's see an example: doc.text_in :x=> 3.5, :y=> 5.5, :text => “this is %row% row and current page %current_page%”


25
26
27
28
# File 'lib/rghost/text_in.rb', line 25

def initialize(options={})
  
  @options=DEFAULT_OPTIONS.dup.merge(options)
end

Instance Method Details

#psObject


30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/rghost/text_in.rb', line 30

def ps
  text=RGhost::PsObject.new
  text.set RGhost::Cursor.moveto(@options)
  #text.raw "currentfont"
  #text.raw "currentrgbcolor"
  text.raw RGhost::Color.create(@options[:color])  if @options[:color]
  f="_#{@options[:with] || @options[:tag] || :default_font}"
  text.raw f
  #text.call @options[:with] || @options[:tag]  || :default_font
  
  text.raw string_eval(@options[:text] || @options[:write] )
  #text.raw "setrgbcolor"
  #text.raw "setfont"
  text.graphic_scope
  #text.set PsObject.new(@options[:text])
 
 
  
  
end