lib/wiz_rtf/document.rb in wiz_rtf-0.6.8 vs lib/wiz_rtf/document.rb in wiz_rtf-0.6.9
- old
+ new
@@ -7,29 +7,29 @@
module WizRtf
# = Rtf Document
#
# Creates a new Rtf document specifing the format of the pages.
# == Example:
- # ```ruby
- # doc = WizRtf::Document.new do
- # text "A Example of Rtf Document", 'text-align' => :center, 'font-family' => 'Microsoft YaHei', 'font-size' => 48, 'font-bold' => true, 'font-italic' => true, 'font-underline' => true
- # image('h:\eahey.png')
- # page_break
- # text "A Table Demo", 'foreground-color' => WizRtf::Color::RED, 'background-color' => '#0f00ff'
- # table [[{content: WizRtf::Image.new('h:\eahey.png'),rowspan:4},{content:'4',rowspan:4},1,{content:'1',colspan:2}],
- # [{content:'4',rowspan:3,colspan:2},8],[11]], column_widths:{1=>100,2 => 100,3 => 50,4 => 50,5 => 50} do
- # add_row [1]
+ #
+ # doc = WizRtf::Document.new do
+ # text "A Example of Rtf Document", 'text-align' => :center, 'font-family' => 'Microsoft YaHei', 'font-size' => 48, 'font-bold' => true, 'font-italic' => true, 'font-underline' => true
+ # image('h:\eahey.png')
+ # page_break
+ # text "A Table Demo", 'foreground-color' => WizRtf::Color::RED, 'background-color' => '#0f00ff'
+ # table [[{content: WizRtf::Image.new('h:\eahey.png'),rowspan:4},{content:'4',rowspan:4},1,{content:'1',colspan:2}],
+ # [{content:'4',rowspan:3,colspan:2},8],[11]], column_widths:{1=>100,2 => 100,3 => 50,4 => 50,5 => 50} do
+ # add_row [1]
+ # end
# end
- # end
- # doc.save('c:\text.rtf')
- # ```
+ # doc.save('c:\text.rtf')
+ #
class Document
def initialize(options = {}, &block)
@fonts = []
@colors = []
@parts = []
- font 'Courier New'
+ font 'NSimSun'
block.arity<1 ? self.instance_eval(&block) : block.call(self) if block_given?
end
# Outputs the Complete Rtf Document to a Generic Stream as a Rich Text Format (RTF)
# * +io+ - The Generic IO to Output the RTF Document
@@ -109,22 +109,24 @@
# This will add a string of +str+ to the document, starting at the
# current drawing position.
# == Styles:
# * +text-align+ - sets the horizontal alignment of the text. optional values: +:left+, +:center+, +:right+
- # * +font-family+ - set the font family of the text. optional values: 'Arial', 'Arial Black', 'Arial Narrow','Bitstream Vera Sans Mono',
- # 'Bitstream Vera Sans','Bitstream Vera Serif','Book Antiqua','Bookman Old Style','Castellar','Century Gothic',
- # 'Comic Sans MS','Courier New','Franklin Gothic Medium','Garamond','Georgia','Haettenschweiler','Impact','Lucida Console'
- # 'Lucida Sans Unicode','Microsoft Sans Serif','Monotype Corsiva','Palatino Linotype','Papyrus','Sylfaen','Symbol'
- # 'Tahoma','Times New Roman','Trebuchet MS','Verdana'.
+ # * +font-family+ - set the font family of the text.
+ # - optional values:
+ # 'Arial', 'Arial Black', 'Arial Narrow','Bitstream Vera Sans Mono',
+ # 'Bitstream Vera Sans','Bitstream Vera Serif','Book Antiqua','Bookman Old Style','Castellar','Century Gothic',
+ # 'Comic Sans MS','Courier New','Franklin Gothic Medium','Garamond','Georgia','Haettenschweiler','Impact','Lucida Console'
+ # 'Lucida Sans Unicode','Microsoft Sans Serif','Monotype Corsiva','Palatino Linotype','Papyrus','Sylfaen','Symbol'
+ # 'Tahoma','Times New Roman','Trebuchet MS','Verdana'.
# * +font-size+ - set font size of the text.
# * +font-bold+ - setting the value true for bold of the text.
# * +font-italic+ - setting the value true for italic of the text.
# * +font-underline+ - setting the value true for underline of the text.
# == Example:
#
- # text "A Example of Rtf Document", 'text-align' => :center, 'font-family' => 'Microsoft YaHei', 'font-size' => 48, 'font-bold' => true, 'font-italic' => true, 'font-underline' => true
+ # text "A Example of Rtf Document", 'text-align' => :center, 'font-family' => 'Microsoft YaHei', 'font-size' => 48, 'font-bold' => true, 'font-italic' => true, 'font-underline' => true
#
def text(str, styles = {})
styles['foreground-color'] = color(styles['foreground-color']) if styles['foreground-color']
styles['background-color'] = color(styles['background-color']) if styles['background-color']
styles['font-family'] = font(styles['font-family']) if styles['font-family']
@@ -140,17 +142,17 @@
# Creates a new Table
# * +rows+ - a table can be thought of as consisting of rows and columns.
# == Options:
# * +column_widths+ - sets the widths of the Columns.
# == Example:
- # ```ruby
- # table [
- # [{content: WizRtf::Image.new('h:\eahey.png'),rowspan:4},{content:'4',rowspan:4},1,{content:'1',colspan:2}],
- # [{content:'4',rowspan:3,colspan:2},8],[11]
- # ], column_widths:{1=>100,2 => 100,3 => 50,4 => 50,5 => 50} do
- # add_row [1]
- # end
- # ```
+ #
+ # table [
+ # [{content: WizRtf::Image.new('h:\eahey.png'),rowspan:4},{content:'4',rowspan:4},1,{content:'1',colspan:2}],
+ # [{content:'4',rowspan:3,colspan:2},8],[11]
+ # ], column_widths:{1=>100,2 => 100,3 => 50,4 => 50,5 => 50} do
+ # add_row [1]
+ # end
+ #
def table(rows = [],options = {}, &block)
@parts << WizRtf::Table.new(rows, options, &block)
end
# Writes a new line.