Sha256: 3e550e6c5da13d7a4f0fc0c15c059699bff69ac3942a194113fa7f646d31160f

Contents?: true

Size: 1.32 KB

Versions: 11

Compression:

Stored size: 1.32 KB

Contents

#!/usr/bin/env ruby

require 'rubygems'
require 'rtf'

include RTF

colours = [Colour.new(0, 0, 0),
           Colour.new(255, 255, 255)]
           
# Create the used styles.
styles                           = {}
styles['EMPHASISED']             = CharacterStyle.new
styles['EMPHASISED'].bold        = true
styles['EMPHASISED'].underline   = true
styles['NORMAL']                 = ParagraphStyle.new
styles['NORMAL'].space_after     = 300

document = Document.new(Font.new(Font::ROMAN, 'Arial'))

document.paragraph(styles['NORMAL']) do |p|
   p << 'This document is a simple programmatically generated file that is '
   p << 'used to demonstrate table generation. A table containing 3 rows '
   p << 'and three columns should be displayed below this text.'
end

table    = document.table(3, 3, 2000, 4000, 2000)
table.border_width = 5
table[0][0] << 'Cell 0,0'
table[0][1].top_border_width = 10
table[0][1] << 'This is a little preamble text for '
table[0][1].apply(styles['EMPHASISED']) << 'Cell 0,1'
table[0][1].line_break
table[0][1] << ' to help in examining how formatting is working.'
table[0][2] << 'Cell 0,2'
table[1][0] << 'Cell 1,0'
table[1][1] << 'Cell 1,1'
table[1][2] << 'Cell 1,2'
table[2][0] << 'Cell 2,0'
table[2][1] << 'Cell 2,1'
table[2][2] << 'Cell 2,2'

File.open('example02.rtf', 'w') do |file|
   file.write(document.to_rtf)
end

Version data entries

11 entries across 11 versions & 3 rubygems

Version Path
rtf-0.3.0 examples/example02.rb
clbustos-rtf-0.4.2 examples/example02.rb
panmind-rtf-0.4.1 examples/example02.rb
panmind-rtf-0.4.0 examples/example02.rb
clbustos-rtf-0.3.1 examples/example02.rb
panmind-rtf-0.3.1 examples/example02.rb
clbustos-rtf-0.3.0 examples/example02.rb
clbustos-rtf-0.2.2 examples/example02.rb
clbustos-rtf-0.2.1 examples/example02.rb
clbustos-rtf-0.1.2 examples/example02.rb
rtf-0.1.0 examples/example02.rb