diff options
author | Glen Mazza <gmazza@apache.org> | 2004-07-16 03:36:14 +0000 |
---|---|---|
committer | Glen Mazza <gmazza@apache.org> | 2004-07-16 03:36:14 +0000 |
commit | 03a30e10172c62743876bc3bb6546c8e0a0ca4d2 (patch) | |
tree | 8c30ff5ebce9135e5e657ddde97fe0d08a8fc9c6 /examples | |
parent | 73e492ff7709c113f3fd862adf873a6a2a585bd7 (diff) | |
download | xmlgraphics-fop-03a30e10172c62743876bc3bb6546c8e0a0ca4d2.tar.gz xmlgraphics-fop-03a30e10172c62743876bc3bb6546c8e0a0ca4d2.zip |
Back to transform example, reverted yesterday's change that removed BufferedOutputStream.
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@197793 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'examples')
-rw-r--r-- | examples/embedding/java/embedding/ExampleFO2PDF.java | 34 |
1 files changed, 10 insertions, 24 deletions
diff --git a/examples/embedding/java/embedding/ExampleFO2PDF.java b/examples/embedding/java/embedding/ExampleFO2PDF.java index d86e13b27..bf44f07e1 100644 --- a/examples/embedding/java/embedding/ExampleFO2PDF.java +++ b/examples/embedding/java/embedding/ExampleFO2PDF.java @@ -19,11 +19,10 @@ package embedding; // Java +import java.io.BufferedOutputStream; import java.io.File; -import java.io.IOException; -import java.io.FileInputStream; import java.io.FileOutputStream; -import java.io.InputStream; +import java.io.IOException; import java.io.OutputStream; //JAXP @@ -32,10 +31,7 @@ import javax.xml.transform.TransformerFactory; import javax.xml.transform.Source; import javax.xml.transform.Result; import javax.xml.transform.stream.StreamSource; -import javax.xml.parsers.SAXParserFactory; import javax.xml.transform.sax.SAXResult; -import org.xml.sax.XMLReader; -import org.xml.sax.InputSource; // FOP @@ -63,35 +59,25 @@ public class ExampleFO2PDF { Driver driver = new Driver(); driver.setRenderer(Driver.RENDER_PDF); - // Setup output stream - // For performance, also buffering output stream. - // Note: buffering recommended for FileOutputStreams - // but not for ByteArrayOutputStreams. - out = new java.io.FileOutputStream(pdf); - out = new java.io.BufferedOutputStream(out); + // Setup output stream. Note: Using BufferedOutputStream + // for performance reasons (helpful with FileOutputStreams). + out = new FileOutputStream(pdf); + out = new BufferedOutputStream(out); driver.setOutputStream(out); - InputSource src = new InputSource(new FileInputStream(fo)); - SAXParserFactory factory = SAXParserFactory.newInstance(); - factory.setNamespaceAware(true); - XMLReader parser = factory.newSAXParser().getXMLReader(); - parser.setContentHandler(driver.getContentHandler()); - parser.parse(src); - -/* - // Setup input stream - Source src = new StreamSource(fo); - // Setup JAXP using identity transformer TransformerFactory factory = TransformerFactory.newInstance(); Transformer transformer = factory.newTransformer(); // identity transformer + // Setup input stream + Source src = new StreamSource(fo); + // Resulting SAX events (the generated FO) must be piped through to FOP Result res = new SAXResult(driver.getContentHandler()); // Start XSLT transformation and FOP processing transformer.transform(src, res); -*/ + } catch (Exception e) { e.printStackTrace(System.err); System.exit(-1); |