diff options
author | Glen Mazza <gmazza@apache.org> | 2004-04-01 23:24:57 +0000 |
---|---|---|
committer | Glen Mazza <gmazza@apache.org> | 2004-04-01 23:24:57 +0000 |
commit | 2dc772585087baa3cc763702e88ccdb4e4c005ae (patch) | |
tree | 69dd142c82fcdd47ab3e212068773074b9f9b42b /examples/embedding | |
parent | a054ab3b7e22af6c163b5d68c04bf5868958a59e (diff) | |
download | xmlgraphics-fop-2dc772585087baa3cc763702e88ccdb4e4c005ae.tar.gz xmlgraphics-fop-2dc772585087baa3cc763702e88ccdb4e4c005ae.zip |
Updated examples to use Commons-Logging.
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@197475 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'examples/embedding')
-rw-r--r-- | examples/embedding/build.xml | 19 | ||||
-rw-r--r-- | examples/embedding/java/embedding/ExampleDOM2PDF.java | 20 | ||||
-rw-r--r-- | examples/embedding/java/embedding/ExampleFO2PDF.java | 18 | ||||
-rw-r--r-- | examples/embedding/java/embedding/ExampleObj2PDF.java | 30 | ||||
-rw-r--r-- | examples/embedding/java/embedding/ExampleXML2PDF.java | 32 |
5 files changed, 73 insertions, 46 deletions
diff --git a/examples/embedding/build.xml b/examples/embedding/build.xml index 4ad0a13d6..203d92a1d 100644 --- a/examples/embedding/build.xml +++ b/examples/embedding/build.xml @@ -39,6 +39,7 @@ <include name="xerces*.jar"/> <include name="xalan*.jar"/> <include name="commons-io*.jar"/> + <include name="commons-logging*.jar"/> </fileset> <fileset dir="${fop.lib.dir}/../build"> <include name="fop.jar"/> @@ -119,6 +120,24 @@ </classpath> </java> </target> + <target name="example6" depends="compile" description="Runs the DOM to PDF example"> + <echo message="Running the Object to PDF example"/> + <java classname="${name}.ExampleDOM2PDF" fork="yes"> + <classpath> + <path refid="project.class.path"/> + <pathelement location="${build.dest}"/> + </classpath> + </java> + </target> + <target name="example7" depends="compile" description="Runs the SVG to PDF example"> + <echo message="Running the Object to PDF example"/> + <java classname="${name}.ExampleSVG2PDF" fork="yes"> + <classpath> + <path refid="project.class.path"/> + <pathelement location="${build.dest}"/> + </classpath> + </java> + </target> <!-- =================================================================== --> <!-- Clean targets --> <!-- =================================================================== --> diff --git a/examples/embedding/java/embedding/ExampleDOM2PDF.java b/examples/embedding/java/embedding/ExampleDOM2PDF.java index 714c4f949..0f10157a5 100644 --- a/examples/embedding/java/embedding/ExampleDOM2PDF.java +++ b/examples/embedding/java/embedding/ExampleDOM2PDF.java @@ -33,10 +33,11 @@ import org.w3c.dom.Element; import org.w3c.dom.Node; import org.w3c.dom.Text; -// Avalon +//Avalon import org.apache.avalon.framework.ExceptionUtil; -import org.apache.avalon.framework.logger.ConsoleLogger; -import org.apache.avalon.framework.logger.Logger; + +// Commons-Logging +import org.apache.commons.logging.impl.SimpleLog; //FOP import org.apache.fop.apps.Driver; @@ -60,18 +61,19 @@ public class ExampleDOM2PDF { */ public void convertDOM2PDF(Document xslfoDoc, File pdf) throws IOException, FOPException { - //Construct driver + // Construct driver Driver driver = new Driver(); - //Setup logger - Logger logger = new ConsoleLogger(ConsoleLogger.LEVEL_INFO); - driver.enableLogging(logger); + // Setup logger + SimpleLog logger = new SimpleLog("log"); + logger.setLevel(SimpleLog.LOG_LEVEL_INFO); + driver.setLogger(logger); driver.initialize(); - //Setup Renderer (output format) + // Setup Renderer (output format) driver.setRenderer(Driver.RENDER_PDF); - //Setup output + // Setup output OutputStream out = new java.io.FileOutputStream(pdf); out = new java.io.BufferedOutputStream(out); diff --git a/examples/embedding/java/embedding/ExampleFO2PDF.java b/examples/embedding/java/embedding/ExampleFO2PDF.java index 0a9646d31..350c507f4 100644 --- a/examples/embedding/java/embedding/ExampleFO2PDF.java +++ b/examples/embedding/java/embedding/ExampleFO2PDF.java @@ -29,8 +29,9 @@ import org.xml.sax.InputSource; //Avalon import org.apache.avalon.framework.ExceptionUtil; -import org.apache.avalon.framework.logger.Logger; -import org.apache.avalon.framework.logger.ConsoleLogger; + +// Commons-Logging +import org.apache.commons.logging.impl.SimpleLog; //FOP import org.apache.fop.apps.Driver; @@ -50,18 +51,19 @@ public class ExampleFO2PDF { */ public void convertFO2PDF(File fo, File pdf) throws IOException, FOPException { - //Construct driver + // Construct driver Driver driver = new Driver(); - //Setup logger - Logger logger = new ConsoleLogger(ConsoleLogger.LEVEL_INFO); - driver.enableLogging(logger); + // Setup logger + SimpleLog logger = new SimpleLog("log"); + logger.setLevel(SimpleLog.LOG_LEVEL_INFO); + driver.setLogger(logger); driver.initialize(); - //Setup Renderer (output format) + // Setup Renderer (output format) driver.setRenderer(Driver.RENDER_PDF); - //Setup output + // Setup output OutputStream out = new java.io.FileOutputStream(pdf); out = new java.io.BufferedOutputStream(out); try { diff --git a/examples/embedding/java/embedding/ExampleObj2PDF.java b/examples/embedding/java/embedding/ExampleObj2PDF.java index 1a1143a6e..9f82334bb 100644 --- a/examples/embedding/java/embedding/ExampleObj2PDF.java +++ b/examples/embedding/java/embedding/ExampleObj2PDF.java @@ -34,8 +34,9 @@ import javax.xml.transform.sax.SAXResult; //Avalon import org.apache.avalon.framework.ExceptionUtil; -import org.apache.avalon.framework.logger.ConsoleLogger; -import org.apache.avalon.framework.logger.Logger; + +// Commons-Logging +import org.apache.commons.logging.impl.SimpleLog; //FOP import org.apache.fop.apps.Driver; @@ -61,34 +62,35 @@ public class ExampleObj2PDF { public void convertProjectTeam2PDF(ProjectTeam team, File xslt, File pdf) throws IOException, FOPException, TransformerException { - //Construct driver + // Construct driver Driver driver = new Driver(); - //Setup logger - Logger logger = new ConsoleLogger(ConsoleLogger.LEVEL_INFO); - driver.enableLogging(logger); + // Setup logger + SimpleLog logger = new SimpleLog("log"); + logger.setLevel(SimpleLog.LOG_LEVEL_INFO); + driver.setLogger(logger); driver.initialize(); - //Setup Renderer (output format) + // Setup Renderer (output format) driver.setRenderer(Driver.RENDER_PDF); - //Setup output + // Setup output OutputStream out = new java.io.FileOutputStream(pdf); out = new java.io.BufferedOutputStream(out); try { driver.setOutputStream(out); - //Setup XSLT + // Setup XSLT TransformerFactory factory = TransformerFactory.newInstance(); Transformer transformer = factory.newTransformer(new StreamSource(xslt)); - //Setup input for XSLT transformation + // Setup input for XSLT transformation Source src = team.getSourceForProjectTeam(); - //Resulting SAX events (the generated FO) must be piped through to FOP + // Resulting SAX events (the generated FO) must be piped through to FOP Result res = new SAXResult(driver.getContentHandler()); - //Start XSLT transformation and FOP processing + // Start XSLT transformation and FOP processing transformer.transform(src, res); } finally { out.close(); @@ -105,12 +107,12 @@ public class ExampleObj2PDF { System.out.println("FOP ExampleObj2PDF\n"); System.out.println("Preparing..."); - //Setup directories + // Setup directories File baseDir = new File("."); File outDir = new File(baseDir, "out"); outDir.mkdirs(); - //Setup input and output + // Setup input and output File xsltfile = new File(baseDir, "xml/xslt/projectteam2FO.xsl"); File pdffile = new File(outDir, "ResultObj2PDF.pdf"); diff --git a/examples/embedding/java/embedding/ExampleXML2PDF.java b/examples/embedding/java/embedding/ExampleXML2PDF.java index c9b81428a..90b9511fa 100644 --- a/examples/embedding/java/embedding/ExampleXML2PDF.java +++ b/examples/embedding/java/embedding/ExampleXML2PDF.java @@ -34,8 +34,9 @@ import javax.xml.transform.sax.SAXResult; //Avalon import org.apache.avalon.framework.ExceptionUtil; -import org.apache.avalon.framework.logger.ConsoleLogger; -import org.apache.avalon.framework.logger.Logger; + +// Commons-Logging +import org.apache.commons.logging.impl.SimpleLog; //FOP import org.apache.fop.apps.Driver; @@ -56,12 +57,12 @@ public class ExampleXML2PDF { System.out.println("FOP ExampleXML2PDF\n"); System.out.println("Preparing..."); - //Setup directories + // Setup directories File baseDir = new File("."); File outDir = new File(baseDir, "out"); outDir.mkdirs(); - //Setup input and output files + // Setup input and output files File xmlfile = new File(baseDir, "xml/xml/projectteam.xml"); File xsltfile = new File(baseDir, "xml/xslt/projectteam2FO.xsl"); File pdffile = new File(outDir, "ResultXML2PDF.pdf"); @@ -72,37 +73,38 @@ public class ExampleXML2PDF { System.out.println(); System.out.println("Transforming..."); - //Construct driver + // Construct driver Driver driver = new Driver(); - //Setup logger - Logger logger = new ConsoleLogger(ConsoleLogger.LEVEL_INFO); - driver.enableLogging(logger); + // Setup logger + SimpleLog logger = new SimpleLog("log"); + logger.setLevel(SimpleLog.LOG_LEVEL_INFO); + driver.setLogger(logger); driver.initialize(); - //Setup Renderer (output format) + // Setup Renderer (output format) driver.setRenderer(Driver.RENDER_PDF); - //Setup output + // Setup output OutputStream out = new java.io.FileOutputStream(pdffile); out = new java.io.BufferedOutputStream(out); try { driver.setOutputStream(out); - //Setup XSLT + // Setup XSLT TransformerFactory factory = TransformerFactory.newInstance(); Transformer transformer = factory.newTransformer(new StreamSource(xsltfile)); - // set the value of a <param> in the stylesheet + // Set the value of a <param> in the stylesheet transformer.setParameter("versionParam", "2.0"); - //Setup input for XSLT transformation + // Setup input for XSLT transformation Source src = new StreamSource(xmlfile); - //Resulting SAX events (the generated FO) must be piped through to FOP + // Resulting SAX events (the generated FO) must be piped through to FOP Result res = new SAXResult(driver.getContentHandler()); - //Start XSLT transformation and FOP processing + // Start XSLT transformation and FOP processing transformer.transform(src, res); } finally { out.close(); |