public
Description: Fast, Nimble PDF Writer for Ruby
Homepage: http://prawn.majesticseacreature.com
Clone URL: git://github.com/sandal/prawn.git
Integrating patch from Brian Kenn
Per ticket #98:
allows proper alignment of table headers
cbartlett (author)
Thu Nov 06 19:43:51 -0800 2008
commit  da1e7eb35c63361335b00d84a12c0ea055b63c5a
tree    5e526839042f3d56f80a55a43dc0dc4448236b43
parent  286077da66c66c64e95380e5dce4f5cf5d6dea2f
...
90
91
92
93
 
94
95
96
...
260
261
262
263
264
 
265
266
 
267
268
269
 
 
 
 
 
 
 
 
 
 
 
 
 
270
271
272
...
90
91
92
 
93
94
95
96
...
260
261
262
 
 
263
264
 
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
0
@@ -90,7 +90,7 @@ module Prawn
0
       # <tt>:widths:</tt> A hash of indices and widths in PDF points.  E.g. <tt>{ 0 => 50, 1 => 100 }</tt>
0
       # <tt>:row_colors</tt>:: An array of row background colors which are used cyclicly.   
0
       # <tt>:align</tt>:: Alignment of text in columns, for entire table (<tt>:center</tt>) or by column (<tt>{ 0 => :left, 1 => :center}</tt>)
0
-      # <tt>:align_headers</tt>:: Alignment of header text.
0
+      # <tt>:align_headers</tt>:: Alignment of header text.  Specify for entire header (<tt>:left</tt>) or by column (<tt>{ 0 => :right, 1 => :left}</tt>). If omitted, the header alignment is the same as the column alignment.
0
       #
0
       # Row colors are specified as html encoded values, e.g.
0
       # ["ffffff","aaaaaa","ccaaff"].  You can also specify 
0
@@ -260,13 +260,25 @@ module Prawn
0
           contents.each { |e| e.border_style = :all }
0
         else                            
0
           if C(:headers)
0
-            contents.first.border_style = :all 
0
-            contents.first.align        = C(:align_headers) || :left
0
+            contents.first.border_style = :all
0
           else
0
-            contents.first.border_style  = :no_bottom    
0
+            contents.first.border_style  = :no_bottom
0
           end
0
           contents.last.border_style  = :no_top
0
         end
0
+        if C(:headers)
0
+          contents.first.cells.each_with_index do |e,i|
0
+          if C(:align_headers)
0
+            case C(:align_headers)
0
+              when Hash
0
+                align = C(:align_headers)[i]
0
+              else
0
+                align = C(:align_headers)
0
+              end
0
+            end
0
+            e.align = align if align
0
+          end
0
+        end
0
         
0
         contents.first.background_color = C(:header_color) if C(:header_color)
0
 
...
190
191
192
193
 
194
195
196
...
190
191
192
 
193
194
195
196
0
@@ -190,7 +190,7 @@ module Prawn
0
         @height   = 0
0
       end
0
 
0
-      attr_reader :width, :height
0
+      attr_reader :width, :height, :cells
0
       attr_accessor :background_color
0
 
0
       def <<(cell)

Comments