|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.xmlmind.fo.converter.Driver
public class Driver
A driver for the conversion process.
The Driver class provides a high-level interface to set up
and perform a conversion. A typical use is as follows:
setProperties or
loadPropertyFile method.
setInput methods. The input source may be specified as a
character stream, a byte stream, a file name or a URL. It is represented
internally by an instance of the InputSource object of the SAX
API.
setOutput methods. The output destination may be specified as
a character stream, a byte stream, or a file name. It is represented
internally by an instance of the OutputDestination object.
convert() method.
Alternatively, an application may create and initialize an
InputSource object, create and initialize an
OutputDestination object, and call the
convert(InputSource, OutputDestination) method.
| Constructor Summary | |
|---|---|
Driver()
Creates a new Driver instance. |
|
| Method Summary | |
|---|---|
void |
convert()
Performs conversion. |
void |
convert(InputSource input,
OutputDestination output)
Performs conversion. |
void |
error(Exception exception)
Not for public use: implementation of ErrorHandler. |
UriResolver |
getUriResolver()
Returns the registered URI resolver. |
XMLReader |
getXMLReader()
Returns the registered external XML reader. |
static String[] |
listEncodings(String format)
Returns the list of available encodings for the specified output format. |
void |
loadPropertyFile(File file)
Reads conversion options from a file. |
void |
loadPropertyFile(String fileName)
Equivalent to loadPropertyFile(new File(fileName)). |
void |
loadUserConfiguration()
Reads conversion options from the user configuration file. |
static void |
main(String[] args)
Not for public use: implementation of the fo2XXX command-line utilities. |
void |
setErrorHandler(ErrorHandler handler)
Registers a conversion error handler. |
void |
setInput(InputSource input)
Sets the input source for the next conversion. |
void |
setInput(InputStream byteStream)
Sets the input source for the next conversion. |
void |
setInput(Reader characterStream)
Sets the input source for the next conversion. |
void |
setInput(String fileName)
Sets the input source for the next conversion. |
void |
setInput(URL url)
Sets the input source for the next conversion. |
void |
setOutput(OutputDestination output)
Sets the output destination for the next conversion. |
void |
setOutput(OutputStream byteStream)
Sets the output destination for the next conversion. |
void |
setOutput(String fileName)
Sets the output destination for the next conversion. |
void |
setOutput(Writer characterStream)
Sets the output destination for the next conversion. |
void |
setProperties(Properties properties)
Sets conversion options. |
void |
setProperty(String key,
String value)
Sets a conversion option. |
void |
setUriResolver(UriResolver resolver)
Registers a URI resolver. |
void |
setXMLReader(XMLReader reader)
Registers an external XML reader. |
void |
warning(Exception exception)
Not for public use: implementation of ErrorHandler. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public Driver()
Driver instance.
| Method Detail |
|---|
public static String[] listEncodings(String format)
throws IllegalArgumentException
format - the output format (rtf, wml,
docx or odt)
IllegalArgumentException - if the format argument
is invalidsetPropertypublic void setInput(InputSource input)
input - the input source, specified as an InputSource
objectsetInput(String),
setInput(URL),
setInput(InputStream),
setInput(Reader)public void setInput(String fileName)
fileName - the input source, specified as a file namesetInput(InputSource),
setInput(URL),
setInput(InputStream),
setInput(Reader)public void setInput(URL url)
url - the input source, specified as a URLsetInput(InputSource),
setInput(String),
setInput(InputStream),
setInput(Reader)public void setInput(InputStream byteStream)
byteStream - the input source, specified as a byte streamsetInput(InputSource),
setInput(String),
setInput(URL),
setInput(Reader)public void setInput(Reader characterStream)
characterStream - the input source, specified as a character
streamsetInput(InputSource),
setInput(String),
setInput(URL),
setInput(InputStream)public void setOutput(OutputDestination output)
output - the output destination, specified as an
OutputDestination objectsetOutput(String),
setOutput(OutputStream),
setOutput(Writer)public void setOutput(String fileName)
fileName - the output destination, specified as a file namesetOutput(OutputDestination),
setOutput(OutputStream),
setOutput(Writer)public void setOutput(OutputStream byteStream)
byteStream - the output destination, specified as a byteStreamsetOutput(OutputDestination),
setOutput(String),
setOutput(Writer)public void setOutput(Writer characterStream)
Note: this method is not suitable for OpenDocument output.
characterStream - the output destination, specified as a character
streamsetOutput(OutputDestination),
setOutput(String),
setOutput(OutputStream)
public void setProperty(String key,
String value)
All conversion options are specified as standard Java properties. Property names and values are summarized in the table below.
| Name | Value | Description | Default |
|---|---|---|---|
alwaysSaveAsPNG
| true or false
| If true, do not attempt to save JPEG images
as JPEG files in the output file. Instead always transcode JPEG
images to PNG.
| false
|
baseURL (1)
| URL | base URL of relative paths in property values | none (paths are taken relative to the input source URL) |
docx.useVML
| true or false
| Use VML -deprecated- elements rather than DrawingML elements to represent images | false
|
genericFontFamilies
| A string having this syntax:
map -> entry [',' entry]*
entry -> generic_family '=' actual_family
generic_family -> 'serif' | 'sans-serif' | 'monospace'
| 'cursive' | 'fantasy'
| May be used to map generic font families to actual font families. | Depends on the output format. Generally: serif=Times New Roman,sans-serif=Arial,monospace=Courier New |
imageResolution
| Positive integer | default image resolution in DPI.
Used to compute the intrinsic size of an image when an image file does not contain resolution or absolute size information. | 96 |
imageRendererResolution
| Positive integer | default image resolution in DPI.
Used to compute the intrinsic size of an image, according to the image renderer (that is, MS-Word or OpenOffice), when an image file does not contain resolution or absolute size information. | Depends on the output format. Generally 96.
It is strongly recommended to use this default value. |
outputEncoding
| See below | output encoding | See below |
outputFormat
| rtf, wml, docx or
odt
| output format | rtf
|
prescaleImages
| true or false
| image scaling policy (2) | false
|
rtf.target
| MSWord
| target RTF viewer | none (no specified target) |
screenResolution
| Positive integer | screen resolution in DPI. Used to convert px lengths to other units. | 96 |
set.graphic_factory_name.parameter_name
| Depends on the parameter | Sets parameter parameter_name on graphic factory called
graphic_factory_name (case-insensitive).
graphic factory examples: ImageIO,
WMF, EMF, SVG, MathML.
Important: unlike all the other properties which only have
an effect on this converter, property
Converter conv = new Converter();
conv.setProperty("set.SVG.resolution", "300"); // DPI
without actually using converter conv is a simple way
to configure graphic factory SVG.
| Depends on the parameter |
singleSidedLayout
| true or false
| single-sided page layout (3) | false
|
styles
| An URL in its string form (e.g. "file:///C:/My%20Folder/styles.xfc") or a filename (e.g. "C:\My Folder\styles.xfc"). A relative filename is relative to the current working directory. | Specifies the location of an XML file containing the set of user styles to be used during the conversion. | Do not use user styles; only use direct formatting/automatic styles. |
The outputEncoding property possible values depend on
the target output format:
ASCII,
Cp1250 (Windows Eastern European), Cp1251
(Windows Cyrillic) and Cp1252 (Windows Latin-1). The
default value is Cp1252.
ISO8859_1) or the charset name (e.g.
ISO-8859-1). The complete list of supported encodings is
returned by the listEncodings method.
The default value is Cp1252.
UTF-8 and UTF-16. The default value is
UTF-8.
ISO8859_1) or the charset name (e.g.
ISO-8859-1). The complete list of supported encodings is
returned by the listEncodings method.
The default value is UTF8.
(1) Use of the baseURL property is
deprecated. Applications should register their own URI resolver to handle URIs in property values.
(2) By default images are not prescaled.
Instead, the original size of images is preserved and scaling
directives are inserted in the output document.
Set the prescaleImages property to true
if you prefer to minimize the size of the output document.
(3) By default RTF, WML and Open XML output documents are
given a double-sided page layout regardless of the input document
properties. To force a single-sided page layout the
singleSidedLayout property must be set to
true.
key - the property namevalue - the property valuesetProperties,
loadPropertyFilepublic void setProperties(Properties properties)
All conversion options are specified as standard Java properties.
See the setProperty method for an
option summary.
properties - a property setsetProperty,
loadPropertyFile
public void loadPropertyFile(String fileName)
throws IOException
loadPropertyFile(new File(fileName)).
IOException
public void loadPropertyFile(File file)
throws IOException
All conversion options are specified as standard Java properties.
See the setProperty method for an
option summary.
file - the property file
IOException - if an I/O error occursloadUserConfiguration
public void loadUserConfiguration()
throws IOException
The user configuration file is a standard Java property file located at user_preferences_directory/xfc.properties, where user_preferences_directory is:
IOException - if an I/O error occursloadPropertyFilepublic void setErrorHandler(ErrorHandler handler)
If no error handler is registered by an application, a default
implementation will be used. The error
method of this default handler throws an exception, while the warning method prints a warning message to the
standard error output stream.
handler - the error handlerpublic void setUriResolver(UriResolver resolver)
An application may use this method to specify a custom URI resolver
to be used for handling URIs in property values. By default URI
specifications that do not denote an absolute location are considered
relative to the input source URI, unless the option is set.
baseURL
resolver - the URI resolvergetUriResolverpublic UriResolver getUriResolver()
null if none has been
specifiedsetUriResolverpublic void setXMLReader(XMLReader reader)
An application may use this method to specify an external XML reader
(org.xml.sax.XMLReader object) to be used for the
conversion. If no XML reader is specified one is created internally.
reader - the XML readergetXMLReaderpublic XMLReader getXMLReader()
null if none has been
specifiedsetXMLReader
public void convert()
throws Exception
The input source and output destination must have been specified
first, using the setInput and setOutput
methods.
Exception - if an error occursconvert(InputSource, OutputDestination)
public void convert(InputSource input,
OutputDestination output)
throws Exception
input - the conversion input sourceoutput - the conversion output destination
Exception - if an error occursconvert()
public void error(Exception exception)
throws Exception
error in interface ErrorHandlerexception - the error information, encapsulated in an exception
Exception - if an error occurs
public void warning(Exception exception)
throws Exception
warning in interface ErrorHandlerexception - the warning information, encapsulated in an exception
Exception - if an error occurspublic static void main(String[] args)
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||