<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -83,21 +83,15 @@ module Prawn
     # Of course, if you use canvas, you will be responsible for ensuring that
     # you remain within the printable area of your document.
     #
-    def bounding_box(*args, &amp;block)
-      parent_box = @bounding_box
-      
-      # Offset to relative positions
-      top_left = args[0]
-      top_left[0] += parent_box.absolute_left
-      top_left[1] += parent_box.absolute_bottom
+    def bounding_box(*args, &amp;block)    
+      init_bounding_box(block) do |parent_box|
+        # Offset to relative positions
+        top_left = args[0]
+        top_left[0] += parent_box.absolute_left
+        top_left[1] += parent_box.absolute_bottom
 
-      @bounding_box = BoundingBox.new(self, *args)
-      self.y = @bounding_box.absolute_top
-     
-      block.call
-      
-      self.y = @bounding_box.absolute_bottom
-      @bounding_box = parent_box
+        @bounding_box = BoundingBox.new(self, *args)   
+      end
     end
 
     # A shortcut to produce a bounding box which is mapped to the document's
@@ -107,21 +101,29 @@ module Prawn
     #     pdf.line pdf.bounds.bottom_left, pdf.bounds.top_right
     #   end
     #
-    def canvas(&amp;block)
-      parent_box = @bounding_box
-      @bounding_box = BoundingBox.new(self, [0,page_dimensions[3]], 
-        :width =&gt; page_dimensions[2], 
-        :height =&gt; page_dimensions[3] 
-      )
+    def canvas(&amp;block)     
+      init_bounding_box(block) do |_|
+        @bounding_box = BoundingBox.new(self, [0,page_dimensions[3]], 
+          :width =&gt; page_dimensions[2], 
+          :height =&gt; page_dimensions[3] 
+        ) 
+      end
+    end      
+    
+    private
+    
+    def init_bounding_box(user_block, &amp;init_block)
+      parent_box = @bounding_box       
 
-      self.y = @bounding_box.absolute_top
+      init_block.call(parent_box)     
 
-      block.call
+      self.y = @bounding_box.absolute_top       
+      user_block.call   
+      self.y = @bounding_box.absolute_bottom 
 
-      self.y = @bounding_box.absolute_bottom
-      @bounding_box = parent_box
+      @bounding_box = parent_box 
     end
-    
+       
     class BoundingBox
       
       def initialize(parent, point, options={}) #:nodoc:</diff>
      <filename>lib/prawn/document/bounding_box.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>0fcc3530603a8d3d05e112cff39883038a213ce5</id>
    </parent>
  </parents>
  <author>
    <name>Gregory Brown</name>
    <email>gregory.t.brown@gmail.com</email>
  </author>
  <url>http://github.com/sandal/prawn/commit/efe870d121952287184ef3cd8d7b2c023b38cffe</url>
  <id>efe870d121952287184ef3cd8d7b2c023b38cffe</id>
  <committed-date>2008-07-21T08:04:57-07:00</committed-date>
  <authored-date>2008-07-21T08:04:57-07:00</authored-date>
  <message>Refactoring of bounding box stuff</message>
  <tree>db96a0e0970dd3900a2c533befeaf3eb2b3aa2b1</tree>
  <committer>
    <name>Gregory Brown</name>
    <email>gregory.t.brown@gmail.com</email>
  </committer>
</commit>
