<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array">
    <added>
      <filename>examples/multi_page_layout.rb</filename>
    </added>
  </added>
  <modified type="array">
    <modified>
      <diff>@@ -20,6 +20,7 @@ module Prawn
     include PageGeometry                             
     
     attr_accessor :page_size, :page_layout, :y, :margin_box
+    attr_reader   :margins
 
              
     # Creates and renders a PDF document. 
@@ -78,29 +79,38 @@ module Prawn
        @page_size   = options[:page_size]   || &quot;LETTER&quot;    
        @page_layout = options[:page_layout] || :portrait
              
-       ml = options[:left_margin]   || 36
-       mr = options[:right_margin]  || 36  
-       mt = options[:top_margin]    || 36
-       mb = options[:bottom_margin] || 36
+       @margins = { :left   =&gt; options[:left_margin]   || 36,
+                    :right  =&gt; options[:right_margin]  || 36,  
+                    :top    =&gt; options[:top_margin]    || 36,       
+                    :bottom =&gt; options[:bottom_margin] || 36  }
         
-       @margin_box = BoundingBox.new(
-         self,
-         [ ml, page_dimensions[-1] - mt ] ,
-         :width =&gt; page_dimensions[-2] - (ml + mr),
-         :height =&gt; page_dimensions[-1] - (mt + mb)
-       )  
+       generate_margin_box
        
        @bounding_box = @margin_box
        
        start_new_page 
-     end  
+     end     
+     
+     def generate_margin_box     
+       old_margin_box = @margin_box
+       @margin_box = BoundingBox.new(
+         self,
+         [ @margins[:left], page_dimensions[-1] - @margins[:top] ] ,
+         :width =&gt; page_dimensions[-2] - (@margins[:left] + @margins[:right]),
+         :height =&gt; page_dimensions[-1] - (@margins[:top] + @margins[:bottom])
+       )                                 
+             
+       # update bounding box if not flowing from the previous page
+       @bounding_box = @margin_box if old_margin_box == @bounding_box              
+     end
             
      # Creates and advances to a new page in the document.
      # Runs the &lt;tt&gt;:on_page_start&lt;/tt&gt; lambda if one was provided at
      # document creation time (See Document.new).  
      #                                
      def start_new_page
-       finish_page_content if @page_content
+       finish_page_content if @page_content  
+       generate_margin_box    
        @page_content = ref(:Length =&gt; 0)   
      
        @current_page = ref(:Type      =&gt; :Page, </diff>
      <filename>lib/prawn/document.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>10a88748e633e236f20928517cedee7c4c23b0d1</id>
    </parent>
  </parents>
  <author>
    <name>Gregory Brown</name>
    <email>gregory.t.brown@gmail.com</email>
  </author>
  <url>http://github.com/sandal/prawn/commit/cca72f343055c1e514159006aaf6a5c485e53692</url>
  <id>cca72f343055c1e514159006aaf6a5c485e53692</id>
  <committed-date>2008-07-02T14:32:25-07:00</committed-date>
  <authored-date>2008-07-02T14:32:25-07:00</authored-date>
  <message>Low level support for multiple page layouts / sizes.  Ineffecient, and needing tests, and probably needs a higher level interface</message>
  <tree>d393d5abda80bf5f1d8ab03647b88182bb5e801d</tree>
  <committer>
    <name>Gregory Brown</name>
    <email>gregory.t.brown@gmail.com</email>
  </committer>
</commit>
