1. PDF generation with fop (zafu-fo)

    After the first experiment with LateX, we are setting up a way to produce PDF files from xsl-fo which is more flexible then LateX for report generation.

    After the first experiment with LateX, we are setting up a way to produce PDF files from xsl-fo which is more flexible then LateX for report generation.

    To use xsl-fo rendering, you create a zafu template starting with a fop tag. You can then write zafu to produce valid xml. The stylesheet must be stored at the same place as the zafu template and should produce valid xsl-fo.

    This is an example of a template:

    <r:fop stylesheet='print.xslt'>
    <report>
      <title do='[v_title]'/>
      <entries do='pages'>
        <entry do='each'>...</entry>
      </entries>
    </report>
    </r:fop>

    And the corresponding “print.xslt” stylesheet:

    <?xml version="1.0" encoding="iso-8859-1"?>
    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
    xmlns:fo="http://www.w3.org/1999/XSL/Format">
    <xsl:template match="/">
    	<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
    	  <fo:layout-master-set>
    	    <fo:simple-page-master master-name="my-page">
    	      <fo:region-body margin="1in"/>
    	    </fo:simple-page-master>
    	  </fo:layout-master-set>
    
    	  <fo:page-sequence master-reference="my-page">
    	    <fo:flow flow-name="xsl-region-body">
    				<fo:block text-align="right" font-family="Helvectica, Arial, sans-serif" font-size="18pt">
    					<xsl:value-of select="report/title" />
    				</fo:block>
    	      <xsl:apply-templates select='report/entries'/>
    	    </fo:flow>
    	  </fo:page-sequence>
    	</fo:root>
    </xsl:template>
    
    <xsl:template match="entries">
        <fo:block font-family="Helvectica, Arial, sans-serif" font-size="32pt">entries</fo:block>
        <xsl:apply-templates select="entry" />
    </xsl:template>
    
    <xsl:template match="entry">
        <fo:block><xsl:value-of select='date'></fo:block>
        <fo:block><xsl:value-of select='action'></fo:block>
    </xsl:template>
    </xsl:stylesheet>
    

    This should give you a basic hint on how to get started with zafu-fo.

    Gaspard Bucher