keiron 01/09/24 01:51:17
Modified: docs/design build.xml
docs/examples build.xml
docs/xml-docs build.xml
lib buildtools.jar
src/org/apache/fop/pdf PDFDocument.java
src/org/apache/fop/tools/anttasks Fop.java
Log:
this patch alters the fop ant task so that other render output
formats are supported
output type can be specified by mime type and also handles
file sets
Submitted by: Jeremias Maerki <[EMAIL PROTECTED]>
Revision Changes Path
1.3 +42 -57 xml-fop/docs/design/build.xml
Index: build.xml
===================================================================
RCS file: /home/cvs/xml-fop/docs/design/build.xml,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- build.xml 2001/09/10 11:32:13 1.2
+++ build.xml 2001/09/24 08:51:17 1.3
@@ -1,73 +1,58 @@
<?xml version="1.0"?>
-
<!-- ======================================================================= -->
<!-- JBoss documentation build file -->
<!-- ======================================================================= -->
-
<project name="FOPDocs" default="docs" basedir="./">
- <target name="init">
+ <target name="init">
<property name="Name" value="FOPDocs"/>
<property name="name" value="fopdocs"/>
<property name="version" value="0.1"/>
-
<property name="lib.dir" value="${basedir}/lib"/>
-
- <taskdef name="xslt" classname="org.apache.fop.tools.anttasks.Xslt"/>
- <taskdef name="fop" classname="org.apache.fop.tools.anttasks.Fop"/>
- </target>
-
- <!-- =================================================================== -->
- <!-- Generate a help screen -->
- <!-- =================================================================== -->
- <target name="help" depends="init">
-
- <echo message="${name}-${version} build file, available targets:" />
- <echo message="------------------------------------------------------------" />
- <echo message="main : Compile and prepare deployment directory. " />
- <echo message="pdf : Compile and prepare pdf user docs. "/>
- <echo message="clean : Clean deployment and distribution. " />
- <echo message="------------------------------------------------------------" />
- <echo message=" USAGE: build <target> " />
-
- </target>
-
- <!-- =================================================================== -->
- <!-- Prepares the build directory -->
- <!-- =================================================================== -->
- <target name="prepare" depends="init">
- </target>
-
- <!-- =================================================================== -->
- <!-- Generates the pdf documentation -->
- <!-- =================================================================== -->
- <target name="pdf" depends="prepare">
- <echo message="Building pdf documentation. Please wait ..."/>
- <delete file="fop.fo"/>
- <xslt infile="fop.xml" xsltfile="docbook/fo/docbook.xsl"
- dependent="fop.xml"
- outfile="fop.fo" smart="yes"/>
-<!--
+ <taskdef name="xslt" classname="org.apache.fop.tools.anttasks.Xslt"/>
+ <taskdef name="fop" classname="org.apache.fop.tools.anttasks.Fop"/>
+ </target>
+ <!-- =================================================================== -->
+ <!-- Generate a help screen -->
+ <!-- =================================================================== -->
+ <target name="help" depends="init">
+ <echo message="${name}-${version} build file, available targets:"/>
+ <echo
message="------------------------------------------------------------"/>
+ <echo message="main : Compile and prepare deployment
directory. "/>
+ <echo message="pdf : Compile and prepare pdf user docs. "/>
+ <echo message="clean : Clean deployment and distribution. "/>
+ <echo
message="------------------------------------------------------------"/>
+ <echo message=" USAGE: build <target> "/>
+ </target>
+ <!-- =================================================================== -->
+ <!-- Prepares the build directory -->
+ <!-- =================================================================== -->
+ <target name="prepare" depends="init"/>
+ <!-- =================================================================== -->
+ <!-- Generates the pdf documentation -->
+ <!-- =================================================================== -->
+ <target name="pdf" depends="prepare">
+ <echo message="Building pdf documentation. Please wait ..."/>
+ <delete file="fop.fo"/>
+ <xslt infile="fop.xml" xsltfile="docbook/fo/docbook.xsl"
dependent="fop.xml" outfile="fop.fo" smart="yes"/>
+ <!--
<style basedir="./"
destdir="./"
style="docbook/fo/docbook.xsl"
extension=".fo"
includes="fop.xml"/>
-->
- <fop fofile="fop.fo" pdffile="fop.pdf"/>
-<!-- <delete file="fop.fo"/>-->
- </target>
-
- <!-- =================================================================== -->
- <!-- Generates pdf and html documentation -->
- <!-- =================================================================== -->
- <target name="docs" depends="pdf"/>
-
- <!-- =================================================================== -->
- <!-- Cleans up generated stuff -->
- <!-- =================================================================== -->
- <target name="clean" depends="init">
- <delete file="fop.fo"/>
- <delete file="fop.pdf"/>
- </target>
+ <fop fofile="fop.fo" outfile="fop.pdf"/>
+ <!-- <delete file="fop.fo"/>-->
+ </target>
+ <!-- =================================================================== -->
+ <!-- Generates pdf and html documentation -->
+ <!-- =================================================================== -->
+ <target name="docs" depends="pdf"/>
+ <!-- =================================================================== -->
+ <!-- Cleans up generated stuff -->
+ <!-- =================================================================== -->
+ <target name="clean" depends="init">
+ <delete file="fop.fo"/>
+ <delete file="fop.pdf"/>
+ </target>
</project>
-
1.19 +122 -122 xml-fop/docs/examples/build.xml
Index: build.xml
===================================================================
RCS file: /home/cvs/xml-fop/docs/examples/build.xml,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -r1.18 -r1.19
--- build.xml 2001/06/19 10:55:16 1.18
+++ build.xml 2001/09/24 08:51:17 1.19
@@ -1,126 +1,126 @@
<?xml version="1.0"?>
-
<!-- =========================================================================== -->
-
-<project default="creating new test pdf files" basedir=".">
-
- <!-- =================================================================== -->
- <!-- Initialization target -->
- <!-- =================================================================== -->
- <target name="init">
- <tstamp/>
- <mkdir dir="tests"/>
- <property name="referenceDir" value="reference"/>
- <property name="testDir" value="tests"/>
- <property name="foDir" value="fo"/>
- <taskdef name="fop" classname="org.apache.fop.tools.anttasks.Fop"/>
- <taskdef name="compare" classname="org.apache.fop.tools.anttasks.Compare"/>
-
-
- </target>
-
- <!-- =================================================================== -->
- <!-- Help on usage -->
- <!-- =================================================================== -->
- <target name="usage">
- <echo message=""/>
- <echo message=""/>
- <echo message="USAGE of runtests"/>
- <echo message="-------------------------------------------------------------"/>
- <echo message=""/>
- <echo message=" available targets are:"/>
- <echo message=""/>
- <echo message=" compare --> generates new pdf test files and compares them
to reference files (default)"/>
- <echo message=" reference --> generates new reference pdf files"/>
- <echo message=" See the comments inside the build.xml file for more details."/>
- <echo message="-------------------------------------------------------------"/>
- <echo message=""/>
- <echo message=""/>
- </target>
-
- <!-- =================================================================== -->
- <!-- Produces new test pdf files -->
- <!-- =================================================================== -->
- <target name="creating new test pdf files" depends="init">
- <fop fofile="${foDir}/normal.fo" pdffile="${testDir}/normal.pdf"/>
- <fop fofile="${foDir}/table.fo" pdffile="${testDir}/table.pdf"/>
- <fop fofile="${foDir}/list.fo" pdffile="${testDir}/list.pdf"/>
- <fop fofile="${foDir}/link.fo" pdffile="${testDir}/link.pdf"/>
- <fop fofile="${foDir}/newlinktest.fo" pdffile="${testDir}/newlinktest.pdf"/>
- <fop fofile="${foDir}/border.fo" pdffile="${testDir}/border.pdf"/>
- <fop fofile="${foDir}/extensive.fo" pdffile="${testDir}/extensive.pdf"/>
- <fop fofile="${foDir}/images.fo" pdffile="${testDir}/images.pdf"/>
- <fop fofile="${foDir}/readme.fo" pdffile="${testDir}/readme.pdf"/>
- <fop fofile="${foDir}/fonts.fo" pdffile="${testDir}/fonts.pdf"/>
- <fop fofile="${foDir}/leader.fo" pdffile="${testDir}/leader.pdf"/>
- <fop fofile="${foDir}/textdeko.fo" pdffile="${testDir}/textdeko.pdf"/>
- <fop fofile="${foDir}/inhprop.fo" pdffile="${testDir}/inhprop.pdf"/>
- <fop fofile="${foDir}/normalex.fo" pdffile="${testDir}/normalex.pdf"/>
- <fop fofile="${foDir}/simple.fo" pdffile="${testDir}/simple.pdf"/>
- <!-- <fop fofile="${foDir}/hyphen.fo" pdffile="${testDir}/hyphen.pdf"/> -->
- <fop fofile="${foDir}/character.fo" pdffile="${testDir}/character.pdf"/>
- <fop fofile="${foDir}/pdfoutline.fo" pdffile="${testDir}/pdfoutline.pdf"/>
- <fop fofile="${foDir}/corresprop.fo" pdffile="${testDir}/corresprop.pdf"/>
- <fop fofile="${foDir}/bordershorthand.fo"
pdffile="${testDir}/bordershorthand.pdf"/>
- </target>
-
-
- <target name="image" depends="init">
- <fop fofile="${foDir}/images.fo" pdffile="${testDir}/images.pdf"/>
- </target>
-
- <!-- =================================================================== -->
- <!-- Compares new test pdf files to reference pdf files -->
- <!-- =================================================================== -->
- <target name="compare" depends ="creating new test pdf files">
- <compare referenceDirectory = "${referenceDir}"
- testDirectory = "${testDir}"
- filenames =
"normal.pdf,table.pdf,list.pdf,link.pdf,border.pdf,images.pdf,extensive.pdf,readme.pdf,fonts.pdf,list2.pdf"/>
- </target>
-
- <!-- =================================================================== -->
- <!-- Produces new reference pdf files -->
- <!-- =================================================================== -->
- <target name="reference">
- <fop fofile="${foDir}/normal.fo" pdffile="${referenceDir}/normal.pdf"/>
- <fop fofile="${foDir}/table.fo" pdffile="${referenceDir}/table.pdf"/>
- <fop fofile="${foDir}/list.fo" pdffile="${referenceDir}/list.pdf"/>
- <fop fofile="${foDir}/link.fo" pdffile="${referenceDir}/link.pdf"/>
- <fop fofile="${foDir}/newlinktest.fo"
pdffile="${referenceDir}/newlinktest.pdf"/>
- <fop fofile="${foDir}/border.fo" pdffile="${referenceDir}/border.pdf"/>
- <fop fofile="${foDir}/extensive.fo" pdffile="${referenceDir}/extensive.pdf"/>
- <fop fofile="${foDir}/images.fo" pdffile="${referenceDir}/images.pdf"/>
- <fop fofile="${foDir}/readme.fo" pdffile="${referenceDir}/readme.pdf"/>
- <fop fofile="${foDir}/fonts.fo" pdffile="${referenceDir}/fonts.pdf"/>
- <fop fofile="${foDir}/leader.fo" pdffile="${referenceDir}/leader.pdf"/>
- <fop fofile="${foDir}/textdeko.fo" pdffile="${referenceDir}/textdeko.pdf"/>
- <fop fofile="${foDir}/inhprop.fo" pdffile="${referenceDir}/inhprop.pdf"/>
- <fop fofile="${foDir}/normalex.fo" pdffile="${referenceDir}/normalex.pdf"/>
- <fop fofile="${foDir}/simple.fo" pdffile="${referenceDir}/simple.pdf"/>
- <!-- <fop fofile="${foDir}/hyphen.fo" pdffile="${referenceDir}/hyphen.pdf"/> -->
- <fop fofile="${foDir}/character.fo" pdffile="${referenceDir}/character.pdf"/>
-
- </target>
-
-
-
-
- <!-- =================================================================== -->
- <!-- Starts the test -->
- <!-- =================================================================== -->
- <target name="runtest" depends="compare">
- <echo message="Running Fop tests"/>
- </target>
-
- <!-- =================================================================== -->
- <!-- Clean targets -->
- <!-- =================================================================== -->
- <target name="clean" depends="init">
- <delete dir="${testDir}"/>
-
- </target>
-
-
+<project default="newPDF" basedir=".">
+ <!-- =================================================================== -->
+ <!-- Initialization target -->
+ <!-- =================================================================== -->
+ <target name="init">
+ <tstamp/>
+ <mkdir dir="tests"/>
+ <property name="referenceDir" value="reference"/>
+ <property name="testDir" value="tests"/>
+ <property name="foDir" value="fo"/>
+ <taskdef name="fop" classname="org.apache.fop.tools.anttasks.Fop"/>
+ <taskdef name="compare"
classname="org.apache.fop.tools.anttasks.Compare"/>
+ </target>
+ <!-- =================================================================== -->
+ <!-- Help on usage -->
+ <!-- =================================================================== -->
+ <target name="usage">
+ <echo message=""/>
+ <echo message=""/>
+ <echo message="USAGE of runtests"/>
+ <echo
message="-------------------------------------------------------------"/>
+ <echo message=""/>
+ <echo message=" available targets are:"/>
+ <echo message=""/>
+ <echo message=" newPDF --> generates new PDF test files (default)"/>
+ <echo message=" newPS --> generates new PostScript test files"/>
+ <echo message=" newAT --> generates new AreaTree (XML) test files"/>
+ <echo message=" comparePDF --> generates new PDF test files and
compares them to reference files"/>
+ <echo message=" referencePDF --> generates new reference PDF files"/>
+ <echo message=" See the comments inside the build.xml file for more
details."/>
+ <echo
message="-------------------------------------------------------------"/>
+ <echo message=""/>
+ <echo message=""/>
+ </target>
+ <!-- =================================================================== -->
+ <!-- Produces new test pdf files -->
+ <!-- =================================================================== -->
+ <target name="newPDF" depends="init">
+ <fop fofile="${foDir}/normal.fo" outfile="${testDir}/normal.pdf"/>
+ <fop fofile="${foDir}/table.fo" outfile="${testDir}/table.pdf"/>
+ <fop fofile="${foDir}/list.fo" outfile="${testDir}/list.pdf"/>
+ <fop fofile="${foDir}/link.fo" outfile="${testDir}/link.pdf"/>
+ <fop fofile="${foDir}/newlinktest.fo"
outfile="${testDir}/newlinktest.pdf"/>
+ <fop fofile="${foDir}/border.fo" outfile="${testDir}/border.pdf"/>
+ <fop fofile="${foDir}/extensive.fo"
outfile="${testDir}/extensive.pdf"/>
+ <fop fofile="${foDir}/images.fo" outfile="${testDir}/images.pdf"/>
+ <fop fofile="${foDir}/readme.fo" outfile="${testDir}/readme.pdf"/>
+ <fop fofile="${foDir}/fonts.fo" outfile="${testDir}/fonts.pdf"/>
+ <fop fofile="${foDir}/leader.fo" outfile="${testDir}/leader.pdf"/>
+ <fop fofile="${foDir}/textdeko.fo" outfile="${testDir}/textdeko.pdf"/>
+ <fop fofile="${foDir}/inhprop.fo" outfile="${testDir}/inhprop.pdf"/>
+ <fop fofile="${foDir}/normalex.fo" outfile="${testDir}/normalex.pdf"/>
+ <fop fofile="${foDir}/simple.fo" outfile="${testDir}/simple.pdf"/>
+ <!-- <fop fofile="${foDir}/hyphen.fo"
outfile="${testDir}/hyphen.pdf"/> -->
+ <fop fofile="${foDir}/character.fo"
outfile="${testDir}/character.pdf"/>
+ <fop fofile="${foDir}/pdfoutline.fo"
outfile="${testDir}/pdfoutline.pdf"/>
+ <fop fofile="${foDir}/corresprop.fo"
outfile="${testDir}/corresprop.pdf"/>
+ <fop fofile="${foDir}/bordershorthand.fo"
outfile="${testDir}/bordershorthand.pdf"/>
+ </target>
+ <target name="image" depends="init">
+ <fop fofile="${foDir}/images.fo" outfile="${testDir}/images.pdf"/>
+ </target>
+ <!-- =================================================================== -->
+ <!-- Produces new test ps files -->
+ <!-- =================================================================== -->
+ <target name="newPS" depends="init">
+ <fop format="application/postscript" outdir="${testDir}">
+ <fileset dir="${foDir}">
+ <include name="**/*.fo"/>
+ </fileset>
+ </fop>
+ </target>
+ <!-- =================================================================== -->
+ <!-- Produces new test areatree files
-->
+ <!-- =================================================================== -->
+ <target name="newAT" depends="init">
+ <fop format="text/xml" outdir="${testDir}">
+ <fileset dir="${foDir}">
+ <include name="**/*.fo"/>
+ </fileset>
+ </fop>
+ </target>
+ <!-- =================================================================== -->
+ <!-- Compares new test pdf files to reference pdf files -->
+ <!-- =================================================================== -->
+ <target name="comparePDF" depends="newPDF">
+ <compare referenceDirectory="${referenceDir}"
testDirectory="${testDir}"
filenames="normal.pdf,table.pdf,list.pdf,link.pdf,border.pdf,images.pdf,extensive.pdf,readme.pdf,fonts.pdf,list2.pdf"/>
+ </target>
+ <!-- =================================================================== -->
+ <!-- Produces new reference pdf files
-->
+ <!-- =================================================================== -->
+ <target name="referencePDF">
+ <fop fofile="${foDir}/normal.fo" outfile="${referenceDir}/normal.pdf"/>
+ <fop fofile="${foDir}/table.fo" outfile="${referenceDir}/table.pdf"/>
+ <fop fofile="${foDir}/list.fo" outfile="${referenceDir}/list.pdf"/>
+ <fop fofile="${foDir}/link.fo" outfile="${referenceDir}/link.pdf"/>
+ <fop fofile="${foDir}/newlinktest.fo"
outfile="${referenceDir}/newlinktest.pdf"/>
+ <fop fofile="${foDir}/border.fo" outfile="${referenceDir}/border.pdf"/>
+ <fop fofile="${foDir}/extensive.fo"
outfile="${referenceDir}/extensive.pdf"/>
+ <fop fofile="${foDir}/images.fo" outfile="${referenceDir}/images.pdf"/>
+ <fop fofile="${foDir}/readme.fo" outfile="${referenceDir}/readme.pdf"/>
+ <fop fofile="${foDir}/fonts.fo" outfile="${referenceDir}/fonts.pdf"/>
+ <fop fofile="${foDir}/leader.fo" outfile="${referenceDir}/leader.pdf"/>
+ <fop fofile="${foDir}/textdeko.fo"
outfile="${referenceDir}/textdeko.pdf"/>
+ <fop fofile="${foDir}/inhprop.fo"
outfile="${referenceDir}/inhprop.pdf"/>
+ <fop fofile="${foDir}/normalex.fo"
outfile="${referenceDir}/normalex.pdf"/>
+ <fop fofile="${foDir}/simple.fo" outfile="${referenceDir}/simple.pdf"/>
+ <!-- <fop fofile="${foDir}/hyphen.fo"
outfile="${referenceDir}/hyphen.pdf"/> -->
+ <fop fofile="${foDir}/character.fo"
outfile="${referenceDir}/character.pdf"/>
+ </target>
+ <!-- =================================================================== -->
+ <!-- Starts the test -->
+ <!-- =================================================================== -->
+ <target name="runtest" depends="comparePDF">
+ <echo message="Running Fop tests"/>
+ </target>
+ <!-- =================================================================== -->
+ <!-- Clean targets -->
+ <!-- =================================================================== -->
+ <target name="clean" depends="init">
+ <delete dir="${testDir}"/>
+ </target>
</project>
-
<!-- End of file -->
1.5 +39 -57 xml-fop/docs/xml-docs/build.xml
Index: build.xml
===================================================================
RCS file: /home/cvs/xml-fop/docs/xml-docs/build.xml,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- build.xml 2001/01/16 08:00:48 1.4
+++ build.xml 2001/09/24 08:51:17 1.5
@@ -1,5 +1,4 @@
<?xml version="1.0"?>
-
<!-- ===========================================================================
@@ -12,62 +11,45 @@
- clean -> deletes all files produced by this script
-->
-
-
<project default="pdf" basedir=".">
-
- <!-- =================================================================== -->
- <!-- Initialization target -->
- <!-- =================================================================== -->
- <target name="init">
- <tstamp/>
-
- <property name="src.dir" value="./fop"/>
- <property name="allfiles.xml" value="fop-doc.xml"/>
- <property name="outfile.fo" value="fop.fo"/>
- <property name="outfile.pdf" value="fop.pdf"/>
-
- <taskdef name="fop" classname="org.apache.fop.tools.anttasks.Fop"/>
- <taskdef name="xslt" classname="org.apache.fop.tools.anttasks.Xslt"/>
-
- </target>
-
- <!-- =================================================================== -->
- <!-- copies all xml files into one. the infile is a dummy, because the -->
- <!-- source files are defined in the stylesheet -->
- <!-- =================================================================== -->
- <target name="prepare-files" depends="init">
- <xslt infile="fop.xml" xsltfile="xml2xml.xsl"
- outfile="${allfiles.xml}" smart="yes"/>
- </target>
-
- <!-- =================================================================== -->
- <!-- Generates the fo file -->
- <!-- =================================================================== -->
- <target name="fo" depends="prepare-files">
- <xslt infile="${allfiles.xml}" xsltfile="xml2pdf.xsl"
- outfile="${outfile.fo}" smart="yes"/>
- </target>
-
-
- <!-- =================================================================== -->
- <!-- Generates the pdf file -->
- <!-- =================================================================== -->
- <target name="pdf" depends="fo">
- <fop fofile="${outfile.fo}" pdffile="${outfile.pdf}"/>
- </target>
-
-
-
- <!-- =================================================================== -->
- <!-- Clean targets -->
- <!-- =================================================================== -->
- <target name="clean">
- <delete file="${allfiles.xml}"/>
- <delete file="${outfile.fo}"/>
- <delete file="${outfile.pdf}"/>
- </target>
-
+ <!-- =================================================================== -->
+ <!-- Initialization target -->
+ <!-- =================================================================== -->
+ <target name="init">
+ <tstamp/>
+ <property name="src.dir" value="./fop"/>
+ <property name="allfiles.xml" value="fop-doc.xml"/>
+ <property name="outfile.fo" value="fop.fo"/>
+ <property name="outfile.pdf" value="fop.pdf"/>
+ <taskdef name="fop" classname="org.apache.fop.tools.anttasks.Fop"/>
+ <taskdef name="xslt" classname="org.apache.fop.tools.anttasks.Xslt"/>
+ </target>
+ <!-- =================================================================== -->
+ <!-- copies all xml files into one. the infile is a dummy, because the -->
+ <!-- source files are defined in the stylesheet -->
+ <!-- =================================================================== -->
+ <target name="prepare-files" depends="init">
+ <xslt infile="fop.xml" xsltfile="xml2xml.xsl"
outfile="${allfiles.xml}" smart="yes"/>
+ </target>
+ <!-- =================================================================== -->
+ <!-- Generates the fo file -->
+ <!-- =================================================================== -->
+ <target name="fo" depends="prepare-files">
+ <xslt infile="${allfiles.xml}" xsltfile="xml2pdf.xsl"
outfile="${outfile.fo}" smart="yes"/>
+ </target>
+ <!-- =================================================================== -->
+ <!-- Generates the pdf file -->
+ <!-- =================================================================== -->
+ <target name="pdf" depends="fo">
+ <fop fofile="${outfile.fo}" outfile="${outfile.pdf}"/>
+ </target>
+ <!-- =================================================================== -->
+ <!-- Clean targets -->
+ <!-- =================================================================== -->
+ <target name="clean">
+ <delete file="${allfiles.xml}"/>
+ <delete file="${outfile.fo}"/>
+ <delete file="${outfile.pdf}"/>
+ </target>
</project>
-
<!-- End of file -->
1.10 +99 -100 xml-fop/lib/buildtools.jar
<<Binary file>>
1.30 +2 -2 xml-fop/src/org/apache/fop/pdf/PDFDocument.java
Index: PDFDocument.java
===================================================================
RCS file: /home/cvs/xml-fop/src/org/apache/fop/pdf/PDFDocument.java,v
retrieving revision 1.29
retrieving revision 1.30
diff -u -r1.29 -r1.30
--- PDFDocument.java 2001/09/07 09:26:16 1.29
+++ PDFDocument.java 2001/09/24 08:51:17 1.30
@@ -1,5 +1,5 @@
/*
- * $Id: PDFDocument.java,v 1.29 2001/09/07 09:26:16 keiron Exp $
+ * $Id: PDFDocument.java,v 1.30 2001/09/24 08:51:17 keiron Exp $
* Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
* For details on use and redistribution please refer to the
* LICENSE file included with these sources.
@@ -1150,7 +1150,7 @@
String goToRef = getGoToReference(destination);
PDFOutline obj = new PDFOutline(++this.objectcount, label, goToRef);
- System.out.println("created new outline object");
+ //log.debug("created new outline object");
if (parent != null) {
parent.addOutline(obj);
1.12 +157 -28 xml-fop/src/org/apache/fop/tools/anttasks/Fop.java
Index: Fop.java
===================================================================
RCS file: /home/cvs/xml-fop/src/org/apache/fop/tools/anttasks/Fop.java,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- Fop.java 2001/08/21 06:18:55 1.11
+++ Fop.java 2001/09/24 08:51:17 1.12
@@ -1,5 +1,5 @@
/*
- * $Id: Fop.java,v 1.11 2001/08/21 06:18:55 keiron Exp $
+ * $Id: Fop.java,v 1.12 2001/09/24 08:51:17 keiron Exp $
* Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
* For details on use and redistribution please refer to the
* LICENSE file included with these sources.
@@ -9,6 +9,7 @@
// Ant
import org.apache.tools.ant.*;
+import org.apache.tools.ant.types.FileSet;
import org.apache.log.*;
import org.apache.log.format.*;
@@ -34,20 +35,23 @@
import org.apache.fop.apps.FOPException;
import org.apache.fop.configuration.Configuration;
-
/**
* Wrapper for Fop which allows it to be accessed from within an Ant task.
* Accepts the inputs:
* <ul>
* <li>fofile -> formatting objects file to be transformed</li>
- * <li>pdffile -> output filename</li>
+ * <li>format -> MIME type of the format to generate ex. "application/pdf"</li>
+ * <li>outfile -> output filename</li>
* <li>baseDir -> directory to work from</li>
* <li>messagelevel -> (info | verbose | debug) level to output non-error
messages</li>
* </ul>
*/
public class Fop extends Task {
File foFile;
- File pdfFile;
+ Vector filesets = new Vector();
+ File outFile;
+ File outDir;
+ String format; //MIME type
File baseDir;
int messageType = Project.MSG_VERBOSE;
@@ -63,30 +67,58 @@
* Gets the input file
*/
public File getFofile() {
- if (foFile == null) {
- log("fofile attribute is not set", Project.MSG_ERR);
- throw new BuildException("fofile attribute is not set");
- }
return foFile;
}
/**
+ * Adds a set of fo files (nested fileset attribute).
+ */
+ public void addFileset(FileSet set) {
+ filesets.addElement(set);
+ }
+
+ /**
* Sets the output file
* @param File to output to
*/
- public void setPdffile(File pdfFile) {
- this.pdfFile = pdfFile;
+ public void setOutfile(File outFile) {
+ this.outFile = outFile;
}
/**
- * Sets the output file
+ * Gets the output file
*/
- public File getPdffile() {
- if (pdfFile == null) {
- log("pdffile attribute is not set", Project.MSG_ERR);
- throw new BuildException("pdffile attribute is not set");
- }
- return pdfFile;
+ public File getOutfile() {
+ return this.outFile;
+ }
+
+ /**
+ * Sets the output directory
+ * @param Directory to output to
+ */
+ public void setOutdir(File outDir) {
+ this.outDir = outDir;
+ }
+
+ /**
+ * Gets the output directory
+ */
+ public File getOutdir() {
+ return this.outDir;
+ }
+
+ /**
+ * Sets output format (MIME type)
+ */
+ public void setFormat(String format) {
+ this.format = format;
+ }
+
+ /**
+ * Gets the output format (MIME type)
+ */
+ public String getFormat() {
+ return this.format;
}
/**
@@ -173,6 +205,58 @@
log.setPriority(Priority.INFO);
}
+ private int determineRenderer(String format) {
+ if ((format == null) ||
+ format.equalsIgnoreCase("application/pdf") ||
+ format.equalsIgnoreCase("pdf")) {
+ return Driver.RENDER_PDF;
+ } else if (format.equalsIgnoreCase("application/postscript") ||
+ format.equalsIgnoreCase("ps")) {
+ return Driver.RENDER_PS;
+ } else if (format.equalsIgnoreCase("application/vnd.mif") ||
+ format.equalsIgnoreCase("mif")) {
+ return Driver.RENDER_MIF;
+ } else if (format.equalsIgnoreCase("application/vnd.gp-PCL") ||
+ format.equalsIgnoreCase("pcl")) {
+ return Driver.RENDER_PCL;
+ } else if (format.equalsIgnoreCase("text/plain") ||
+ format.equalsIgnoreCase("txt")) {
+ return Driver.RENDER_TXT;
+ } else if (format.equalsIgnoreCase("text/xml") ||
+ format.equalsIgnoreCase("at") ||
+ format.equalsIgnoreCase("xml")) {
+ return Driver.RENDER_XML;
+ } else {
+ String err = "Couldn't determine renderer to use: "+format;
+ log.error(err);
+ throw new BuildException(err);
+ }
+ }
+
+ private String determineExtension(int renderer) {
+ switch (renderer) {
+ case Driver.RENDER_PDF: return ".pdf";
+ case Driver.RENDER_PS: return ".ps";
+ case Driver.RENDER_MIF: return ".mif";
+ case Driver.RENDER_PCL: return ".pcl";
+ case Driver.RENDER_TXT: return ".txt";
+ case Driver.RENDER_XML: return ".xml";
+ default:
+ String err = "Unknown renderer: "+renderer;
+ log.error(err);
+ throw new BuildException(err);
+ }
+ }
+
+ private File replaceExtension(File file, String expectedExt, String newExt) {
+ String name = file.getName();
+ if (name.toLowerCase().endsWith(expectedExt)) {
+ name = name.substring(0, name.length()-expectedExt.length());
+ }
+ name = name.concat(newExt);
+ return new File(file.getParentFile(), name);
+ }
+
public void run() throws FOPException {
try {
// Configuration.put("baseDir",
task.getBasedir().toURL().toExternalForm());
@@ -181,32 +265,77 @@
} catch (Exception e) {
task.log("Error setting base directory", Project.MSG_DEBUG);
}
+
+ task.log("Using base directory: "
+ + Configuration.getValue("baseDir"), Project.MSG_DEBUG);
+
+ int rint = determineRenderer(task.getFormat());
+ String newExtension = determineExtension(rint);
+
+ int actioncount = 0;
+
+ // deal with single source file
+ if (task.getFofile() != null) {
+ if (task.getFofile().exists()) {
+ File outf = task.getOutfile();
+ if (outf == null) {
+ throw new BuildException("outfile is required when fofile is
used");
+ }
+ if (task.getOutdir() != null) {
+ outf = new File(task.getOutdir(), outf.getName());
+ }
+ render(task.getFofile(), outf, rint);
+ actioncount++;
+ }
+ }
+
+ // deal with the filesets
+ for (int i=0; i<task.filesets.size(); i++) {
+ FileSet fs = (FileSet)task.filesets.elementAt(i);
+ DirectoryScanner ds = fs.getDirectoryScanner(task.getProject());
+ String[] files = ds.getIncludedFiles();
+
+ for (int j=0; j<files.length; j++) {
+ File f = new File(fs.getDir(task.getProject()), files[j]);
+ File outf = replaceExtension(f, ".fo", newExtension);
+ if (task.getOutdir() != null) {
+ outf = new File(task.getOutdir(), outf.getName());
+ }
+ render(f, outf, rint);
+ actioncount++;
+ }
+ }
+
+ if (actioncount == 0) {
+ task.log("No files processed. No files were selected by the filesets
and no fofile was set."
+ , Project.MSG_WARN);
+ }
+ }
- InputHandler inputHandler = new FOInputHandler(task.getFofile());
+ private void render(File foFile, File outFile, int renderer) throws
FOPException {
+ InputHandler inputHandler = new FOInputHandler(foFile);
XMLReader parser = inputHandler.getParser();
setParserFeatures(parser);
- FileOutputStream pdfOut = null;
+ FileOutputStream out = null;
try {
- pdfOut = new FileOutputStream(task.getPdffile());
+ out = new FileOutputStream(outFile);
} catch (Exception ex) {
- log.error("Failed to open " + task.getPdffile());
+ log.error("Failed to open " + outFile);
throw new BuildException(ex);
}
- task.log("Using base directory: "
- + Configuration.getValue("baseDir"), Project.MSG_DEBUG);
- task.log(task.getFofile().getName() + " -> "
- + task.getPdffile().getName(), Project.MSG_INFO);
+ task.log(foFile + " -> " + outFile, Project.MSG_INFO);
try {
- Driver driver = new Driver(inputHandler.getInputSource(), pdfOut);
+ Driver driver = new Driver(inputHandler.getInputSource(), out);
driver.setLogger(log);
- driver.setRenderer(Driver.RENDER_PDF);
+ driver.setRenderer(renderer);
driver.setXMLReader(parser);
driver.run();
+ out.close();
} catch (Exception ex) {
- log.error("Couldn't render pdf: " + ex.getMessage());
+ log.error("Couldn't render file: " + ex.getMessage());
throw new BuildException(ex);
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]