- From: Amick, Eric <Eric.Amick@mail.house.gov>
- Date: Wed, 28 Jan 2009 08:41:09 -0500
- To: <roger@senanque.co.nz>, <www-xsl-fo@w3.org>
- Message-ID: <1C972EC37048FA409A9EE8B360613ECD0F3633@HRM09.US.House.gov>
I think you'll find this easier and more portable to boot:
http://www.cranesoftwrights.com/resources/psmi/index.htm
Eric Amick
Legislative Computer Systems
Office of the Clerk
________________________________
From: www-xsl-fo-request@w3.org [mailto:www-xsl-fo-request@w3.org] On
Behalf Of Roger Parkinson
Sent: Tuesday, January 27, 2009 16:43
To: www-xsl-fo@w3.org
Subject: How to mix portrait and landscape in one document
I spent a little time getting this going and it works for me so I
thought I would share it.
Sometimes I want a diagram or a table to display in landscape but I want
the rest of my doc in portrait.
I do something like this in my doc:
<landscape>
<... definition of table or image etc >
</landscape>
This is how I got it to work (and I'm happy to hear if there is a
smarter way, of course).
<xsl:template match="landscape">
<xsl:text
disable-output-escaping="yes"><![CDATA[</fo:flow></fo:page-sequence>]]><
/xsl:text>
<fo:page-sequence master-reference="landscape">
<fo:static-content flow-name="folio">
<xsl:call-template name="PageFooter"/><!-- set up the
page footer for landscape -->
</fo:static-content>
<fo:flow flow-name="text">
<xsl:apply-templates/>
</fo:flow>
</fo:page-sequence>
<xsl:text disable-output-escaping="yes">><![CDATA[
<fo:page-sequence master-reference="oddEven">
]]></xsl:text>
<fo:static-content flow-name="folio">
<xsl:call-template name="PageFooter"/> <!-- this
sets up the page footer again for the new portrait flow-->
</fo:static-content>
<xsl:text disable-output-escaping="yes"><![CDATA[
<fo:flow flow-name="text">
]]></xsl:text>
</xsl:template>
This matches my <landscape> tag and everything inside that is rendered
in landscape mode using the page-sequence-master "landscape"
We have to interrupt the main flow and page-sequence for this to work,
and that means using
<xsl:text
disable-output-escaping="yes"><![CDATA[</fo:flow></fo:page-sequence>]]><
/xsl:text>
because, of course, the style sheet would not be valid XML otherwise. We
restore the flow (or make a new one similar) after the landscape tag is
done.
This assumes the following has been done earlier to define the page
masters:
<xsl:template name="PageMasterPortrait">
<fo:simple-page-master
master-name="oddLayout"
page-height="29.5cm"
page-width="21cm"
margin-top="0.1cm"
margin-bottom="0.1cm"
margin-left="1cm"
margin-right="1cm">
<fo:region-body
margin-top="0.75in"
margin-bottom="0.8in"
margin-left="0.75in"
margin-right="0.5in"
extent="0.5in"
region-name="text"/>
<fo:region-before region-name="oddHead" extent="0.5in"/>
<fo:region-after region-name="folio" extent="0.6in"/>
</fo:simple-page-master>
<fo:simple-page-master
master-name="evenLayout"
page-height="29.5cm"
page-width="21cm"
margin-top="0.1cm"
margin-bottom="0.1cm"
margin-left="1cm"
margin-right="1cm">
<fo:region-body
margin-top="0.75in"
margin-bottom="0.8in"
margin-left="0.5in"
margin-right="0.75in"
extent="0.5in"
region-name="text"/>
<fo:region-before region-name="evenHead" extent="0.5in"/>
<fo:region-after region-name="folio" extent="0.6in"/>
</fo:simple-page-master>
<fo:simple-page-master
master-name="landscapeLayout"
page-height="21cm"
page-width="30cm"
margin-top="0.1cm"
margin-bottom="0.1cm"
margin-left="1cm"
margin-right="1cm">
<fo:region-body
margin-top="0.75in"
margin-bottom="0.8in"
margin-left="0.5in"
margin-right="0.75in"
extent="0.5in"
region-name="text"/>
<fo:region-before region-name="evenHead" extent="0.5in"/>
<fo:region-after region-name="folio" extent="0.6in"/>
</fo:simple-page-master>
<fo:page-sequence-master master-name="landscape">
<fo:single-page-master-reference
master-reference="landscapeLayout"/>
</fo:page-sequence-master>
<fo:page-sequence-master master-name="oddEven">
<fo:repeatable-page-master-alternatives>
<fo:conditional-page-master-reference odd-or-even="odd"
master-reference="oddLayout"/>
<fo:conditional-page-master-reference odd-or-even="even"
master-reference="evenLayout"/>
</fo:repeatable-page-master-alternatives>
</fo:page-sequence-master>
</xsl:template>
.... and the root of my XSL looks like this:
<xsl:template match="/">
<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format"
<http://www.w3.org/1999/XSL/Format> >
<fo:layout-master-set>
<xsl:call-template name="PageMasterPortrait"/>
</fo:layout-master-set>
<fo:page-sequence master-reference="oddEven">
<fo:static-content flow-name="folio">
<xsl:call-template name="PageFooter"/>
</fo:static-content>
<fo:flow flow-name="text">
<xsl:apply-templates select="doc/body"/>
</fo:flow>
</fo:page-sequence>
</fo:root>
</xsl:template>
The page footer is just a block showing the page number and title, yours
will be different.
Enjoy!
<http://homepages.ihug.co.nz/%7Eprocon/>
Received on Tuesday, 3 February 2009 19:51:59 UTC