Hello,
I use fop in my application to convert html-to-pdf. Apart from using the jar, there is an html-to-pdf.xsl that helps this process.
I am having problems in page breaks in that the page that is generated after the break has a big white space before the contents actually begin. This is causing an issue as the first page is not consistent with the rest.
This was found on the internet by my colleague and we have coded none of it.
I am copy-pasting the specific code that (I think!) helps in page breaks.
Please let me know how the space-after-page-break can be avioded. Any help would be much appreciated. Thanks in advance.
<!-- ============================================
We render the <h1> by putting a horizontal rule
and a page break before it. We also process
the id attribute; if the <h1> tag has one, we
use it. If not, we see if the preceding element
is a named anchor (<a name="x"/>
. If there is
a named anchor before the <h1>, we use the name
of the anchor point as the id.
=============================================== -->
<xsl:template match="h1">
<fo:block break-before="page"></fo:block>
<fo:block font-size="28pt" line-height="32pt"
keep-with-next="always"
space-after="22pt" font-family="serif">
<xsl:attribute name="id">
<xsl:choose>
<xsl:when test="@id">
<xsl:value-of select="@id"/>
</xsl:when>
<xsl:when test="name(preceding-sibling::*[1]) = 'a' and
preceding-sibling::*[1][@name]">
<xsl:value-of select="preceding-sibling::*[1]/@name"/>
</xsl:when>
<xsl
therwise>
<xsl:value-of select="generate-id()"/>
</xsl
therwise>
</xsl:choose>
</xsl:attribute>
<xsl:apply-templates select="*|text()"/>
</fo:block>
</xsl:template>