Index: src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfAttributes.java
===================================================================
--- src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfAttributes.java	(revision 123107)
+++ src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfAttributes.java	(revision 123188)
@@ -238,4 +238,12 @@
         int v = (value != null) ? value.intValue() : 0;
         set(name, v + addValue);
     }
+    
+    /**
+     * This method clears the attributes on the RtfAttributes object
+     */
+    public void clear()
+    {
+    	this.values.clear();
+    }
 }
Index: src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfSection.java
===================================================================
--- src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfSection.java	(revision 123107)
+++ src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfSection.java	(revision 123188)
@@ -28,6 +28,7 @@
 
 import java.io.Writer;
 import java.io.IOException;
+import java.util.Iterator;
 
 /**  Models a section in an RTF document
  *  @author Bertrand Delacretaz bdelacretaz@codeconsult.ch
@@ -68,6 +69,25 @@
         externalGraphic = new RtfExternalGraphic(this, writer);
         return externalGraphic;
     }
+    
+    /*
+     * (non-Javadoc)
+     * @see org.apache.fop.render.rtf.rtflib.rtfdoc.RtfContainer#clearChildren()
+     */
+    public void clearChildren()
+    {
+   	 super.clearChildren();
+   	 
+  
+   	 this.paragraph = null;
+   	 this.table = null;
+   	 this.list = null;
+   	 this.externalGraphic = null;
+   	 this.before = null;
+   	 this.after = null;
+   	 this.jforCmd = null;
+   	 
+    }
 
     /**
      * Start a new paragraph after closing current paragraph, list and table
Index: src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfFile.java
===================================================================
--- src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfFile.java	(revision 123107)
+++ src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfFile.java	(revision 123188)
@@ -99,6 +99,9 @@
      */
     public RtfListTable startListTable(RtfAttributes attr)
     throws IOException {
+    	
+   	 
+    	
         listNum++;
         if (listTable != null) {
             return listTable;
@@ -137,6 +140,7 @@
             startHeader();
         }
         header.close();
+        
         pageArea = new RtfPageArea(this, writer);
         addChild(pageArea);
         return pageArea;
@@ -168,15 +172,43 @@
         if (docArea != null) {
             throw new RtfStructureException("startDocumentArea called more than once");
         }
+       
+        
         // create an empty header if there was none
-        if (header == null) {
+        if (header == null) 
+        {
             startHeader();
         }
         header.close();
         docArea = new RtfDocumentArea(this, writer);
+        
         addChild(docArea);
         return docArea;
     }
+    
+    /**
+     * This method starts a second area on the RtfFile
+     * This is use for starting new page sequences.
+     * 
+     * @return	The document area that was started
+     * @throws IOException
+     */
+    public RtfDocumentArea startSecondArea() throws IOException
+    {
+	
+    	//	Flush the file:
+		this.getRtfFile().flush();
+		//	clear the children
+		this.clearChildren();
+		
+     	docArea = new RtfDocumentArea(this,writer);
+     	
+     	//	Clear the children
+     	this.clearChildren();
+     	
+    	addChild(docArea);
+    	return(docArea);
+     }
 
 
 
@@ -198,7 +230,7 @@
      * overridden to write RTF prefix code, what comes before our children
      * @throws IOException for I/O problems
      */
-    protected void writeRtfPrefix() throws IOException {
+    public void writeRtfPrefix() throws IOException {
         writeGroupMark(true);
         writeControlWord("rtf1");
     }
@@ -207,7 +239,7 @@
      * overridden to write RTF suffix code, what comes after our children
      * @throws IOException for I/O problems
      */
-    protected void writeRtfSuffix() throws IOException {
+    public void writeRtfSuffix() throws IOException {
         writeGroupMark(false);
     }
 
@@ -219,6 +251,10 @@
         writeRtf();
         writer.flush();
     }
+    
+    public synchronized void flushWriter() throws IOException {
+    	writer.flush();
+    }
 
     /**
      * minimal test and usage example
Index: src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfContainer.java
===================================================================
--- src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfContainer.java	(revision 123107)
+++ src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfContainer.java	(revision 123188)
@@ -123,7 +123,32 @@
 
       return false;
     }
+    
 
+    /*
+     * (non-Javadoc)
+     * @see org.apache.fop.render.rtf.rtflib.rtfdoc.RtfElement#clearChildren()
+     */
+    public void clearChildren()
+    {
+    	super.clearChildren();
+    	
+    	if (children == null)
+    		return;
+    	
+    	if (children.size() == 0)
+    		return;
+    	
+    	for (Iterator it = children.iterator(); it.hasNext(); ) {
+    		RtfElement e = (RtfElement)it.next();
+    		e.clearChildren();
+    		e = null;
+    	}
+     
+    	//	clear this list
+    	children.clear();
+    }
+
     /**
      * write RTF code of all our children
      * @throws IOException for I/O problems
@@ -134,6 +159,7 @@
             final RtfElement e = (RtfElement)it.next();
             e.writeRtf();
         }
+ 
     }
 
     /** return our options */
Index: src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfElement.java
===================================================================
--- src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfElement.java	(revision 123107)
+++ src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfElement.java	(revision 123188)
@@ -46,7 +46,11 @@
     private boolean closed;
     private final int id;
     private static int idCounter;
-
+    
+    private boolean allowMutipleWrites = false;
+    private boolean writeSuffix = true;
+    private boolean writePrefix = true;
+ 
     /** Create an RTF element as a child of given container */
     RtfElement(RtfContainer parent, Writer w) throws IOException {
         this(parent, w, null);
@@ -73,21 +77,73 @@
     public final void close() throws IOException {
         closed = true;
     }
+   
+    /**
+     * Does nothing . derived should override if they want to have this
+     * behaviour.
+     */
+    public void clearChildren()
+    {
+    	if (this.attrib != null)
+    	{
+    		this.attrib.clear();
+    	}
+    }
 
     /**
      * Write the RTF code of this element to our Writer
      * @throws IOException for I/O problems
      */
-    public final void writeRtf() throws IOException {
-        if (!written) {
-            written = true;
-            if (okToWriteRtf()) {
-                writeRtfPrefix();
-                writeRtfContent();
-                writeRtfSuffix();
-            }
-        }
+    public final void writeRtf() throws IOException
+	{
+
+		// If it wasn't written write it:
+		if (!written)
+		{
+			written = true;
+			if (okToWriteRtf())
+			{
+
+				if (this.writePrefix) writeRtfPrefix();
+
+				writeRtfContent();
+
+				if (this.writeSuffix) writeRtfSuffix();
+			}
+		}
+
+		else
+		{
+			if (this.allowMutipleWrites)
+			{
+			 
+				if (this.writePrefix) writeRtfPrefix();
+
+				writeRtfContent();
+
+				if (this.writeSuffix) writeRtfSuffix();
+			}
+		}
+	}
+    
+  
+    
+    public void	setWriteSuffix(boolean writeSuffixFlag)
+    {
+    	this.writeSuffix = writeSuffixFlag;
     }
+    
+    public void setWritePrefix(boolean writePrefixFlag)
+    {
+    	this.writePrefix = writePrefixFlag;
+    }
+    
+    public void setMultipleWriteFlag(boolean multipleWriteFlag)
+    {
+    	this.allowMutipleWrites = multipleWriteFlag;
+    }
+    
+   
 
     /**
      * Starts a new line in the RTF file being written. This is only to format
Index: src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfDocumentArea.java
===================================================================
--- src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfDocumentArea.java	(revision 123107)
+++ src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfDocumentArea.java	(revision 123188)
@@ -48,10 +48,26 @@
      * @return the new RtfSection
      */
     public RtfSection newSection() throws IOException {
-        if (currentSection != null) {
-            currentSection.close();
-        }
-        currentSection = new RtfSection(this, writer);
-        return currentSection;
+    	 return(newSection(true));
     }
+    
+    /**
+     * Closes the current RTf Section and creates a new one.
+     * Uses the writeSuffix Flag to indicate whether or not
+     * the section should close the section or not.
+     * @param writeSuffixFlag
+     * @return
+     */
+    public RtfSection newSection(boolean writeSuffixFlag) throws IOException
+    {
+    	if (currentSection != null) {
+    		currentSection.close();
+   
+    	}
+    	currentSection = new RtfSection(this,writer);
+    	currentSection.setWriteSuffix(writeSuffixFlag);
+   
+    	return(currentSection);
+    }
+    
 }
\ No newline at end of file
Index: src/java/org/apache/fop/render/rtf/RTFHandler.java
===================================================================
--- src/java/org/apache/fop/render/rtf/RTFHandler.java	(revision 123107)
+++ src/java/org/apache/fop/render/rtf/RTFHandler.java	(revision 123188)
@@ -23,6 +23,7 @@
 import java.awt.Dimension;
 import java.awt.Rectangle;
 import java.awt.geom.Point2D;
+import java.io.BufferedWriter;
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStream;
@@ -91,6 +92,7 @@
 import org.apache.fop.fo.properties.CommonBorderPaddingBackground;
 import org.apache.fop.fo.properties.EnumLength;
 import org.apache.fop.fonts.FontSetup;
+import org.apache.fop.layoutmgr.TopLevelLayoutManager;
 import org.apache.fop.layoutmgr.inline.ImageLayout;
 import org.apache.fop.layoutmgr.table.ColumnSetup;
 import org.apache.fop.render.DefaultFontResolver;
@@ -156,7 +158,13 @@
     private int nestedTableDepth = 1;
 
     private PercentContext percentManager = new PercentContext();
+    
+    private int pageSequenceCount = 0;
+    
+    PageSequence	prevPageSequence = null;
+    
 
+
     /**
      * Creates a new RTF structure handler.
      * @param userAgent the FOUserAgent for this process
@@ -174,8 +182,17 @@
     public void startDocument() throws SAXException {
         // TODO sections should be created
         try {
-            rtfFile = new RtfFile(new OutputStreamWriter(os));
+        	//	Construct the file and write the suffix:
+            rtfFile = new RtfFile(new BufferedWriter(new OutputStreamWriter(os)));
+            //	set the write suffix flag on the file
+            rtfFile.setWriteSuffix(false);
+            rtfFile.setMultipleWriteFlag(true);
+            
             docArea = rtfFile.startDocumentArea();
+            
+            //	set the multiple write flag on the document area:
+            docArea.setMultipleWriteFlag(true);
+            
         } catch (IOException ioe) {
             // TODO could we throw Exception in all FOEventHandler events?
             throw new SAXException(ioe);
@@ -185,7 +202,19 @@
     /** {@inheritDoc} */
     public void endDocument() throws SAXException {
         try {
-            rtfFile.flush();
+        	//	 How many page sequences to we have
+      	//	 We handle multiple page sequences differently
+      	//	 than if we have one page sequence:
+      	if (this.pageSequenceCount > 1)
+      	{
+      		//	don't want to write the prefix if we have
+      		//	more than one page sequence
+      		rtfFile.setWritePrefix(false);
+      	}
+        	
+        	docArea.setWriteSuffix(true);
+        	rtfFile.setWriteSuffix(true);
+        	rtfFile.flush();
         } catch (IOException ioe) {
             // TODO could we throw Exception in all FOEventHandler events?
             throw new SAXException(ioe);
@@ -193,80 +222,143 @@
     }
 
     /** {@inheritDoc} */
-    public void startPageSequence(PageSequence pageSeq)  {
-        try {
-            //This is needed for region handling
-            if (this.pagemaster == null) {
-                String reference = pageSeq.getMasterReference();
-                this.pagemaster
-                        = pageSeq.getRoot().getLayoutMasterSet().getSimplePageMaster(reference);
-                if (this.pagemaster == null) {
-                    log.warn("Only simple-page-masters are supported on page-sequences: "
-                            + reference);
-                    log.warn("Using default simple-page-master from page-sequence-master...");
-                    PageSequenceMaster master
-                        = pageSeq.getRoot().getLayoutMasterSet().getPageSequenceMaster(reference);
-                    this.pagemaster = master.getNextSimplePageMaster(
-                            false, false, false, false, false);
-                }
-            }
+	public void startPageSequence(PageSequence pageSeq)
+	{
+		try
+		{
+			// This is needed for region handling
+			if (this.pagemaster == null)
+			{
+				String reference = pageSeq.getMasterReference();
+				this.pagemaster = pageSeq.getRoot().getLayoutMasterSet().getSimplePageMaster(reference);
+				if (this.pagemaster == null)
+				{
+					log.warn("Only simple-page-masters are supported on page-sequences: " + reference);
+					log.warn("Using default simple-page-master from page-sequence-master...");
+					PageSequenceMaster master = pageSeq.getRoot().getLayoutMasterSet().getPageSequenceMaster(reference);
+					this.pagemaster = master.getNextSimplePageMaster(false, false, false, false, false);
+				}
+			}
 
-            if (bDefer) {
-                return;
-            }
+			if (bDefer)
+			{
+				return;
+			}
+	 
 
-            sect = docArea.newSection();
+			// Start a second area:
+			if (pageSequenceCount > 0)
+			{
+				//	Start a second area and instruct the second area
+				//	that it is not to write a prefix or a suffix
+				docArea = rtfFile.startSecondArea();
+				docArea.setWritePrefix(false);
+				docArea.setWriteSuffix(false);
+				
+				//	Clear the percent Manager and the builder Context
+				percentManager = new PercentContext();
+				builderContext = new BuilderContext(null);
+			
+			}
+			if (this.prevPageSequence != null)
+			{
+				this.prevPageSequence.releasePageSequence();
+				this.prevPageSequence = null;
+			}
+			
 
-            //read page size and margins, if specified
-            //only simple-page-master supported, so pagemaster may be null
-            if (pagemaster != null) {
-                sect.getRtfAttributes().set(
-                    PageAttributesConverter.convertPageAttributes(
-                            pagemaster));
-            } else {
-                log.warn("No simple-page-master could be determined!");
-            }
+			//	Depending on the properties set on the page
+			//	sequence will depend on whether or not we want
+			//	this section to have a suffix or not.
+			if (pageSeq.getBreakAfter() == Constants.EN_AUTO)
+			{
+				sect = docArea.newSection(false);
+			}
+			else if (pageSeq.getBreakAfter() == Constants.EN_PAGE)
+			{
+				sect = docArea.newSection(true);
+			}
+			else
+			{
+				log.error("Invalid break-after specified on page-sequence.");
+				return;
+			}
+			
+			//	Set the multiple write flag to true on the section.
+			sect.setMultipleWriteFlag(true);
 
-            builderContext.pushContainer(sect);
+			// If are on the second page sequence
+			// we need to set properties on our
+			// rtf File to not write the prefix anymore
+			if (pageSequenceCount == 1)
+			{
+				rtfFile.setWritePrefix(false);
+			}
 
-            //Calculate usable page width for this flow
-            int useAblePageWidth = pagemaster.getPageWidth().getValue()
-                - pagemaster.getCommonMarginBlock().marginLeft.getValue()
-                - pagemaster.getCommonMarginBlock().marginRight.getValue()
-                - sect.getRtfAttributes().getValueAsInteger(RtfPage.MARGIN_LEFT).intValue()
-                - sect.getRtfAttributes().getValueAsInteger(RtfPage.MARGIN_RIGHT).intValue();
-            percentManager.setDimension(pageSeq, useAblePageWidth);
+			//	Increment the page sequence toun:
+			pageSequenceCount += 1;
 
-            bHeaderSpecified = false;
-            bFooterSpecified = false;
-        } catch (IOException ioe) {
-            // TODO could we throw Exception in all FOEventHandler events?
-            log.error("startPageSequence: " + ioe.getMessage(), ioe);
-            //TODO throw new FOPException(ioe);
-        } catch (FOPException fope) {
-            // TODO could we throw Exception in all FOEventHandler events?
-            log.error("startPageSequence: " + fope.getMessage(), fope);
-        }
-    }
+			// read page size and margins, if specified
+			// only simple-page-master supported, so pagemaster may be null
+			if (pagemaster != null)
+			{
+				sect.getRtfAttributes().set(PageAttributesConverter.convertPageAttributes(pagemaster));
+			}
+			else
+			{
+				log.warn("No simple-page-master could be determined!");
+			}
 
+			builderContext.pushContainer(sect);
+
+			// Calculate usable page width for this flow
+			int useAblePageWidth = pagemaster.getPageWidth().getValue()
+				- pagemaster.getCommonMarginBlock().marginLeft.getValue()
+				- pagemaster.getCommonMarginBlock().marginRight.getValue()
+				- sect.getRtfAttributes().getValueAsInteger(RtfPage.MARGIN_LEFT).intValue()
+				- sect.getRtfAttributes().getValueAsInteger(RtfPage.MARGIN_RIGHT).intValue();
+			percentManager.setDimension(pageSeq, useAblePageWidth);
+
+			bHeaderSpecified = false;
+			bFooterSpecified = false;
+		}
+		catch (IOException ioe)
+		{
+			// TODO could we throw Exception in all FOEventHandler events?
+			log.error("startPageSequence: " + ioe.getMessage(), ioe);
+			// TODO throw new FOPException(ioe);
+		}
+		catch (FOPException fope)
+		{
+			// TODO could we throw Exception in all FOEventHandler events?
+			log.error("startPageSequence: " + fope.getMessage(), fope);
+		}
+	}
+
     /** {@inheritDoc} */
-    public void endPageSequence(PageSequence pageSeq) {
-        if (bDefer) {
-            //If endBlock was called while SAX parsing, and the passed FO is Block
-            //nested within another Block, stop deferring.
-            //Now process all deferred FOs.
-            bDefer = false;
-            recurseFONode(pageSeq);
-            this.pagemaster = null;
-            bDefer = true;
+	public void endPageSequence(PageSequence pageSeq)
+	{
 
-            return;
-        } else {
-            builderContext.popContainer();
-            this.pagemaster = null;
-        }
-    }
+		if (bDefer)
+		{
+			// If endBlock was called while SAX parsing, and the passed FO is Block
+			// nested within another Block, stop deferring.
+			// Now process all deferred FOs.
+			bDefer = false;
+			recurseFONode(pageSeq);
+			this.pagemaster = null;
+			bDefer = true;
 
+			return;
+		}
+		else
+		{
+			builderContext.popContainer();
+			this.pagemaster = null;
+		}
+
+	}
+
     /** {@inheritDoc} */
     public void startFlow(Flow fl) {
         if (bDefer) {
@@ -301,7 +393,7 @@
                     final IRtfAfterContainer contAfter
                         = (IRtfAfterContainer)builderContext.getContainer
                                 (IRtfAfterContainer.class, true, this);
-                    contAfter.newAfter(attr);
+                   contAfter.newAfter(attr);
                 }
                 handled = true;
             } else if (regionBefore != null
@@ -354,6 +446,7 @@
             log.error("startFlow: " + e.getMessage());
             throw new RuntimeException(e.getMessage());
         }
+       
     }
 
     /** {@inheritDoc} */
@@ -379,6 +472,8 @@
             log.error("endFlow: " + e.getMessage());
             throw new RuntimeException(e.getMessage());
         }
+        
+       
     }
 
     /** {@inheritDoc} */
@@ -425,7 +520,7 @@
                     true, this);
 
             RtfTextrun textrun = container.getTextrun();
