Changeset 997

Show
Ignore:
Timestamp:
05/13/07 19:22:34 (2 years ago)
Author:
sandal
Message:

Formatting system tutorial

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • ruport-www/cheatsheets/formatting.html

    r996 r997  
    206206requires a few simple lines, hiding all formatting complexity.</p> 
    207207 
     208<p>The output for this report is shown below</p> 
     209<pre> 
     210*************************************************************************** 
     211  December Sales Figures 
     212*************************************************************************** 
     213 
     214isbn           |title                         |author         |sales      
     215########################################################################### 
     216978111111111   |Book Number One               |me             |10         
     217978222222222   |Two is better than one        |you            |267        
     218978333333333   |Three Blind Mice              |John Howard    |1          
     219978444444444   |The number 4                  |George Bush    |1829       
     220###########################################################################       
     221</pre> 
    208222 
    209223        <h3>Adding <span class="caps">PDF</span></h3> 
     
    245259 
    246260    def build_document_body  
    247       draw_table titles, :maximum_width => 500 
    248                          :column_order => %w[isbn title author sales] 
     261      draw_table Table(:column_names => %w[isbn title author sales], 
     262                       :data => titles), :maximum_width => 500 
    249263    end 
    250264 
    251265    def finalize_document 
    252       output &lt;&lt; pdf_writer.render 
     266      render_pdf 
    253267    end 
    254268  end 
     
    306320  File.open("dec_sales.pdf", "w") { |f| f.write report } 
    307321</code></pre> 
     322       
     323We end up with pretty output like this: 
     324 
     325 
    308326 
    309327        <p>Switching output formats within your app according to user preference or