public
Description: Fast, Nimble PDF Writer for Ruby
Homepage: http://prawn.majesticseacreature.com
Clone URL: git://github.com/sandal/prawn.git
Added :vposition argument to image()
trym (author)
Wed Oct 29 11:44:20 -0700 2008
commit  cd63dfb9424292cc3dcd97dcce0fb55349ce4dc8
tree    ebfccc1e20eccddd88e94a47373fa3662beb19e6
parent  dc678c367065fc53e12baad242010bd1352c5422
...
52
53
54
55
 
56
57
58
...
87
88
89
 
90
91
92
...
120
121
122
123
 
 
 
 
 
 
 
 
 
124
125
126
...
52
53
54
 
55
56
57
58
...
87
88
89
90
91
92
93
...
121
122
123
 
124
125
126
127
128
129
130
131
132
133
134
135
0
@@ -52,7 +52,7 @@ module Prawn
0
     # (See also: Prawn::Images::PNG , Prawn::Images::JPG)
0
     # 
0
     def image(file, options={})     
0
-      Prawn.verify_options [:at,:position, :height, :width, :scale, :fit], options
0
+      Prawn.verify_options [:at, :position, :vposition, :height, :width, :scale, :fit], options
0
       
0
       if file.respond_to?(:read)
0
         image_content = file.read
0
@@ -87,6 +87,7 @@ module Prawn
0
 
0
       # find where the image will be placed and how big it will be  
0
       w,h = calc_image_dimensions(info, options)
0
+      
0
       if options[:at]       
0
         x,y = translate(options[:at]) 
0
       else                  
0
@@ -120,7 +121,15 @@ module Prawn
0
       when Numeric
0
         options[:position] + bounds.absolute_left
0
       end
0
-
0
+      options[:vposition] ||= :top
0
+      y = case options[:vposition]
0
+      when :top
0
+        bounds.absolute_top
0
+      when :center
0
+        bounds.absolute_top - (bounds.height - h) / 2.0
0
+      when :bottom
0
+        bounds.absolute_bottom + h
0
+      end
0
       return [x,y]
0
     end
0
 

Comments