1 50 51 package org.openlaszlo.iv.flash.fop; 52 53 import org.openlaszlo.iv.flash.util.*; 54 55 import org.openlaszlo.iv.flash.api.*; 56 57 import org.apache.fop.apps.*; 58 import org.apache.fop.messaging.MessageHandler; 59 import org.apache.fop.viewer.*; 60 61 import org.xml.sax.*; 62 import org.apache.xerces.parsers.*; 63 64 import java.awt.geom.*; 65 import java.io.*; 66 import java.net.*; 67 import java.util.*; 68 69 74 75 public class FOPHelper 76 { 77 private InputSource foInput; 78 79 private String linkHandler; 80 81 private Script script; 82 private Rectangle2D maxPageBounds; 83 84 90 91 public void setXSLFOInputSource( InputSource inputSource ) 92 { 93 this.foInput = inputSource; 94 } 95 96 public void setXSLFOInputSource( String s ) 97 { 98 this.foInput = new InputSource( new StringReader( s ) ); 99 } 100 101 public void setLinkHandler( String s ) 102 { 103 linkHandler = s; 104 } 105 106 109 110 public void render() throws IVException, IOException, FOPException 111 { 112 SWFRenderer renderer = new SWFRenderer(); 113 114 renderer.setLinkHandler( linkHandler ); 115 116 Driver driver = new Driver(); 117 118 driver.addElementMapping( "org.apache.fop.fo.StandardElementMapping" ); 119 121 driver.setRenderer( renderer ); 122 driver.setInputSource( this.foInput ); 123 124 driver.run(); 125 126 128 this.script = renderer.getScriptBuilder().getScript(); 129 130 script.getFrameAt( 0 ).addStopAction(); 131 132 this.maxPageBounds = renderer.getScriptBuilder().getMaxPageBounds(); 133 } 134 135 public Script getScript() 136 { 137 return script; 138 } 139 140 public Rectangle2D getMaxPageBounds() 141 { 142 return maxPageBounds; 143 } 144 } 145 | Popular Tags |