-
+      
             textrun.addParagraphBreak();
             textrun.popBlockAttributes();
 
@@ -842,7 +937,8 @@
     // Lists
     /** {@inheritDoc} */
     public void startList(ListBlock lb) {
-        if (bDefer) {
+        
+    	if (bDefer) {
             return;
         }
 
@@ -1340,7 +1436,9 @@
 
     /** {@inheritDoc} */
     public void startPageNumber(PageNumber pagenum) {
-        if (bDefer) {
+        
+ 
+    	if (bDefer) {
             return;
         }
 
@@ -1362,6 +1460,8 @@
             log.error("startPageNumber: " + e.getMessage());
             throw new RuntimeException(e.getMessage());
         }
+        
+ 
     }
 
     /** {@inheritDoc} */
@@ -1607,6 +1707,10 @@
 
 
             recurseFONode( pageSequence.getMainFlow() );
+            
+            //	Set the previous page sequence
+            this.prevPageSequence = pageSequence;
+            
         } else if (foNode instanceof Table) {
             Table table = (Table) foNode;
 
@@ -1662,6 +1766,6 @@
             }
         }
 
-        invokeDeferredEvent(foNode, false);
+       invokeDeferredEvent(foNode, false);
     }
 }
Index: src/java/org/apache/fop/layoutmgr/ExternalDocumentLayoutManager.java
===================================================================
--- src/java/org/apache/fop/layoutmgr/ExternalDocumentLayoutManager.java	(revision 123107)
+++ src/java/org/apache/fop/layoutmgr/ExternalDocumentLayoutManager.java	(revision 123188)
@@ -246,5 +246,33 @@
         
         return page;
     }
