<!-- chapterName "Lesson 12: Different pages with different layouts" -->

<codesnippet language="xml" style="code"><![CDATA[
<!DOCTYPE document SYSTEM "rml.dtd">
<document filename="example_12.pdf">

    <template showBoundary="1"> 
        <pageTemplate id="Layout1">
            <pageGraphics>
                <image file="files/logo_bg.gif" x="300" y="100"/>
                <fill color="red"/>
                <setFont name="Helvetica-Bold" size="24"/>
                <drawString x="100" y="100"> This is Layout #1</drawString>
            </pageGraphics>
            <!-- two frames: -->
            <frame id="first" x1="100" y1="400" width="150" height="200"/>
            <frame id="second" x1="300" y1="400" width="150" height="200"/>
        </pageTemplate>
        <pageTemplate id="Layout2">
            <pageGraphics>
                <image file="files/logo_bg.gif" x="300" y="700"/>
                <fill color="red"/>
                <setFont name="Helvetica-Bold" size="24"/>
                <drawString x="100" y="700"> This is Layout #2</drawString>
            </pageGraphics>
            <!-- two frames: -->
            <frame id="first" x1="100" y1="100" width="150" height="200"/>
            <frame id="second" x1="500" y1="100" width="150" height="200"/>
        </pageTemplate>
    </template>

    <stylesheet>
        <!-- empty...-->
    </stylesheet>

    <story firstPageTemplate="Layout1"> 
        <para>
             Welcome to RML.
        </para>
        <para>
             This is page layout number 1.
        </para>
        <para>
            Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
            tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
            quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
            consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
            cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat
            non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."
        </para>
        <para>
            Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
            tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
            quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
            consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
        </para>
        <para>
             We will now set the next page template to layout 2, and use nextFrame to force
             text into the next frame, thereby creating page 2.
        </para>
        <setNextTemplate name="Layout2"/>
        <nextFrame/>

        <para>
            In this example, there is more than one frame in the template for page one.  If there
            hadn't been enough text to fill up all the frames, we might have needed more than
            one &lt;nextFrame&gt; tag to push the text onto a new page.  That's because the
            &lt;setNextTemplate&gt; doesn't actually start using the next template immediately;
            you have to either fill up the frames with text, or specify enough &lt;nextFrame&gt; 
            tags to account for any empty frames, before a new page will be created.
        </para>
        
    </story>
</document>


]]></codesnippet>

<para>You can easily use different layouts for different pages in your document.  Declare each different layout as a &lt;pageTemplate&gt; with an id in the &lt;template&gt; section.  Normally, the flowables will fill up the frames on a page and then flow into a new page with the same layout.  However, you can set the layout of the next page using the &lt;setNextTemplate name="templateID"/&gt; tag.  This will ensure that once the current page is full, the next page will have the layout specified.</para>
