You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

anttask.xml 8.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236
  1. <?xml version="1.0" encoding="UTF-8" standalone="no"?>
  2. <!--
  3. Licensed to the Apache Software Foundation (ASF) under one or more
  4. contributor license agreements. See the NOTICE file distributed with
  5. this work for additional information regarding copyright ownership.
  6. The ASF licenses this file to You under the Apache License, Version 2.0
  7. (the "License"); you may not use this file except in compliance with
  8. the License. You may obtain a copy of the License at
  9. http://www.apache.org/licenses/LICENSE-2.0
  10. Unless required by applicable law or agreed to in writing, software
  11. distributed under the License is distributed on an "AS IS" BASIS,
  12. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. See the License for the specific language governing permissions and
  14. limitations under the License.
  15. -->
  16. <!-- $Id$ -->
  17. <!DOCTYPE document PUBLIC "-//APACHE//DTD Documentation V2.0//EN" "http://forrest.apache.org/dtd/document-v20.dtd">
  18. <document>
  19. <header>
  20. <title>Apache™ FOP: Ant task</title>
  21. <version>$Revision$</version>
  22. </header>
  23. <body>
  24. <p>
  25. Apache™ FOP provides an Ant task for automating the document build process.
  26. </p>
  27. <section id="basics">
  28. <title>Description</title>
  29. <p>
  30. The FOP Ant task will convert XSL-FO documents to PDF, PS, PCL etc. output
  31. (see <a href="output.html">Output formats</a> for available formats).
  32. </p>
  33. <p>
  34. To call FOP tasks within Ant, first add a FOP task definition to your Ant build file.
  35. One method of defining the task is as follows:
  36. </p>
  37. <source><![CDATA[
  38. <property name="fop.home" value="....path to your FOP HOME directory..."/>
  39. <taskdef name="fop"
  40. classname="org.apache.fop.tools.anttasks.Fop">
  41. <classpath>
  42. <fileset dir="${fop.home}/lib">
  43. <include name="*.jar"/>
  44. </fileset>
  45. <fileset dir="${fop.home}/build">
  46. <include name="fop.jar"/>
  47. <include name="fop-hyph.jar" />
  48. </fileset>
  49. </classpath>
  50. </taskdef>
  51. ]]></source>
  52. <p>
  53. Then create FOP tasks within your Ant build file, using the FOP task parameters listed below.</p>
  54. </section>
  55. <!-- TODO: Installation/Configuration -->
  56. <section id="parameters"><title>Parameters for FOP Ant task</title>
  57. <table><caption>Parameters specified as attributes</caption>
  58. <tr>
  59. <th>Attribute</th>
  60. <th>Description</th>
  61. <th>Required</th>
  62. </tr>
  63. <tr>
  64. <td>fofile</td>
  65. <td>XSL-FO file to be rendered</td>
  66. <td>Yes, if no fileset nested element is used</td>
  67. </tr>
  68. <tr>
  69. <td>xmlfile</td>
  70. <td>XML input file</td>
  71. <td>Yes, if no fofile is specified</td>
  72. </tr>
  73. <tr>
  74. <td>xsltfile</td>
  75. <td>XSLT input file</td>
  76. <td>Yes, if no fofile is specified</td>
  77. </tr>
  78. <tr>
  79. <td>outfile</td>
  80. <td>Output filename</td>
  81. <td>Yes, when fofile is used. (This attribute is not valid for filesets.)</td>
  82. </tr>
  83. <tr>
  84. <td>format</td>
  85. <td>Possible output formats:<br/>
  86. <code>application/X-fop-awt-preview</code><br/>
  87. <code>application/X-fop-print</code><br/>
  88. <code>application/X-fop-areatree</code><br/>
  89. <code>application/pdf</code><br/>
  90. <code>application/postscript</code><br/>
  91. <code>application/mif</code><br/>
  92. <code>application/rtf</code>,
  93. <code>text/richtext</code>,
  94. <code>text/rtf</code><br/>
  95. <code>application/x-pcl</code>,
  96. <code>application/vnd.hp-PCL</code><br/>
  97. <code>application/x-afp</code>,
  98. <code>application/vnd.ibm.modcap</code><br/>
  99. <code>text/plain</code><br/>
  100. <code>image/svg+xml</code><br/>
  101. <code>image/gif</code><br/>
  102. <code>image/png</code><br/>
  103. <code>image/tiff</code><br/>
  104. </td>
  105. <td>No, defaults to <code>application/pdf</code></td>
  106. </tr>
  107. <tr>
  108. <td>outdir</td>
  109. <td>Output directory</td>
  110. <td>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>
  111. </tr>
  112. <tr>
  113. <td>force</td>
  114. <td>Recreate target files, even if they are newer than their corresponding
  115. source files. Note: This attribute is available in post-0.20.5
  116. versions (0.20.x nightly build and 1.0dev) only; target files are
  117. always generated (i.e., force=true) in 0.20.5 release.
  118. </td>
  119. <td>No, default is <code>false</code></td>
  120. </tr>
  121. <tr>
  122. <td>basedir</td>
  123. <td>Base directory to resolve relative references (e.g., graphics files) within the
  124. FO document.
  125. </td>
  126. <td>No, for single FO File entry, default is to use the location
  127. of that FO file.
  128. </td>
  129. </tr>
  130. <tr>
  131. <td>relativebase</td>
  132. <td>For fileset usage only. A value of <code>true</code> specifies using the location
  133. of each .fo file as the base directory for resolving relative file references located
  134. within that .fo file. A value of <code>false</code> specifies using the value of
  135. basedir for all files within the fileset, or just the current working directory
  136. if basedir is not specified.
  137. </td>
  138. <td>No, default is <code>false</code>.
  139. </td>
  140. </tr>
  141. <tr>
  142. <td>userconfig</td>
  143. <td>User configuration file (same as the FOP "-c" command line option).</td>
  144. <td>No</td>
  145. </tr>
  146. <tr>
  147. <td>messagelevel</td>
  148. <td>Logging level<br/>
  149. 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>
  150. <td>No, defaults to <code>verbose</code></td>
  151. </tr>
  152. <tr>
  153. <td>logFiles</td>
  154. <td>Controls whether the names of the files that are processed are logged
  155. (<code>true</code>) or not (<code>false</code>). <strong>Currently doesn't work in FOP Trunk!!!</strong></td>
  156. <td>No, default is <code>true</code></td>
  157. </tr>
  158. <tr>
  159. <td>throwexceptions</td>
  160. <td>Controls whether or not an exception is thrown if an error occurs during rendering.</td>
  161. <td>Default is <code>true</code></td>
  162. </tr>
  163. </table>
  164. <p/>
  165. <table><caption>Parameters specified as nested elements</caption>
  166. <tr>
  167. <th>Attribute</th>
  168. <th>Description</th>
  169. <th>Required</th>
  170. </tr>
  171. <tr>
  172. <td>fileset</td>
  173. <td><a href="http://ant.apache.org/manual/CoreTypes/fileset.html">FileSets</a>
  174. are used to specify multiple XSL-FO files to be rendered.</td>
  175. <td>Yes, if no fofile attribute is supplied</td>
  176. </tr>
  177. </table>
  178. </section>
  179. <section id="examples">
  180. <title>Examples</title>
  181. <p>
  182. The following example converts a single XSL-FO file to a PDF document:
  183. </p>
  184. <source><![CDATA[
  185. <target name="generate-pdf" description="Generates a single PDF file">
  186. <fop format="application/pdf"
  187. fofile="c:\working\foDirectory\foDocument.fo"
  188. outfile="c:\working\pdfDirectory\pdfDocument.pdf" />
  189. </target>
  190. ]]></source>
  191. <p>
  192. This example converts all XSL-FO files within an entire directory to PostScript:
  193. </p>
  194. <source><![CDATA[
  195. <target name="generate-multiple-ps"
  196. description="Generates multiple PostScript files">
  197. <fop format="application/postscript"
  198. outdir="${build.dir}" messagelevel="debug">
  199. <fileset dir="${fo.examples.dir}">
  200. <include name="*.fo"/>
  201. </fileset>
  202. </fop>
  203. </target>
  204. ]]></source>
  205. <p>
  206. The following example transforms and converts a single XML and XSLT file to an AFP document:
  207. </p>
  208. <source><![CDATA[
  209. <target name="generate-afp-from-transform" description="Generates a single AFP file from an XSLT stylesheet">
  210. <fop format="application/x-afp"
  211. xmlfile="c:\working\foDirectory\Document.xml"
  212. xsltfile="c:\working\foDirectory\Document.xslt"
  213. outfile="c:\working\afpDirectory\Document.afp" />
  214. </target>
  215. ]]></source>
  216. <p>
  217. This example transforms and converts all XML files within an entire directory to PostScript:
  218. </p>
  219. <source><![CDATA[
  220. <target name="generate-multiple-ps-from-transform" description="Generates multiple PostScript files using an XSLT stylesheet">
  221. <fop format="application/postscript"
  222. xsltfile="c:\working\foDirectory\Document.xslt"
  223. outdir="${build.dir}" messagelevel="debug">
  224. <fileset dir="${test.dir}">
  225. <include name="*.xml"/>
  226. </fileset>
  227. </fop>
  228. </target>
  229. ]]></source>
  230. </section>
  231. </body>
  232. </document>