+    
+    /**
+     * REVISION_ISSUE:
+     * 
+     * THIS IS UNIMPLEMENTED AND SHOULD BE FIGURED OUT.   HAD TO IMPLEMENT BECAUSE
+     * IT HAS TO CONFORM TO THE TOP LEVEL PAGE MANAGER.  
+     * 
+     */
+        
+    public Page getUnfinishedPage()
+    {
+    	return null;
+    }
+    
+    public void setUnfinishedPage(Page unfinishedPage)
+    {
+    	 
+    }
+    
+    public PageProvider getUnfinishedPageProvider()
+    {
+    	return null;
+    }
+    
+    public void setUnfinishedPageProvider(PageProvider unfinishedPageProvider)
+    {
+    	 
+    }
 
 }
Index: src/java/org/apache/fop/layoutmgr/Page.java
===================================================================
--- src/java/org/apache/fop/layoutmgr/Page.java	(revision 123107)
+++ src/java/org/apache/fop/layoutmgr/Page.java	(revision 123188)
@@ -35,6 +35,13 @@
     private SimplePageMaster spm;
     private PageViewport pageViewport;
     
+    //	Available real-estate on the page
+    private int	availableBPD = 0;
+    //	Left over real-estate on teh page
+    private int leftOverBPD = 0;
+    //	Flag identifying whether (this) page is a carry over page
+    private boolean isCarryOverPage = false;
+    
     /**
      * Main constructor
      * @param spm the simple-page-master used for this page
@@ -69,4 +76,63 @@
         return this.pageViewport;
     }
     
+    /**
+     * This method sets the available real-estate on the page.
+     * 
+     * @param availableBPD  available real-estate
+     */
+    public void	setAvailableBPD(int availableBPD)
+    {
+    	this.availableBPD = availableBPD;
+    }
+    
+    /**
+     * This method returns the available real-estate on the page.
+     * 
+     * @return	The available real-estate
+     */
+    public int		getAvailableBPD()
+    {
+    	return(this.availableBPD);
+    }
+    
+    /**
+     * This method sets the left over real-estate on the page.
+     * 
+     * @param leftOverBPD	The left-over real-estate
+     */
+    public void setLeftOverBPD(int leftOverBPD)
+    {
+    	this.leftOverBPD = leftOverBPD;
+    }
+    
+    /**
+     * This method returns the left-over real-estate on the page.
+     * 
+     * @return	The left-over real-estate
+     */
+    public int getLeftOverBPD()
+    {
+    	return(this.leftOverBPD);
+    }
+    
+    /**
+     * This method sets the page as a carry over page.
+     */
+    public void setAsCarryOverPage()
+    {
+    	this.isCarryOverPage = true;
+    }
+    
+    /**
+     * This method returns the flag indicating whether this 
+     * page has been designated as a carry-over page or not.
+     * 
+     * @return	The carry over flag
+     */
+    public boolean isCarryOverPage()
+    {
+    	return(this.isCarryOverPage);
+    }
+    
 }
