XSL-FO and XSLT

 

XSL-FO and XSLT can help each other.


Remember this example?

<fo:block
    font-size="14pt" font-family="verdana" color="red"
    space-before="5mm" space-after="5mm">
PdfBroker.io
</fo:block>
<fo:block
    text-indent="5mm"
    font-family="verdana" font-size="12pt"
    space-before="5mm" space-after="5mm">
At PdfBroker.io you can generate PDF documents from web standards like html and xml. No SDK needed.
</fo:block>
Result:


PdfBroker.io

   At PdfBroker.io you can generate PDF documents from web standards like html and xml. No SDK needed.
 

The example above is from the chapter about XSL-FO Blocks.


With a little help from XSLT

Remove the XSL-FO information from the document:

<header>
PdfBroker.io
</header>
<paragraph>
At PdfBroker.io you can generate PDF documents from web standards like html and xml. No SDK needed.
</paragraph>

Add an XSLT transformation:

<xsl:template match="header">
<fo:block
    font-size="14pt" font-family="verdana" color="red"
    space-before="5mm" space-after="5mm">
    <xsl:apply-templates/>
</fo:block>
</xsl:template>

<xsl:template match="paragraph">
<fo:block
    text-indent="5mm"
    font-family="verdana" font-size="12pt"
    space-before="5mm" space-after="5mm">
    <xsl:apply-templates/>
</fo:block>
</xsl:template>

And the result will be the same:


PdfBroker.io

   At PdfBroker.io you can generate PDF documents from web standards like html and xml. No SDK needed.
 


More examples with XSLT

You can checkout a more realistic example of using XSLT with Xsl-fo in our demo section where we transform an example xml of an order into a pdf invoice on /demo/xsl-fo-transformation-invoice-demo


Feedback

Feedback

Let us know what you think and help us improve