Skip to content
shairontoledo edited this page Sep 13, 2010 · 3 revisions

Show

Writes a text on the current row or points with align. Options:

  • :tag or :with – Uses predefined tag.
  • :color – Overrides color of the tag.
  • :align – Text align.

Examples

The vertical red line is the current point. To align by point

doc.moveto :x => 3, :y => 4
doc.show "Foo Bar Baz", :align => :show_left      #default


doc.moveto :x => 3, :y => 4
doc.show "Foo Bar Baz", :align => :show_center


doc.moveto :x => 3, :y => 4
doc.show "Foo Bar Baz", :align => :show_right

For the current row it‘s not necessary to position using moveto. As below:

doc.show "Foo Bar Baz", :align => :show_right

Now page justification

doc.show "Foo Bar Baz", :align => :page_left
doc.show "Foo Bar Baz", :align => :page_center
doc.show "Foo Bar Baz", :align => :page_right

Overriding tag color

doc.show "Foo Bar Baz", :with => :my_italic, :align => :page_center, :color => :red

Many tags per row. Defining tags


doc=Document.new
doc.define_tags do
  tag :font1, :name => 'Helvetica', :size => 10, :color => '#F34811'
  tag :font2, :name => 'Times',     :size => 14, :color => '#A4297A'
  tag :font3, :name => 'TimesBold', :size => 18, :color => '#AA3903'
end

using them

  
doc.show "foo bar baz ",  :with => :font1
doc.show "qux quux ",     :with => :font2
doc.show "corge ",        :with => :font3
doc.show "grault garply ",:with => :font2
doc.show "qux quux",      :with => :font1

TextIn

TextIn is a helper to combine cursor positioning and text output into one step. 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 evaluate postscript internal variables you pass in between % signs. Sounds complex, huh? Let‘s see an example:

doc.text_in :x=> 3, :y=> 5.5, :text => "this is %row% row and current page %current_page%"

Text

Wraps the text so as the it fits on the page(:area_x). Wrapping happens in whitespace characters without hyphenation. Additionally you can make use of predefined tag and the special tag
to break row. You can disable the parse with second parameter tag_parse=false.

Examples

doc=Document.new 
doc.define_tags do 
  tag :font1, :name => 'Helvetica', :size => 10, :color => '#F34811' 
  tag :font2, :name => 'Times',     :size => 11, :color => '#A4297A' 
  tag :font3, :name => 'TimesBold', :size => 12, :color => '#AA3903' 
end 
my_text="<font1>foo, bar, baz</font1>,<font2>qux, quux</font2>, corge, grault, garply,waldo, <font3>fred, plugh,</font3> xyzzy,<br/> thud, bing" 
doc.text my_text

Without parse


 atext="<font1>foo, bar, baz</font1>,<font2>qux, quux</font2>, corge, grault, garply, waldo, <font3>fred, plugh,</font3> xyzzy,<br/> thud, bing"
  doc.text atext,false

TextArea

TextArea wraps the text so that it fits in a box of a given width. Wrapping happens in whitespace characters without hyphenation. Additionally you can make use of predefined tag and the special tag
to break row. The alignment can be left, right and centered.
PS: It doesn’t jump pages.

Options

  • :x and :y – Initial position.
  • :row_height – Row height :)
  • :width – Maximum width of the text
  • :text_align – Align the text in the virtual box using :left, :right and :center.

Examples


doc=Document.new
my_text="<font1>foo, bar, baz</font1><font2>qux, quux</font2>, corge, grault, garply, waldo, <font3>fred, plugh,</font3> xyzzy,<br/> thud, bing"
doc.text_area my_text
doc.text_area my_text, :width =>3
 

doc.text_area my_text, :width =>3, :text_align => :center
doc.text_area my_text, :width =>3, :text_align => :right
doc.text_area my_text, :width =>3, :text_align => :right, :x => 3
doc.text_area my_text, :width =>3, :text_align => :right, :x => 3, :row_height => 0.6