<?xml version="1.0" encoding="ISO-8859-1"?><!--
  Licensed to the Apache Software Foundation (ASF) under one or more
  contributor license agreements.  See the NOTICE file distributed with
  this work for additional information regarding copyright ownership.
  The ASF licenses this file to You under the Apache License, Version 2.0
  (the "License"); you may not use this file except in compliance with
  the License.  You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions and
  limitations under the License.
--><!-- $Id$ --><!DOCTYPE document PUBLIC "-//APACHE//DTD Documentation V1.3//EN" "document-v13.dtd">
<document xmlns:xi="http://www.w3.org/2001/XInclude">
  <header>
    <title>Apache&#8482; FOP: Ant task</title>
    <version>$Revision$</version>
  </header>
  <body>
    <p>
      Apache&#8482; FOP provides an Ant task for automating the document build process.
    </p>
    <section id="basics">
      <title>Description</title>
      <p>
        The FOP Ant task will convert XSL-FO documents to PDF, PS, PCL etc. output
        (see <link href="output.html">Output formats</link> for available formats).
      </p>
      <p>
        To call FOP tasks within Ant, first add a FOP task definition to your Ant build file.
        One method of defining the task is as follows:
      </p>
      <source xml:space="preserve"><![CDATA[
<property name="fop.home" value="....path to your FOP HOME directory..."/>

<taskdef name="fop" 
         classname="org.apache.fop.tools.anttasks.Fop">
  <classpath>
    <fileset dir="${fop.home}/lib">
      <include name="*.jar"/>
    </fileset>
    <fileset dir="${fop.home}/build">
      <include name="fop.jar"/>
      <include name="fop-hyph.jar" />
    </fileset>
  </classpath>
</taskdef>
    ]]></source>
