org.ofbiz.webapp.view
Class ApacheFopWorker

java.lang.Object
  extended by org.ofbiz.webapp.view.ApacheFopWorker

public class ApacheFopWorker
extends java.lang.Object

Apache FOP worker class.


Nested Class Summary
static class ApacheFopWorker.LocalResolver
          Local URI resolver for the Transformer class.
 
Field Summary
protected static FopFactory fopFactory
           
static java.lang.String module
           
static java.lang.String tempFilePrefix
          File name prefix used for temporary files.
 
Constructor Summary
ApacheFopWorker()
           
 
Method Summary
static Fop createFopInstance(java.io.OutputStream out, java.lang.String outputFormat)
          Returns a new Fop instance.
static java.io.File createTempFoXmlFile()
          Returns a temporary File instance.
static java.io.File createTempResultFile()
          Returns a temporary File instance.
static FopFactory getFactoryInstance()
          Returns an instance of the FopFactory class.
static void transform(java.io.File srcFile, java.io.File destFile, java.io.File stylesheetFile, java.lang.String outputFormat)
          Transform an xsl-fo file to the specified file format.
static void transform(java.io.InputStream srcStream, java.io.OutputStream destStream, java.io.InputStream stylesheetStream, java.lang.String outputFormat)
          Transform an xsl-fo InputStream to the specified OutputStream format.
static void transform(javax.xml.transform.stream.StreamSource src, javax.xml.transform.stream.StreamSource stylesheet, Fop fop)
          Transform an xsl-fo StreamSource to the specified output format.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

module

public static final java.lang.String module

tempFilePrefix

public static final java.lang.String tempFilePrefix
File name prefix used for temporary files. Currently set to org.ofbiz.webapp.view.ApacheFopWorker-.

See Also:
Constant Field Values

fopFactory

protected static FopFactory fopFactory
Constructor Detail

ApacheFopWorker

public ApacheFopWorker()
Method Detail

getFactoryInstance

public static FopFactory getFactoryInstance()
Returns an instance of the FopFactory class. FOP documentation recommends the reuse of the factory instance because of the startup time.

Returns:
FopFactory The FopFactory instance

transform

public static void transform(java.io.File srcFile,
                             java.io.File destFile,
                             java.io.File stylesheetFile,
                             java.lang.String outputFormat)
                      throws java.io.IOException,
                             FOPException
Transform an xsl-fo file to the specified file format.

Parameters:
srcFile - The xsl-fo File instance
destFile - The target (result) File instance
stylesheetFile - Optional stylesheet File instance
outputFormat - Optional output format, defaults to "application/pdf"
Throws:
java.io.IOException
FOPException

transform

public static void transform(java.io.InputStream srcStream,
                             java.io.OutputStream destStream,
                             java.io.InputStream stylesheetStream,
                             java.lang.String outputFormat)
                      throws FOPException
Transform an xsl-fo InputStream to the specified OutputStream format.

Parameters:
srcStream - The xsl-fo InputStream instance
destStream - The target (result) OutputStream instance
stylesheetStream - Optional stylesheet InputStream instance
outputFormat - Optional output format, defaults to "application/pdf"
Throws:
FOPException

transform

public static void transform(javax.xml.transform.stream.StreamSource src,
                             javax.xml.transform.stream.StreamSource stylesheet,
                             Fop fop)
                      throws FOPException
Transform an xsl-fo StreamSource to the specified output format.

Parameters:
src - The xsl-fo StreamSource instance
stylesheet - Optional stylesheet StreamSource instance
fop -
Throws:
FOPException

createFopInstance

public static Fop createFopInstance(java.io.OutputStream out,
                                    java.lang.String outputFormat)
                             throws FOPException
Returns a new Fop instance. Note: FOP documentation recommends using a Fop instance for one transform run only.

Parameters:
out - The target (result) OutputStream instance
outputFormat - Optional output format, defaults to "application/pdf"
Returns:
Fop instance
Throws:
FOPException

createTempFoXmlFile

public static java.io.File createTempFoXmlFile()
                                        throws java.io.IOException
Returns a temporary File instance. The temporary file name starts with tempFilePrefix and ends with ".xml". Calling methods are responsible for deleting the temporary file.

FOP performs transforms in memory, so if there is any chance FO output will be more than a few pages, it would be best to keep FO input in a temporary file.

Returns:
File instance
Throws:
java.io.IOException

createTempResultFile

public static java.io.File createTempResultFile()
                                         throws java.io.IOException
Returns a temporary File instance. The temporary file name starts with tempFilePrefix and ends with ".res". Calling methods are responsible for deleting the temporary file.

FOP performs transforms in memory, so if there is any chance FO output will be more than a few pages, it would be best to keep FO output in a temporary file.

Returns:
File instance
Throws:
java.io.IOException