Index: src/java/org/apache/fop/layoutmgr/PageBreakingAlgorithm.java
===================================================================
--- src/java/org/apache/fop/layoutmgr/PageBreakingAlgorithm.java	(revision 123107)
+++ src/java/org/apache/fop/layoutmgr/PageBreakingAlgorithm.java	(revision 123188)
@@ -30,6 +30,7 @@
 import org.apache.fop.fo.FONode;
 import org.apache.fop.fo.FObj;
 import org.apache.fop.layoutmgr.AbstractBreaker.PageBreakPosition;
+import org.apache.fop.layoutmgr.BreakingAlgorithm.KnuthNode;
 import org.apache.fop.traits.MinOptMax;
 
 class PageBreakingAlgorithm extends BreakingAlgorithm {
@@ -307,6 +308,8 @@
 
     protected void considerLegalBreak(KnuthElement element, int elementIdx) {
         super.considerLegalBreak(element, elementIdx);
+        
+  
         newFootnotes = false;
     }
 
@@ -364,13 +367,37 @@
         } else {
             // there are no footnotes
         }
-        int diff = getLineWidth(activeNode.line) - actualWidth;
+        
+        
+        Page page = null;
+        int diff = 0;
+        
+        //	Get the page (if we have a page-provider) because
+        //	we need to keep track of left-over real-estate if
+        //	this page is to become a carry over page.
+        if (this.pageProvider != null) {
+			page = this.pageProvider.getPage(false, activeNode.line,
+					PageProvider.RELTO_CURRENT_ELEMENT_LIST);
+	    }
+     
+        int lineWidth = getLineWidth(activeNode.line);
+        
+        diff = lineWidth - actualWidth;
+        
+        
+        //	If we got a page ... set the left over real-estate
+        if (page != null)
+        {
+        		page.setLeftOverBPD(diff);
+        }
+         
+
         if (autoHeight && diff < 0) {
-            //getLineWidth() for auto-height parts return 0 so the diff will be negative
-            return 0; //...but we don't want to shrink in this case. Stick to optimum.
+           return 0; //...but we don't want to shrink in this case. Stick to optimum.
         } else {
+        
             return diff;
-        }
+        } 
     }
 
     /** Checks whether footnotes from preceding pages may be deferred to the page after
@@ -870,12 +897,35 @@
     
     /** {@inheritDoc} */
     protected int getLineWidth(int line) {
-        int bpd;
-        if (pageProvider != null) {
-            bpd = pageProvider.getAvailableBPD(line);
-        } else {
-            bpd = super.getLineWidth(line);
-        }
+    	
+    	int bpd;
+    	
+    	//	If we have a page provider ... look for the page
+    	//	... IF the page is a carry over page ... used the
+    	//	available real-estate on that page and ignore
+    	// the page breaker information.
+    	if (this.pageProvider != null) 
+    	{
+			Page page = this.pageProvider.getPage(false, line,
+					PageProvider.RELTO_CURRENT_ELEMENT_LIST);
+			if (page != null)
+			{
+				if (page.isCarryOverPage())
+				{
+					bpd = page.getAvailableBPD();
+					return(bpd);
+				}
+			}
+    	}
+    
+    	
+	    if (pageProvider != null) {
+			bpd = pageProvider.getAvailableBPD(line);
+		} else {
+			bpd = super.getLineWidth(line);
+		}
+    	
+    	
         if (log.isTraceEnabled()) {
             log.trace("getLineWidth(" + line + ") -> " + bpd);
         }
Index: src/java/org/apache/fop/layoutmgr/PageProvider.java
===================================================================
--- src/java/org/apache/fop/layoutmgr/PageProvider.java	(revision 123107)
+++ src/java/org/apache/fop/layoutmgr/PageProvider.java	(revision 123188)
@@ -59,6 +59,8 @@
     //Cache to optimize getAvailableBPD() calls
     private int lastRequestedIndex = -1;
     private int lastReportedBPD = -1;
+    
+   
 
     /** 
      * AreaTreeHandler which activates the PSLM and controls
@@ -80,6 +82,7 @@
         this.areaTreeHandler = ath;
         this.pageSeq = ps;
         this.startPageOfPageSequence = ps.getStartingPageNumber();
+     
     }
     
     /**
@@ -115,6 +118,7 @@
      * @return the available BPD
      */
     public int getAvailableBPD(int index) {
+      	
         //Special optimization: There may be many equal calls by the BreakingAlgorithm
         if (this.lastRequestedIndex == index) {
             if (log.isTraceEnabled()) {
@@ -125,6 +129,8 @@
         int c = index;
         int pageIndex = 0;
         int colIndex = startColumnOfCurrentElementList;
+        
+       
         Page page = getPage(
                 false, pageIndex, RELTO_CURRENT_ELEMENT_LIST);
         while (c > 0) {
@@ -156,6 +162,8 @@
         int idx = 0;
         int pageIndex = 0;
         int colIndex = startColumnOfCurrentElementList;
+        
+    
         Page page = getPage(
                 false, pageIndex, RELTO_CURRENT_ELEMENT_LIST);
         while (idx < partCount) {
@@ -181,6 +189,8 @@
      * @return the requested Page
      */
     public Page getPage(boolean isBlank, int index, int relativeTo) {
+    	
+    
         if (relativeTo == RELTO_PAGE_SEQUENCE) {
             return getPage(isBlank, index);
         } else if (relativeTo == RELTO_CURRENT_ELEMENT_LIST) {
@@ -193,6 +203,27 @@
         }
     }
     
+    
+    public Page getLastPage()
+    {
+    	if (cachedPages.size() == 0)
+    		return(null);
+    	
+    	int idx = cachedPages.size() -1;
+    	
+     
+    	return(this.getPage(false, idx));
+    }
+    
+    public void setStartingPage(Page startingPage)
+    {
+    	if (cachedPages.size() == 0)
+    		this.cachedPages.add(startingPage);
+    	else
+    		this.cachedPages.set(0, startingPage);
+    	this.indexOfCachedLastPage = 0;
+    }
+    
     /**
      * 
      * @param isBlank   true if the Page should be a blank one
@@ -200,43 +231,65 @@
      * @return  a Page instance
      */
     protected Page getPage(boolean isBlank, int index) {
+    	
+    	
+    	
         boolean isLastPage = (lastPageIndex >= 0) && (index == lastPageIndex);
-        if (log.isTraceEnabled()) {
-            log.trace("getPage(" + index + " " + (isBlank ? "blank" : "non-blank") 
-                    + (isLastPage ? " <LAST>" : "") + ")");
-        }
-        int intIndex = index - startPageOfPageSequence;
-        if (log.isTraceEnabled()) {
-            if (isBlank) {
-                log.trace("blank page requested: " + index);
-            }
-            if (isLastPage) {
-                log.trace("last page requested: " + index);
-            }
-        }
-        while (intIndex >= cachedPages.size()) {
-            if (log.isTraceEnabled()) {
-                log.trace("Caching " + index);
-            }
-            cacheNextPage(index, isBlank, isLastPage);
-        }
-        Page page = (Page)cachedPages.get(intIndex);
-        boolean replace = false;
-        if (page.getPageViewport().isBlank() != isBlank) {
-            log.debug("blank condition doesn't match. Replacing PageViewport.");
-            replace = true;
-        }
-        if ((isLastPage && indexOfCachedLastPage != intIndex)
-                || (!isLastPage && indexOfCachedLastPage >= 0)) {
-            log.debug("last page condition doesn't match. Replacing PageViewport.");
-            replace = true;
-            indexOfCachedLastPage = (isLastPage ? intIndex : -1);
-        }
-        if (replace) {
-            disardCacheStartingWith(intIndex);
-            page = cacheNextPage(index, isBlank, isLastPage);
-        }
-        return page;
+		if (log.isTraceEnabled()) {
+			log.trace("getPage(" + index + " "
+					+ (isBlank ? "blank" : "non-blank")
+					+ (isLastPage ? " <LAST>" : "") + ")");
+		}
+		int intIndex = index - startPageOfPageSequence;
+		if (log.isTraceEnabled()) {
+			if (isBlank) {
+				log.trace("blank page requested: " + index);
+			}
+			if (isLastPage) {
+				log.trace("last page requested: " + index);
+			}
+		}
+		while (intIndex >= cachedPages.size()) {
+			if (log.isTraceEnabled()) {
+				log.trace("Caching " + index);
+			}
+			cacheNextPage(index, isBlank, isLastPage);
+		}
+	 
+		Page page = (Page) cachedPages.get(intIndex);
+		
+		//	If we are looking for the first page ... and there
+		//	is all-ready a cached page ... lets return that instead
+		//	THIS should cure the carry over.
+		if ( (index == startPageOfPageSequence) && (indexOfCachedLastPage == 0))
+		{
+			if (page != null)
+			{
+		 
+				return(page);
+			}
+		}
+		
+	
+		boolean replace = false;
+		
+		if (page.getPageViewport().isBlank() != isBlank) 
+		{
+			log.debug("blank condition doesn't match. Replacing PageViewport.");
+			replace = true;
+		}
+		if ((isLastPage && indexOfCachedLastPage != intIndex)
+				|| (!isLastPage && indexOfCachedLastPage >= 0)) {
+			log
+					.debug("last page condition doesn't match. Replacing PageViewport.");
+			replace = true;
+			indexOfCachedLastPage = (isLastPage ? intIndex : -1);
+		}
+		if (replace) {
+			disardCacheStartingWith(intIndex);
+			page = cacheNextPage(index, isBlank, isLastPage);
+		}
+		return page;
     }
 
     private void disardCacheStartingWith(int index) {
@@ -267,6 +320,8 @@
             //Set unique key obtained from the AreaTreeHandler
             page.getPageViewport().setKey(areaTreeHandler.generatePageViewportKey());
             page.getPageViewport().setForeignAttributes(spm.getForeignAttributes());
+            
+       
             cachedPages.add(page);
             return page;
         } catch (FOPException e) {
@@ -275,5 +330,6 @@
             throw new IllegalStateException(e.getMessage());
         }
     }
+   
     
 }
\ No newline at end of file
Index: src/java/org/apache/fop/layoutmgr/PageSequenceLayoutManager.java
===================================================================
--- src/java/org/apache/fop/layoutmgr/PageSequenceLayoutManager.java	(revision 123107)
+++ src/java/org/apache/fop/layoutmgr/PageSequenceLayoutManager.java	(revision 123188)
@@ -25,146 +25,248 @@
 import org.apache.fop.area.AreaTreeHandler;
 import org.apache.fop.area.AreaTreeModel;
 import org.apache.fop.area.LineArea;
+import org.apache.fop.fo.Constants;
 import org.apache.fop.fo.pagination.PageSequence;
 import org.apache.fop.fo.pagination.PageSequenceMaster;
 import org.apache.fop.fo.pagination.SideRegion;
 import org.apache.fop.fo.pagination.StaticContent;
+import org.apache.fop.layoutmgr.Page;
 import org.apache.fop.layoutmgr.inline.ContentLayoutManager;
 
 /**
- * LayoutManager for a PageSequence.  This class is instantiated by
- * area.AreaTreeHandler for each fo:page-sequence found in the
- * input document.
+ * LayoutManager for a PageSequence. This class is instantiated by
+ * area.AreaTreeHandler for each fo:page-sequence found in the input document.
  */
-public class PageSequenceLayoutManager extends AbstractPageSequenceLayoutManager {
+public class PageSequenceLayoutManager extends
+		AbstractPageSequenceLayoutManager {
 
-    private static Log log = LogFactory.getLog(PageSequenceLayoutManager.class);
+	private static Log log = LogFactory.getLog(PageSequenceLayoutManager.class);
 
-    private PageProvider pageProvider;
+	private PageProvider pageProvider;
 
-    /**
-     * Constructor
-     *
-     * @param ath the area tree handler object
-     * @param pseq fo:page-sequence to process
-     */
-    public PageSequenceLayoutManager(AreaTreeHandler ath, PageSequence pseq) {
-        super(ath, pseq);
-        this.pageProvider = new PageProvider(ath, pseq);
-    }
+	private Page unfinishedPage = null;
 
-    /** @return the PageProvider applicable to this page-sequence. */
-    public PageProvider getPageProvider() {
-        return this.pageProvider;
-    }
-    
-    /**
-     * @return the PageSequence being managed by this layout manager 
-     */
-    protected PageSequence getPageSequence() {
-        return (PageSequence)pageSeq;
-    }
+	private PageProvider unfinishedPageProvider = null;
 
-    /**
-     * Provides access to this object
-     * @return this PageSequenceLayoutManager instance
-     */
-    public PageSequenceLayoutManager getPSLM() {
-        return this;
-    }
-    
-    /** {@inheritDoc} */
-    public void activateLayout() {
-        initialize();
+	/**
+	 * Constructor
+	 * 
+	 * @param ath
+	 *            the area tree handler object
+	 * @param pseq
+	 *            fo:page-sequence to process
+	 */
+	public PageSequenceLayoutManager(AreaTreeHandler ath, PageSequence pseq) {
+		super(ath, pseq);
+		this.pageProvider = new PageProvider(ath, pseq);
 
-        LineArea title = null;
+	}
 
-        if (getPageSequence().getTitleFO() != null) {
-            try {
-                ContentLayoutManager clm = getLayoutManagerMaker().
-                    makeContentLayoutManager(this, getPageSequence().getTitleFO());
-                title = (LineArea) clm.getParentArea(null);
-            } catch (IllegalStateException e) {
-                // empty title; do nothing
-            }
-        }
+	/** @return the PageProvider applicable to this page-sequence. */
+	public PageProvider getPageProvider() {
+		return this.pageProvider;
+	}
 
-        AreaTreeModel areaTreeModel = areaTreeHandler.getAreaTreeModel();
-        org.apache.fop.area.PageSequence pageSequenceAreaObject
-                = new org.apache.fop.area.PageSequence(title);
-        pageSequenceAreaObject.setLanguage(getPageSequence().getLanguage());
-        pageSequenceAreaObject.setCountry(getPageSequence().getCountry());
-        areaTreeModel.startPageSequence(pageSequenceAreaObject);
-        if (log.isDebugEnabled()) {
-            log.debug("Starting layout");
-        }
+	/**
+	 * @return the PageSequence being managed by this layout manager
+	 */
+	protected PageSequence getPageSequence() {
+		return (PageSequence) pageSeq;
+	}
 
-        curPage = makeNewPage(false, false);
-        
-        PageBreaker breaker = new PageBreaker(this);
-        int flowBPD = (int)getCurrentPV().getBodyRegion().getRemainingBPD();
-        breaker.doLayout(flowBPD);
+	/**
+	 * Provides access to this object
+	 * 
+	 * @return this PageSequenceLayoutManager instance
+	 */
+	public PageSequenceLayoutManager getPSLM() {
+		return this;
+	}
 
-        finishPage();
-    }
-        
-    /** {@inheritDoc} */
-    public void finishPageSequence() {
-        if (pageSeq.hasId()) {
-            idTracker.signalIDProcessed(pageSeq.getId());
-        }
+	/** {@inheritDoc} */
+	public void activateLayout() {
+		initialize();
 
-        pageSeq.getRoot().notifyPageSequenceFinished(currentPageNum,
-                (currentPageNum - startPageNum) + 1);
-        areaTreeHandler.notifyPageSequenceFinished(pageSeq,
-                (currentPageNum - startPageNum) + 1);
-        getPageSequence().releasePageSequence();
-        
-        // If this sequence has a page sequence master so we must reset
-        // it in preparation for the next sequence
-        String masterReference = getPageSequence().getMasterReference();
-        PageSequenceMaster pageSeqMaster
-            = pageSeq.getRoot().getLayoutMasterSet().getPageSequenceMaster(masterReference);
-        if (pageSeqMaster != null) {
-            pageSeqMaster.reset();
-        }
+		LineArea title = null;
 
-        if (log.isDebugEnabled()) {
-            log.debug("Ending layout");
-        }
-    }
-    
-    /** {@inheritDoc} */
-    protected Page createPage(int pageNumber, boolean isBlank) {
-        return pageProvider.getPage(isBlank,
-                pageNumber, PageProvider.RELTO_PAGE_SEQUENCE);
-    }
-    
-    private void layoutSideRegion(int regionID) {
-        SideRegion reg = (SideRegion)curPage.getSimplePageMaster().getRegion(regionID);
-        if (reg == null) {
-            return;
-        }
-        StaticContent sc = getPageSequence().getStaticContent(reg.getRegionName());
-        if (sc == null) {
-            return;
-        }
+		if (getPageSequence().getTitleFO() != null) {
+			try {
+				ContentLayoutManager clm = getLayoutManagerMaker()
+						.makeContentLayoutManager(this,
+								getPageSequence().getTitleFO());
+				title = (LineArea) clm.getParentArea(null);
+			} catch (IllegalStateException e) {
+				// empty title; do nothing
+			}
+		}
 
-        StaticContentLayoutManager lm = (StaticContentLayoutManager)
-            getLayoutManagerMaker().makeStaticContentLayoutManager(
-                    this, sc, reg);
-        lm.doLayout();
-    }
+		AreaTreeModel areaTreeModel = areaTreeHandler.getAreaTreeModel();
+		org.apache.fop.area.PageSequence pageSequenceAreaObject = new org.apache.fop.area.PageSequence(
+				title);
+		pageSequenceAreaObject.setLanguage(getPageSequence().getLanguage());
+		pageSequenceAreaObject.setCountry(getPageSequence().getCountry());
+		areaTreeModel.startPageSequence(pageSequenceAreaObject);
+		if (log.isDebugEnabled()) {
+			log.debug("Starting layout");
+		}
 
-    /** {@inheritDoc} */
-    protected void finishPage() {
-        // Layout side regions
-        layoutSideRegion(FO_REGION_BEFORE); 
-        layoutSideRegion(FO_REGION_AFTER);
-        layoutSideRegion(FO_REGION_START);
-        layoutSideRegion(FO_REGION_END);
-        
-        super.finishPage();
-    }
-        
+		 
+	 
+		// If we are on the first page sequence ... make a page
+		if (areaTreeModel.getPageSequenceCount() == 1) {
+ 
+	
+			curPage = makeNewPage(false, false);
+
+			pageBreaker = new PageBreaker(this);
+		} else 
+		{
+			this.currentPageNum += 1;
+
+			if (curPage == null) 
+			{
+				// Have to designate the page sequence here:
+				if (unfinishedPage != null) 
+				{
+					// Set the current page to the unfinished page:
+					curPage = this.unfinishedPage;
+					this.unfinishedPage = null;
+
+					// Set the appropriate info on the current page.
+					curPage.getPageViewport().setPageIndex(0);
+					curPage.getPageViewport().setPageSequence(
+							pageSequenceAreaObject);
+
+					pageBreaker = new PageBreaker(this);
+
+					
+					Page pPage = this.unfinishedPageProvider.getPage(false,
+							this.currentPageNum);
+
+					if (pPage != null) {
+						 
+						// Identify that it is a carry over page.
+						pPage.setAsCarryOverPage();
+						// Set the starting page on the page provider						
+						this.pageProvider.setStartingPage(pPage);
+					 
+					}
+					
+				}
+				else
+				{
+					curPage = makeNewPage(false, false);
+
+					pageBreaker = new PageBreaker(this);
+				}
+
+			}
+
+		}
+		addIDToPage(pageSeq.getId());
+		int flowBPD = (int) getCurrentPV().getBodyRegion().getRemainingBPD();
+
+		pageBreaker.doLayout(flowBPD);
+
+		// finishPage();
+
+	}
+
+	/** {@inheritDoc} */
+	public void finishPageSequence() {
+
+		if (pageSeq.hasId()) {
+			idTracker.signalIDProcessed(pageSeq.getId());
+		}
+
+		// Set the unfinished page
+
+		if (this.curPage != null) {
+			this.curPage.setAvailableBPD(this.curPage.getLeftOverBPD());
+			this.unfinishedPage = this.curPage;
+			this.unfinishedPageProvider = this.pageProvider;
+		}
+
+		pageSeq.getRoot().notifyPageSequenceFinished(currentPageNum,
+				(currentPageNum - startPageNum) + 1);
+		areaTreeHandler.notifyPageSequenceFinished(pageSeq,
+				(currentPageNum - startPageNum) + 1);
+
+		getPageSequence().releasePageSequence();
+
+		// If this sequence has a page sequence master so we must reset
+		// it in preparation for the next sequence
+		String masterReference = getPageSequence().getMasterReference();
+		PageSequenceMaster pageSeqMaster = pageSeq.getRoot()
+				.getLayoutMasterSet().getPageSequenceMaster(masterReference);
+		if (pageSeqMaster != null) {
+			pageSeqMaster.reset();
+		}
+
+		if (log.isDebugEnabled()) {
+			log.debug("Ending layout");
+		}
+
+	}
+
+	/** {@inheritDoc} */
+	protected Page createPage(int pageNumber, boolean isBlank) {
+
+		return pageProvider.getPage(isBlank, pageNumber,
+				PageProvider.RELTO_PAGE_SEQUENCE);
+	}
+
+	private void layoutSideRegion(int regionID) {
+	
+		SideRegion reg = (SideRegion) curPage.getSimplePageMaster().getRegion(
+				regionID);
+		if (reg == null) {
+			return;
+		}
+		StaticContent sc = getPageSequence().getStaticContent(
+				reg.getRegionName());
+		if (sc == null) {
+			return;
+		}
+
+		StaticContentLayoutManager lm = (StaticContentLayoutManager) getLayoutManagerMaker()
+				.makeStaticContentLayoutManager(this, sc, reg);
+		lm.doLayout();
+	}
+
+	/** {@inheritDoc} */
+	public void finishPage() {
+		
+		//	A current page of null can happen here now that support of
+		//	page-sequences with/or-without page breaks in between
+		//	is supported ... so if we run into it here ... just exit.
+ 	   if (curPage == null)
+ 		  	return;
+ 	   
+		// Layout side regions
+		layoutSideRegion(FO_REGION_BEFORE);
+		layoutSideRegion(FO_REGION_AFTER);
+		layoutSideRegion(FO_REGION_START);
+		layoutSideRegion(FO_REGION_END);
+
+		super.finishPage();
+
+	}
+
+	public Page getUnfinishedPage() {
+		return this.unfinishedPage;
+	}
+
+	public void setUnfinishedPage(Page unfinishedPage) {
+		this.unfinishedPage = unfinishedPage;
+	}
+
+	public PageProvider getUnfinishedPageProvider() {
+		return this.unfinishedPageProvider;
+	}
+
+	public void setUnfinishedPageProvider(PageProvider unfinishedPageProvider) {
+		this.unfinishedPageProvider = unfinishedPageProvider;
+	}
+
 }
Index: src/java/org/apache/fop/layoutmgr/PageBreaker.java
===================================================================
--- src/java/org/apache/fop/layoutmgr/PageBreaker.java	(revision 123107)
+++ src/java/org/apache/fop/layoutmgr/PageBreaker.java	(revision 123188)
@@ -48,6 +48,8 @@
     private PageProvider pageProvider;
     private Block separatorArea;
     
+    private int  optimalPageCount = 0;
+    
     /**
      * The FlowLayoutManager object, which processes
      * the single fo:flow of the fo:page-sequence
@@ -302,19 +304,19 @@
                 footnoteSeparatorLength,
                 isPartOverflowRecoveryActivated(), false, false);
         //alg.setConstantLineWidth(flowBPD);
-        int iOptPageCount = algRestart.findBreakingPoints(effectiveList,
+        this.optimalPageCount = algRestart.findBreakingPoints(effectiveList,
                     newStartPos,
                     1, true, BreakingAlgorithm.ALL_BREAKS);
-        AbstractBreaker.log.debug("restart: iOptPageCount= " + iOptPageCount
+        AbstractBreaker.log.debug("restart: iOptPageCount= " + this.optimalPageCount
                 + " pageBreaks.size()= " + algRestart.getPageBreaks().size());
         boolean replaceLastPage 
-                = iOptPageCount <= pslm.getCurrentPV().getBodyRegion().getColumnCount(); 
+                = this.optimalPageCount <= pslm.getCurrentPV().getBodyRegion().getColumnCount(); 
         if (replaceLastPage) {
             //Replace last page
             pslm.setCurrentPage(pageProvider.getPage(false, currentPageNum));
             //Make sure we only add the areas we haven't added already
             effectiveList.ignoreAtStart = newStartPos;
-            addAreas(algRestart, iOptPageCount, originalList, effectiveList);
+            addAreas(algRestart, this.optimalPageCount, originalList, effectiveList);
         } else {
             effectiveList.ignoreAtStart = newStartPos;
             addAreas(alg, restartPoint, partCount - restartPoint, originalList, effectiveList);
@@ -361,12 +363,12 @@
                 isPartOverflowRecoveryActivated(),
                 pslm.getCurrentPV().getBodyRegion().getColumnCount());
         //alg.setConstantLineWidth(flowBPD);
-        int iOptPageCount = algRestart.findBreakingPoints(effectiveList,
+        this.optimalPageCount = algRestart.findBreakingPoints(effectiveList,
                     newStartPos,
                     1, true, BreakingAlgorithm.ALL_BREAKS);
-        AbstractBreaker.log.debug("restart: iOptPageCount= " + iOptPageCount
+        AbstractBreaker.log.debug("restart: iOptPageCount= " + this.optimalPageCount
                 + " pageBreaks.size()= " + algRestart.getPageBreaks().size());
-        if (iOptPageCount > pslm.getCurrentPV().getBodyRegion().getColumnCount()) {
+        if (this.optimalPageCount > pslm.getCurrentPV().getBodyRegion().getColumnCount()) {
             AbstractBreaker.log.warn(
                     "Breaking algorithm produced more columns than are available.");
             /* reenable when everything works
@@ -376,7 +378,7 @@
         }
         //Make sure we only add the areas we haven't added already
         effectiveList.ignoreAtStart = newStartPos;
-        addAreas(algRestart, iOptPageCount, originalList, effectiveList);
+        addAreas(algRestart, this.optimalPageCount, originalList, effectiveList);
         AbstractBreaker.log.debug("===================================================");
     }
     
@@ -541,4 +543,14 @@
             return true;
         }
     }
+    
+    /**
+     * This method returns the optimal page count calculated by the Page Breaker.
+     * 
+     * @return  The optimal Page Count
+     */
+    public int getOptimalPageCount()
+    {
+   	 return this.optimalPageCount;
+    }
 }
\ No newline at end of file
Index: src/java/org/apache/fop/layoutmgr/AbstractPageSequenceLayoutManager.java
===================================================================
--- src/java/org/apache/fop/layoutmgr/AbstractPageSequenceLayoutManager.java	(revision 123107)
+++ src/java/org/apache/fop/layoutmgr/AbstractPageSequenceLayoutManager.java	(revision 123188)
@@ -63,6 +63,10 @@
     /** The stating page number */
     protected int startPageNum = 0;
     
+    PageBreaker pageBreaker = null;
+    
+    protected int optimalPageCount = 0;
+    
     /**
      * Constructor
      *
@@ -273,34 +277,64 @@
     protected abstract Page createPage(int pageNumber, boolean isBlank);
     
     /**
-     * Makes a new page
-     * 
-     * @param bIsBlank whether this page is blank or not
-     * @param bIsLast whether this page is the last page or not
-     * @return a new page
-     */
-    protected Page makeNewPage(boolean isBlank, boolean isLast) {
-        if (curPage != null) {
-            finishPage();
-        }
+	 * Makes a new page
+	 * 
+	 * @param bIsBlank
+	 *            whether this page is blank or not
+	 * @param bIsLast
+	 *            whether this page is the last page or not
+	 * @return a new page
+	 */
+	protected Page makeNewPage(boolean isBlank, boolean isLast) {
 
-        currentPageNum++;
+		if (curPage != null) {
 
-        curPage = createPage(currentPageNum, isBlank);
+			//  Only finish and start a new page if we are not on the last page
+			//	 calculated by the Page Breaker algorithm.
+			if ((this.currentPageNum - this.startPageNum + 1) != this.pageBreaker
+					.getOptimalPageCount()) {
 
-        if (log.isDebugEnabled()) {
-            log.debug("[" + curPage.getPageViewport().getPageNumberString() 
-                    + (isBlank ? "*" : "") + "]");
-        }
-        
-        addIDToPage(pageSeq.getId());
-        return curPage;
-    }
+				finishPage();
+
+				currentPageNum++;
+
+				curPage = createPage(currentPageNum, isBlank);
+
+				if (log.isDebugEnabled()) {
+					log.debug("["
+							+ curPage.getPageViewport().getPageNumberString()
+							+ (isBlank ? "*" : "") + "]");
+				}
+
+				addIDToPage(pageSeq.getId());
+
+			}
+			
+
+		} else {
+
+			currentPageNum++;
+
+			curPage = createPage(currentPageNum, isBlank);
+
+			if (log.isDebugEnabled()) {
+				log.debug("[" + curPage.getPageViewport().getPageNumberString()
+						+ (isBlank ? "*" : "") + "]");
+			}
+
+			addIDToPage(pageSeq.getId());
+		}
+
+		return curPage;
+
+	}
     
     /**
      * Finishes a page in preparation for a new page.
      */
-    protected void finishPage() {
+    public void finishPage() {
+   	 	
+   	  
         if (log.isTraceEnabled()) {
             curPage.getPageViewport().dumpMarkers();
         }
@@ -309,7 +343,9 @@
         // 
         idTracker.tryIDResolution(curPage.getPageViewport());
         // Queue for ID resolution and rendering
+    
         areaTreeHandler.getAreaTreeModel().addPage(curPage.getPageViewport());
+      
         if (log.isDebugEnabled()) {
             log.debug("page finished: " + curPage.getPageViewport().getPageNumberString() 
                     + ", current num: " + currentPageNum);
@@ -376,10 +412,25 @@
         } else if (forcePageCount == Constants.EN_NO_FORCE) {
             // i hope: nothing special at all
         }
-
-        if (curPage != null) {
-            finishPage();
-        }
+        	
+        /*  
+         * This comes out with support of page-sequences that do not have
+         * page breaks between them.
+         * 
+        if (curPage != null) 
+        {
+              finishPage();
+        } */
     }
     
+    /**
+     * Return the page breaker contained by the abstract page sequence.
+     * 
+     * @return   Page Breaker contained by the abstract page sequence.
+     */
+    PageBreaker	getPageBreaker()
+    {
+    	return this.pageBreaker;
+    }
+    
 }
Index: src/java/org/apache/fop/layoutmgr/TopLevelLayoutManager.java
===================================================================
--- src/java/org/apache/fop/layoutmgr/TopLevelLayoutManager.java	(revision 123107)
+++ src/java/org/apache/fop/layoutmgr/TopLevelLayoutManager.java	(revision 123188)
@@ -46,5 +46,37 @@
      * Finished the page-sequence and notifies everyone about it.
      */
     public void finishPageSequence();
+    
+    /**
+     * Instructs the layout manager to finish its curren tpage
+     */
+    public void finishPage();
+    
+    /**
+     * Returns the unfinished page contained by the Layout Manager
+     * @return		The unfinished page
+     */
+    public Page getUnfinishedPage();
+    
+    /**
+     * Sets the unfinished page on the layout manager.
+     * 
+     * @param unfinishedPage	The unfinished page.
+     */
+    public void setUnfinishedPage(Page unfinishedPage);
+    
+    /**
+     * Returns the unfinished page provider set on the layout manager.
+     * 
+     * @return	The unfinished page provider.
+     */
+    public PageProvider getUnfinishedPageProvider();
+    
+    /**
+     * Sets the unfinished page provider on the layout manager.
+     * 
+     * @param pageBreaker	The page provider
+     */
+    public void setUnfinishedPageProvider(PageProvider pageProvider);
 
 }
\ No newline at end of file
Index: src/java/org/apache/fop/fo/pagination/PageSequence.java
===================================================================
--- src/java/org/apache/fop/fo/pagination/PageSequence.java	(revision 123107)
+++ src/java/org/apache/fop/fo/pagination/PageSequence.java	(revision 123188)
@@ -48,6 +48,10 @@
 
     /** Map of flows to their flow name (flow-name, Flow) */
     private Map flowMap;
+    
+    //  This identifies whether a page break should exist
+    //  after the page-sequence or not.
+    private int breakAfter;
 
     /**
      * The currentSimplePageMaster is either the page master for the
@@ -86,6 +90,9 @@
         country = pList.get(PR_COUNTRY).getString();
         language = pList.get(PR_LANGUAGE).getString();
         masterReference = pList.get(PR_MASTER_REFERENCE).getString();
+        
+        breakAfter =  pList.get(PR_BREAK_AFTER).getEnum();
+       
         //writingMode = pList.getWritingMode();
         
         if (masterReference == null || masterReference.equals("")) {
@@ -94,6 +101,17 @@
     }
 
     /**
+     * Returns the break after property (by default this will have
+     * no constraint)
+     * 
+     * @return  The break after property
+     */
+    public int	getBreakAfter()
+    {
+   	 return(this.breakAfter);
+    }
+    
+    /**
      * {@inheritDoc}
      */
     protected void startOfNode() throws FOPException {
Index: src/java/org/apache/fop/fo/pagination/AbstractPageSequence.java
===================================================================
--- src/java/org/apache/fop/fo/pagination/AbstractPageSequence.java	(revision 123107)
+++ src/java/org/apache/fop/fo/pagination/AbstractPageSequence.java	(revision 123188)
@@ -89,7 +89,22 @@
         
         if (initialPageNumber.getEnum() != 0) {
             // auto | auto-odd | auto-even.
-            startingPageNumber = getRoot().getEndingPageNumberOfPreviousSequence() + 1;
+ 
+        	
+            startingPageNumber = getRoot().getEndingPageNumberOfPreviousSequence();
+           
+            if (startingPageNumber == 0)
+            {
+            	startingPageNumber+=1;
+            }
+            
+            /*  
+             *  REVISION_ISSUE:
+             *  GOING TO TEAR THIS OUT FOR NOW  This is interfering with
+             *  running page-sequences together ... This will be an issue
+             *  if submitted to FOP
+             *  
+             *  
             pageNumberType = initialPageNumber.getEnum();
             if (pageNumberType == EN_AUTO_ODD) {
                 if (startingPageNumber % 2 == 0) {
@@ -100,6 +115,9 @@
                     startingPageNumber++;
                 }
             }
+            */
+        
+        
         } else { // <integer> for explicit page number
             int pageStart = initialPageNumber.getValue();
             startingPageNumber = (pageStart > 0) ? pageStart : 1; // spec rule
Index: src/java/org/apache/fop/area/AreaTreeHandler.java
===================================================================
--- src/java/org/apache/fop/area/AreaTreeHandler.java	(revision 123107)
+++ src/java/org/apache/fop/area/AreaTreeHandler.java	(revision 123188)
@@ -33,6 +33,7 @@
 import org.apache.fop.apps.FOUserAgent;
 import org.apache.fop.apps.FormattingResults;
 import org.apache.fop.datatypes.Numeric;
+import org.apache.fop.fo.Constants;
 import org.apache.fop.fo.FOEventHandler;
 import org.apache.fop.fo.extensions.ExtensionAttachment;
 import org.apache.fop.fo.extensions.ExternalDocument;
@@ -185,7 +186,9 @@
         if (prevPageSeqLM != null) {
             prevPageSeqLM.doForcePageCount(initialPageNumber);
             prevPageSeqLM.finishPageSequence();
-            prevPageSeqLM = null;
+          //  Take this out for now ... so there will actually be
+          //	two of these PageSequenceLayoutManagers in Memory at a given time.
+          //  prevPageSeqLM = null;
         }
     }
 
@@ -196,8 +199,11 @@
     
     private void startAbstractPageSequence(AbstractPageSequence pageSequence) {
         rootFObj = pageSequence.getRoot();
+        
+        
         finishPrevPageSequence(pageSequence.getInitialPageNumber());
         pageSequence.initPageNumber();
+      
         // extension attachments from fo:root
         wrapAndAddExtensionAttachments(rootFObj.getExtensionAttachments());
         // extension attachments from fo:declarations
@@ -231,10 +237,44 @@
             PageSequenceLayoutManager pageSLM;
             pageSLM = getLayoutManagerMaker().makePageSequenceLayoutManager(
                     this, pageSequence);
+          
+            //  If we have a previous page sequence ... set the unfinished page on it
+            if (prevPageSeqLM != null)
+            {
+            	//	Check the available realestate
+            	if (prevPageSeqLM.getUnfinishedPage() != null)
+            	{
+            	   pageSLM.setUnfinishedPage(prevPageSeqLM.getUnfinishedPage());
+            	   pageSLM.setUnfinishedPageProvider(prevPageSeqLM.getUnfinishedPageProvider());
+               }
+            }
+           
+          
             pageSLM.activateLayout();
+            
+            //	If the break after property was not set we need to get the unfinished
+         	//	page
+         	if (pageSequence.getBreakAfter() == Constants.EN_AUTO)
+         	{
+         		 //	Do Nothing
+         	}
+         	//	Just finish the page
+         	else if (pageSequence.getBreakAfter() == Constants.EN_PAGE)
+         	{
+         		 //	Finish the page:
+         		 pageSLM.finishPage();
+         	}
+         	else
+         	{
+         		System.out.println("Invalid Break After Property");
+         		log.error("Invalid break-after property specified on Page Sequence.");
+         		return;
+         	}
             // preserve the current PageSequenceLayoutManger for the
             // force-page-count check at the beginning of the next PageSequence
+            prevPageSeqLM = null;
             prevPageSeqLM = pageSLM;
+      
         }
     }
 
@@ -280,6 +320,12 @@
      */
     public void endDocument() throws SAXException {
 
+    	//	If we have a previous page sequence
+    	if (this.prevPageSeqLM != null)
+    	{
+    		this.prevPageSeqLM.finishPage();
+    	} 
+    	
         finishPrevPageSequence(null);
         // process fox:destination elements
         if (rootFObj != null) {
@@ -321,6 +367,10 @@
             Resolvable res = (Resolvable) odi;
             String[] ids = res.getIDRefs();
             for (int count = 0; count < ids.length; count++) {
+            	
+           
+            	
+            	
                 List pageVPList = idTracker.getPageViewportsContainingID(ids[count]);
                 if (pageVPList != null) {
                     res.resolveIDRef(ids[count], pageVPList);
