Movatterモバイル変換


[0]ホーム

URL:


 

Apache XML Graphics Project Logo

Apache™ FOP

This document is for an old version of FOP that is no longer supported.Latest version of this page
The Apache FOP Project

The Apache™ FOP Project

Apache™ FOP: Ant task

Apache™ FOP provides an Ant task for automating the document build process.

Description

The FOP Ant task will convert XSL-FO documents to PDF, PS, PCL etc. output (seeOutput formats for available formats).

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:

<propertyname="fop.home"value="....path to your FOP HOME directory..."/><taskdefname="fop"classname="org.apache.fop.tools.anttasks.Fop"><classpath><filesetdir="${fop.home}/lib"><includename="*.jar"/></fileset><filesetdir="${fop.home}/build"><includename="fop.jar"/><includename="fop-hyph.jar"/></fileset></classpath></taskdef>

Then create FOP tasks within your Ant build file, using the FOP task parameters listed below.

Parameters for FOP Ant task

Parameters specified as attributes

AttributeDescriptionRequired
fofileXSL-FO file to be renderedYes, if no fileset nested element is used
xmlfileXML input fileYes, if no fofile is specified
xsltfileXSLT input fileYes, if no fofile is specified
outfileOutput filenameYes, when fofile is used. (This attribute is not valid for filesets.)
formatPossible output formats:

application/X-fop-awt-preview

application/X-fop-print

application/X-fop-areatree

application/pdf

application/postscript

application/mif

application/rtf,text/richtext,text/rtf

application/x-pcl,application/vnd.hp-PCL

application/x-afp,application/vnd.ibm.modcap

text/plain

image/svg+xml

image/gif

image/png

image/tiff

No, defaults toapplication/pdf
outdirOutput directoryRequired if a fileset is used to specify the files to render; optional for fofile. (Can alternatively specify the full path in the fofile value.)
forceRecreate 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.No, default isfalse
basedirBase directory to resolve relative references (e.g., graphics files) within the FO document.No, for single FO File entry, default is to use the location of that FO file.
relativebaseFor fileset usage only. A value oftrue specifies using the location of each .fo file as the base directory for resolving relative file references located within that .fo file. A value offalse specifies using the value of basedir for all files within the fileset, or just the current working directory if basedir is not specified.No, default isfalse.
userconfigUser configuration file (same as the FOP "-c" command line option).No
messagelevelLogging level

Possible values:error,warn,info,verbose,debug.Currently doesn't work in FOP Trunk!!!
No, defaults toverbose
logFilesControls whether the names of the files that are processed are logged (true) or not (false).Currently doesn't work in FOP Trunk!!!No, default istrue
throwexceptionsControls whether or not an exception is thrown if an error occurs during rendering.Default istrue


Parameters specified as nested elements

AttributeDescriptionRequired
filesetFileSets are used to specify multiple XSL-FO files to be rendered.Yes, if no fofile attribute is supplied

Examples

The following example converts a single XSL-FO file to a PDF document:

<targetname="generate-pdf"description="Generates a single PDF file"><fopformat="application/pdf"fofile="c:\working\foDirectory\foDocument.fo"outfile="c:\working\pdfDirectory\pdfDocument.pdf"/></target>

This example converts all XSL-FO files within an entire directory to PostScript:

<targetname="generate-multiple-ps"description="Generates multiple PostScript files"><fopformat="application/postscript"outdir="${build.dir}"messagelevel="debug"><filesetdir="${fo.examples.dir}"><includename="*.fo"/></fileset></fop></target>

The following example transforms and converts a single XML and XSLT file to an AFP document:

<targetname="generate-afp-from-transform"description="Generates a single AFP file from an XSLT stylesheet"><fopformat="application/x-afp"xmlfile="c:\working\foDirectory\Document.xml"xsltfile="c:\working\foDirectory\Document.xslt"outfile="c:\working\afpDirectory\Document.afp"/></target>

This example transforms and converts all XML files within an entire directory to PostScript:

<targetname="generate-multiple-ps-from-transform"description="Generates multiple PostScript files using an XSLT stylesheet"><fopformat="application/postscript"xsltfile="c:\working\foDirectory\Document.xslt"outdir="${build.dir}"messagelevel="debug"><filesetdir="${test.dir}"><includename="*.xml"/></fileset></fop></target>
Apache Software Foundation

Copyright © 2025 The Apache Software Foundation, Licensed undertheApache License, Version 2.0.
Apache, Apache XML Graphics, Apache FOP, Apache Batik, the Apache logo, and theApache XML Graphics logos are trademarks ofThe ApacheSoftware Foundation. All other marks mentioned may be trademarks or registeredtrademarks of their respective owners.


[8]ページ先頭

©2009-2026 Movatter.jp