I want to create a PDF document with a header and a footer in every pages, I don't know why they only appears in odd pages.
I simplify the code and I create a table and I repeated several times to have 4 pages but the result is the same, the header and footer appears only in the first and the third page.
Here is the code. The xsl version is 1.0.
<xsl:output indent="yes"/>
<xsl:template match ="template">
<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
<fo:layout-master-set>
<!-- layout information -->
<fo:simple-page-master master-name="pagetemplate"
page-height="29.7cm"
page-width="21cm"
margin-top="1cm"
margin-bottom="0.1cm"
margin-left="0.8cm"
margin-right="1.0cm">
<fo:region-body margin-top="2.5cm" margin-bottom="2.5cm"/>
<fo:region-before extent="2.0cm"/>
<fo:region-after extent="2.0cm"/>
</fo:simple-page-master>
</fo:layout-master-set>
<fo:page-sequence master-reference="pagetemplate">
<fo:static-content flow-name="xsl-region-before">
<fo:block>
<xsl:call-template name="header"/>
</fo:block>
</fo:static-content>
<fo:static-content flow-name="xsl-region-after">
<fo:block>
<xsl:call-template name="footer"/>
</fo:block>
</fo:static-content>
<fo:flow flow-name="xsl-region-body">
<xsl:call-template name="block"/>
<xsl:call-template name="block"/>
<xsl:call-template name="block"/>
<xsl:call-template name="block"/>
</fo:flow>
</fo:page-sequence>
</fo:root>
</xsl:template>
XSL-FO (XSL Formatting Objects) is a markup language for XML document formatting that is most often used to generate PDF files. XSL-FO is part of XSL (Extensible Stylesheet Language), a set of W3C technologies designed for the transformation and formatting of XML data. The other parts of XSL are XSLT and XPath.
XSLT has become the language of choice for a very wide range of XML applications. It is of course still used to produce XSL-FO documents for printing, but it is also used to integrate back-end software for Web sites.
XSL consists of four parts: XSLT - a language for transforming XML documents. XPath - a language for navigating in XML documents. XSL-FO - a language for formatting XML documents (discontinued in 2013) XQuery - a language for querying XML documents.
Open your XSL file in the XSL editor. Click the Snippets tab, open the XSL drawer, and then double-click Default HTML header.
I solve the problem.
The thing was that the margins of region-body, region-before and region-after weren't correct.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With