public
Description: Fast, Nimble PDF Writer for Ruby
Homepage: http://prawn.majesticseacreature.com
Clone URL: git://github.com/sandal/prawn.git
Fix some bugs and make the example much more awesomer
sandal (author)
Thu Jul 24 16:32:07 -0700 2008
commit  9dbda1baefbe902488891a527761a9a4258e7193
tree    893d56267e0155ab17b0a63195004d68562abf13
parent  50ff78422473262ed2acafa82c8410d12f33265d
...
3
4
5
6
7
8
 
 
 
 
 
 
 
 
9
...
3
4
5
 
 
 
6
7
8
9
10
11
12
13
14
0
@@ -3,7 +3,12 @@
0
 $LOAD_PATH << File.join(File.dirname(__FILE__), '..', 'lib')
0
 require "prawn"
0
    
0
-Prawn::Document.generate("image.pdf") do 
0
-  filename = File.join("#{Prawn::BASEDIR}/data/images/stef.jpg")
0
-  image filename, :at => [200, 400]
0
+Prawn::Document.generate("image.pdf", :page_layout => :landscape) do 
0
+  pigs = "#{Prawn::BASEDIR}/data/images/pigs.jpg" 
0
+  image pigs, :at => [50,550]                                        
0
+  
0
+  stef = "#{Prawn::BASEDIR}/data/images/stef.jpg"
0
+  image stef, :at => [75, 75]
0
+  
0
+  text "Please enjoy the pigs", :size => 36, :at => [200,15]   
0
 end
...
45
46
47
48
 
49
50
51
52
 
 
53
54
55
...
59
60
61
62
 
63
64
65
...
76
77
78
79
80
81
82
83
84
85
 
 
86
87
88
...
45
46
47
 
48
49
50
51
 
52
53
54
55
56
...
60
61
62
 
63
64
65
66
...
77
78
79
 
 
 
 
80
 
 
81
82
83
84
85
0
@@ -45,11 +45,12 @@ module Prawn
0
       # add a reference to the image object to the current page
0
       # resource list and give it a label
0
       label = "I#{next_image_id}"
0
-      page_xobjects.merge!( label => image_obj )
0
+      page_xobjects.merge!( label => image_obj )   
0
 
0
       # add the image to the current page
0
       instruct = "\nq\n%.3f 0 0 %.3f %.3f %.3f cm\n/%s Do\nQ"
0
-      add_content instruct % [ image_info.width, image_info.height, x, y, label ]
0
+      add_content instruct % [ image_info.width, image_info.height, x, 
0
+                               y - image_info.height, label ]
0
     end
0
 
0
     private
0
@@ -59,7 +60,7 @@ module Prawn
0
                 :Subtype    => :Image,
0
                 :ColorSpace => :DeviceRGB,
0
                 :Filter     => :DCTDecode,
0
-                :BitsPerComponent => 8,
0
+                :BitsPerComponent => info.bits,
0
                 :Width   => info.width,
0
                 :Height  => info.height,
0
                 :Length  => size
0
@@ -76,13 +77,9 @@ module Prawn
0
       obj
0
     end
0
 
0
-    def image_counter
0
-      @image_counter ||= 0
0
-    end
0
-
0
     def next_image_id
0
-      counter = image_counter
0
-      counter += 1
0
+      @image_counter ||= 0
0
+      @image_counter += 1
0
     end
0
   end
0
 end

Comments