Prevent unwanted blank pages when converting xsl-fo

I use xsl-fo to create a pdf document with numbered pages (page x of x), but a blank page is always created at the end of the document. Does anyone know why the following xsl creates a blank page? If I delete the last fo: block page, a blank page will not be displayed.

<xsl:template match="/Report"> <fo:root font-family="Georgia,Garamond,New York,Times,Time New Roman,Serif"> <xsl:copy-of select="$fo-layout-master-set"/> <fo:page-sequence master-reference="default-page" initial-page-number="1" format="1"> <!-- Footer content --> <xsl:call-template name="getStaticFooter"/> <fo:flow><fo:block/> </fo:flow> </fo:page-sequence> <fo:page-sequence master-reference="default-page"> <!-- Footer content --> <xsl:call-template name="getStaticFooter"/> <fo:flow> <fo:block id="last-page"/> </fo:flow> </fo:page-sequence> </fo:root> </xsl:template> <xsl:template name="getStaticFooter"> <fo:static-content flow-name="xsl-region-after"> <fo:table xsl:use-attribute-sets="contentTable"> <fo:table-column number-columns-repeated="3" width="proportional-column-width(10)"/> <fo:table-body> <fo:table-row> <fo:table-cell text-align="right"> <fo:block> <fo:inline font-size="7pt" font-weight="bold">Generated by </fo:inline> </fo:block> <fo:block> <fo:inline font-size="7pt">Page <fo:page-number/> of <fo:page-number-citation ref-id="last-page"/></fo:inline> </fo:block> </fo:table-cell> </fo:table-row> </fo:table-body> </fo:table> </fo:static-content> </xsl:template> 

+4
source share
1 answer

I think because you have 2 different fo:page-sequence . Try moving <fo:block id="last-page"/> to the end of the stream in the first page sequence and delete the second fo:page-sequence .

Example:

 <xsl:template match="/Report"> <fo:root font-family="Georgia,Garamond,New York,Times,Time New Roman,Serif"> <xsl:copy-of select="$fo-layout-master-set"/> <fo:page-sequence master-reference="default-page" initial-page-number="1" format="1"> <!-- Footer content --> <xsl:call-template name="getStaticFooter"/> <fo:flow> <fo:block/><!-- I'm assuming this is where the actual content will exist; there most likely a <xsl:apply-templates/> here. --> <fo:block id="last-page"/> </fo:flow> </fo:page-sequence> </fo:root> </xsl:template> 
+2
source

Source: https://habr.com/ru/post/1346094/


All Articles