Method: RTF::Document#to_rtf

Defined in:
lib/rtf/node.rb

#to_rtfObject

This method generates the RTF text for a Document object.



1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
# File 'lib/rtf/node.rb', line 1798

def to_rtf
   text = StringIO.new

   text << "{#{prefix}\\#{@character_set.id2name}"
   text << "\\deff#{@default_font}"
   text << "\\deflang#{@language}" if @language != nil
   text << "\\plain\\fs24\\fet1"
   text << "\n#{@fonts.to_rtf}"
   text << "\n#{@colours.to_rtf}" if @colours.size > 0
   text << "\n#{@information.to_rtf}"
   text << "\n#{@lists.to_rtf}"
   if @headers.compact != []
      text << "\n#{@headers[3].to_rtf}" if @headers[3] != nil
      text << "\n#{@headers[2].to_rtf}" if @headers[2] != nil
      text << "\n#{@headers[1].to_rtf}" if @headers[1] != nil
      if @headers[1] == nil or @headers[2] == nil
         text << "\n#{@headers[0].to_rtf}"
      end
   end
   if @footers.compact != []
      text << "\n#{@footers[3].to_rtf}" if @footers[3] != nil
      text << "\n#{@footers[2].to_rtf}" if @footers[2] != nil
      text << "\n#{@footers[1].to_rtf}" if @footers[1] != nil
      if @footers[1] == nil or @footers[2] == nil
         text << "\n#{@footers[0].to_rtf}"
      end
   end
   text << "\n#{@style.prefix(self)}" if @style != nil
   self.each {|entry| text << "\n#{entry.to_rtf}"}
   text << "\n}"

   text.string
end