1 17 18 19 20 package org.apache.fop.cli; 21 22 import java.io.File ; 23 import java.io.OutputStream ; 24 import java.util.Vector ; 25 26 import javax.xml.transform.Result ; 27 import javax.xml.transform.sax.SAXResult ; 28 29 import org.apache.fop.apps.FOPException; 30 import org.apache.fop.apps.FOUserAgent; 31 import org.apache.fop.area.AreaTreeModel; 32 import org.apache.fop.area.AreaTreeParser; 33 import org.apache.fop.area.RenderPagesModel; 34 import org.apache.fop.fonts.FontInfo; 35 import org.xml.sax.SAXException ; 36 37 40 public class AreaTreeInputHandler extends InputHandler { 41 42 49 public AreaTreeInputHandler(File xmlfile, File xsltfile, Vector params) { 50 super(xmlfile, xsltfile, params); 51 } 52 53 57 public AreaTreeInputHandler(File atfile) { 58 super(atfile); 59 } 60 61 62 public void renderTo(FOUserAgent userAgent, String outputFormat, OutputStream out) 63 throws FOPException { 64 FontInfo fontInfo = new FontInfo(); 65 AreaTreeModel treeModel = new RenderPagesModel(userAgent, 66 outputFormat, fontInfo, out); 67 68 AreaTreeParser parser = new AreaTreeParser(); 70 71 Result res = new SAXResult (parser.getContentHandler(treeModel, userAgent)); 73 74 transformTo(res); 75 76 try { 77 treeModel.endDocument(); 78 } catch (SAXException e) { 79 throw new FOPException(e); 80 } 81 } 82 83 } 84 | Popular Tags |