<p>
    Then create FOP tasks within your Ant build file, using the FOP task parameters listed below.</p>
    </section>
    <!-- TODO: Installation/Configuration -->
    <section id="parameters"><title>Parameters for FOP Ant task</title>
     <table><caption>Parameters specified as attributes</caption> 
      <tr> 
       <th colspan="1" rowspan="1">Attribute</th> 
       <th colspan="1" rowspan="1">Description</th> 
       <th colspan="1" rowspan="1">Required</th> 
      </tr> 
      <tr> 
       <td colspan="1" rowspan="1">fofile</td> 
       <td colspan="1" rowspan="1">XSL-FO file to be rendered</td> 
       <td colspan="1" rowspan="1">Yes, if no fileset nested element is used</td> 
      </tr> 
      <tr> 
       <td colspan="1" rowspan="1">xmlfile</td> 
       <td colspan="1" rowspan="1">XML input file</td> 
       <td colspan="1" rowspan="1">Yes, if no fofile is specified</td> 
      </tr> 
      <tr> 
       <td colspan="1" rowspan="1">xsltfile</td> 
       <td colspan="1" rowspan="1">XSLT input file</td> 
       <td colspan="1" rowspan="1">Yes, if no fofile is specified</td> 
      </tr> 
      <tr> 
       <td colspan="1" rowspan="1">outfile</td> 
       <td colspan="1" rowspan="1">Output filename</td> 
       <td colspan="1" rowspan="1">Yes, when fofile is used.  (This attribute is not valid for filesets.)</td> 
      </tr> 
      <tr> 
       <td colspan="1" rowspan="1">format</td> 
       <td colspan="1" rowspan="1">Possible output formats:<br/>
         <code>application/X-fop-awt-preview</code><br/>
         <code>application/X-fop-print</code><br/>
         <code>application/X-fop-areatree</code><br/>
         <code>application/pdf</code><br/>
         <code>application/postscript</code><br/>
         <code>application/mif</code><br/>
         <code>application/rtf</code>,
         <code>text/richtext</code>,
         <code>text/rtf</code><br/>
         <code>application/x-pcl</code>,
         <code>application/vnd.hp-PCL</code><br/>
         <code>application/x-afp</code>,
         <code>application/vnd.ibm.modcap</code><br/>
         <code>text/plain</code><br/>
         <code>image/svg+xml</code><br/>
         <code>image/gif</code><br/>
         <code>image/png</code><br/>
         <code>image/tiff</code><br/>
       </td> 
       <td colspan="1" rowspan="1">No, defaults to <code>application/pdf</code></td> 
      </tr> 
      <tr> 
       <td colspan="1" rowspan="1">outdir</td> 
       <td colspan="1" rowspan="1">Output directory</td> 
       <td colspan="1" rowspan="1">Required if a fileset is used to specify the files to render; optional for fofile. (Can alternatively specify the full path in the fofile value.)</td> 
      </tr> 
      <tr> 
       <td colspan="1" rowspan="1">force</td> 
       <td colspan="1" rowspan="1">Recreate target files, even if they are newer than their corresponding
            source files. Note: This attribute is available in post-0.20.5 
            versions (0.20.x nightly build and 1.0dev) only; target files are 
            always generated (i.e., force=true) in 0.20.5 release.
       </td> 
       <td colspan="1" rowspan="1">No, default is <code>false</code></td> 
      </tr> 
      <tr> 
       <td colspan="1" rowspan="1">basedir</td> 
       <td colspan="1" rowspan="1">Base directory to resolve relative references (e.g., graphics files) within the 
            FO document.
       </td> 
       <td colspan="1" rowspan="1">No, for single FO File entry, default is to use the location 
            of that FO file.
       </td> 
      </tr> 
      <tr> 
       <td colspan="1" rowspan="1">relativebase</td> 
       <td colspan="1" rowspan="1">For fileset usage only.  A value of <code>true</code> specifies using the location
        of each .fo file as the base directory for resolving relative file references located
        within that .fo file.  A value of <code>false</code> specifies using the value of 
        basedir for all files within the fileset, or just the current working directory
        if basedir is not specified.
       </td> 
       <td colspan="1" rowspan="1">No, default is <code>false</code>.
       </td> 
      </tr> 
      <tr> 
       <td colspan="1" rowspan="1">userconfig</td> 
       <td colspan="1" rowspan="1">User configuration file (same as the FOP "-c" command line option).</td> 
       <td colspan="1" rowspan="1">No</td> 
      </tr> 
      <tr> 
       <td colspan="1" rowspan="1">messagelevel</td> 
       <td colspan="1" rowspan="1">Logging level<br/>
       Possible values: <code>error</code>, <code>warn</code>, <code>info</code>, <code>verbose</code>, <code>debug</code>. <strong>Currently doesn't work in FOP Trunk!!!</strong></td> 
       <td colspan="1" rowspan="1">No, defaults to <code>verbose</code></td> 
      </tr> 
      <tr> 
       <td colspan="1" rowspan="1">logFiles</td> 
       <td colspan="1" rowspan="1">Controls whether the names of the files that are processed are logged 
            (<code>true</code>) or not (<code>false</code>). <strong>Currently doesn't work in FOP Trunk!!!</strong></td> 
       <td colspan="1" rowspan="1">No, default is <code>true</code></td> 
      </tr> 
      <tr> 
       <td colspan="1" rowspan="1">throwexceptions</td> 
       <td colspan="1" rowspan="1">Controls whether or not an exception is thrown if an error occurs during rendering.</td> 
       <td colspan="1" rowspan="1">Default is <code>true</code></td> 
      </tr> 
     </table>
     <p/>
     <table><caption>Parameters specified as nested elements</caption>
      <tr> 
       <th colspan="1" rowspan="1">Attribute</th> 
       <th colspan="1" rowspan="1">Description</th> 
       <th colspan="1" rowspan="1">Required</th> 
      </tr> 
      <tr> 
       <td colspan="1" rowspan="1">fileset</td> 
       <td colspan="1" rowspan="1"><link href="http://ant.apache.org/manual/CoreTypes/fileset.html">FileSets</link> 
            are used to specify multiple XSL-FO files to be rendered.</td> 
       <td colspan="1" rowspan="1">Yes, if no fofile attribute is supplied</td> 
      </tr> 
      </table>
    </section>
    <section id="examples">
    <title>Examples</title>
    <p>
    The following example converts a single XSL-FO file to a PDF document:
    </p>

    <source xml:space="preserve"><![CDATA[
<target name="generate-pdf" description="Generates a single PDF file">
   <fop format="application/pdf" 
        fofile="c:\working\foDirectory\foDocument.fo"
        outfile="c:\working\pdfDirectory\pdfDocument.pdf" />
</target>
    ]]></source>
    <p>
    This example converts all XSL-FO files within an entire directory to PostScript:
    </p>
    <source xml:space="preserve"><![CDATA[
<target name="generate-multiple-ps" 
        description="Generates multiple PostScript files">
   <fop format="application/postscript" 
        outdir="${build.dir}" messagelevel="debug">
        <fileset dir="${fo.examples.dir}">
           <include name="*.fo"/>
        </fileset>
   </fop>
</target>
    ]]></source>
    <p>
    The following example transforms and converts a single XML and XSLT file to an AFP document:
    </p>
    <source xml:space="preserve"><![CDATA[
<target name="generate-afp-from-transform" description="Generates a single AFP file from an XSLT stylesheet">
   <fop format="application/x-afp" 
        xmlfile="c:\working\foDirectory\Document.xml"
        xsltfile="c:\working\foDirectory\Document.xslt"
        outfile="c:\working\afpDirectory\Document.afp" />
</target>
    ]]></source>
    <p>
    This example transforms and converts all XML files within an entire directory to PostScript:
    </p>
    <source xml:space="preserve"><![CDATA[
<target name="generate-multiple-ps-from-transform" description="Generates multiple PostScript files using an XSLT stylesheet">
   <fop format="application/postscript" 
        xsltfile="c:\working\foDirectory\Document.xslt"
        outdir="${build.dir}" messagelevel="debug">
        <fileset dir="${test.dir}">
           <include name="*.xml"/>
        </fileset>
   </fop>
</target>
    ]]></source>
    </section>
    </body>
</document>