# encoding: utf-8
#
# There are two other text methods available: formatted_text
and
# formatted_text_box
.
#
# These are useful when the provided text has numerous portions that need to be
# formatted differently. As you might imply from their names the first should
# be used for free flowing text just like the text
method and the
# last should be used for positioned text just like text_box
.
#
# The main difference between these methods and the text
and
# text_box
methods is how the text is provided. The
# formatted_text
and formatted_text_box
methods accept
# an array of hashes. Each hash must provide a :text
option which
# is the text string and may provide the following options: :styles
# (an array of symbols), :size
(the font size),
# :character_spacing
(additional space between the characters),
# :font
(the name of a registered font), :color
(the
# same input accepted by fill_color
and stroke_color
),
# :link
(an URL to create a link), :anchor
(a
# destination inside the document), and :local
(a link to a local
# file).
#
require File.expand_path(File.join(File.dirname(__FILE__),
%w[.. example_helper]))
filename = File.basename(__FILE__).gsub('.rb', '.pdf')
Prawn::Example.generate(filename) do
formatted_text [ { :text => "Some bold. ", :styles => [:bold] },
{ :text => "Some italic. ", :styles => [:italic] },
{ :text => "Bold italic. ", :styles => [:bold, :italic] },
{ :text => "Bigger Text. ", :size => 20 },
{ :text => "More spacing. ", :character_spacing => 3 },
{ :text => "Different Font. ", :font => "Courier" },
{ :text => "Some coloring. ", :color => "FF00FF" },
{ :text => "Link to the wiki. ",
:color => "0000FF",
:link => "https://github.com/prawnpdf/prawn/wiki" },
{ :text => "Link to the Text Reference. " ,
:color => "0000FF",
:anchor => "Text Reference" },
{ :text => "Link to a local file. ",
:color => "0000FF",
:local => "./local_file.txt" }
]
formatted_text_box [ { :text => "Just your regular" },
{ :text => " text_box ", :font => "Courier" },
{ :text => "with some additional formatting options " +
"added to the mix.",
:color => [50, 100, 0, 0],
:styles => [:italic] }
], :at => [100, 100], :width => 200, :height => 100
end