From: Glen Mazza Date: Fri, 16 Jul 2004 03:36:14 +0000 (+0000) Subject: Back to transform example, reverted yesterday's change that removed BufferedOutputStream. X-Git-Tag: Root_Temp_KnuthStylePageBreaking~669 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=03a30e10172c62743876bc3bb6546c8e0a0ca4d2;p=xmlgraphics-fop.git 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 --- 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);