Browse Source

Conversion of web site to 0.92 release - step 2

git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/branches/fop-0_92@393470 13f79535-47bb-0310-9956-ffa450edef68
tags/fop-0_92-beta
Manuel Mall 18 years ago
parent
commit
a58e3247fb

+ 2
- 2
src/documentation/content/xdocs/0.92/anttask.xml View File

@@ -1,6 +1,6 @@
<?xml version="1.0" standalone="no"?>
<!--
Copyright 1999-2005 The Apache Software Foundation
Copyright 1999-2006 The Apache Software Foundation

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@@ -119,7 +119,7 @@
</tr>
<tr>
<td>userconfig</td>
<td>User configuration file (same as the FOP "-c" command line option). <strong>Currently doesn't work in FOP Trunk!!!</strong></td>
<td>User configuration file (same as the FOP "-c" command line option).</td>
<td>No</td>
</tr>
<tr>

+ 69
- 2
src/documentation/content/xdocs/0.92/configuration.xml View File

@@ -1,6 +1,6 @@
<?xml version="1.0" standalone="no"?>
<!--
Copyright 1999-2005 The Apache Software Foundation
Copyright 1999-2006 The Apache Software Foundation

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@@ -67,9 +67,24 @@
</tr>
<tr>
<td>base</td>
<td>URL</td>
<td>URL or directory</td>
<td>Specifies the base URL based on which relative URL will be resolved.</td>
</tr>
<tr>
<td>font-base</td>
<td>URL or directory</td>
<td>Specifies the base URL based on which relative font URLs will be resolved.
If not specified defaults to the base URL above.
</td>
</tr>
<tr>
<td>hyphenation-base</td>
<td>URL or directory</td>
<td>Specifies the base URL based on which relative URLs to hyphenation pattern
files will be resolved. If not specified, support for user-supplied hyphenation
patterns remains disabled.
</td>
</tr>
<tr>
<td>source-resolution</td>
<td>Integer, dpi</td>
@@ -132,6 +147,9 @@
<!-- Base URL for resolving relative URLs -->
<base>./</base>

<!-- Font Base URL for resolving relative font URLs -->
<font-base>./</font-base>

<!-- Source resolution in dpi (dots/pixels per inch) for determining the size of pixels in SVG and bitmap images, default: 72dpi -->
<source-resolution>72</source-resolution>
<!-- Target resolution in dpi (dots/pixels per inch) for specifying the target resolution for generated bitmaps, default: 72dpi -->
@@ -178,6 +196,55 @@
The details on the font configuration can be found on the separate <a href="fonts.html">Fonts</a> page.
Note especially the section entitled <a href="fonts.html#register">Register Fonts with FOP</a>.
</p>
<section id="pdf-renderer">
<title>Special Settings for the PDF Renderer</title>
<p>
The configuration element for the PDF renderer contains two elements. One is for the font configuration
(please follow the link above) and one is for the "filter list". The filter list controls how the
individual objects in a PDF file are encoded. By default, all objects get "flate" encoded (i.e. simply
compressed with the same algorithm that is also used in ZIP files). Most users don't need to change that
setting. For debugging purposes, it may be desired not to compress the internal objects at all so the
generated PDF commands can be read. In that case, you can simply use the following filter list. The
second filter list (type="image") ensures that all images still get compressed but also ASCII-85 encoded
so the produced PDF file is still easily readable in a text editor.
</p>
<source><![CDATA[
<renderer mime="application/pdf">
<filterList>
<value>null</value>
</filterList>
<filterList type="image">
<value>flate</value>
<value>ascii-85</value>
</filterList>
<fonts....
</renderer>]]></source>
</section>
<section id="ps-renderer">
<title>Special Settings for the PostScript Renderer</title>
<p>
Besides the normal font configuration (the same "fonts" element as for the PDF renderer) the PostScript
renderer has an additional setting to force landscape pages to be rotated to fit on a page inserted into
the printer in portrait mode. Set the value to "true" to activate this feature. The default is "false".
Example:
</p>
<source><![CDATA[
<renderer mime="application/postscript">
<auto-rotate-landscape>true</auto-rotate-landscape>
<fonts>
<font metrics-url="arial.xml" kerning="yes" embed-url="arial.ttf">
<font-triplet name="Arial" style="normal" weight="normal"/>
<font-triplet name="ArialMT" style="normal" weight="normal"/>
</font>
<font metrics-url="arialb.xml" kerning="yes" embed-url="arialb.ttf">
<font-triplet name="Arial" style="normal" weight="bold"/>
<font-triplet name="ArialMT" style="normal" weight="bold"/>
</font>
</fonts>
</renderer>]]></source>
</section>
</section>
</body>
</document>

+ 254
- 192
src/documentation/content/xdocs/0.92/embedding.xml View File

@@ -32,15 +32,23 @@
to embedded applications as well as command-line use, such as options and performance.
</p>
<p>
To embed Apache FOP in your application, instantiate org.apache.fop.apps.Fop.
You'll tell FOP in the constructor which output format (i.e. Renderer) to use.
Afterwards, you'll set the OutputStream to use to output the results of the
rendering (where applicable). You can customize FOP's behaviour by supplying
your own FOUserAgent instance. The FOUserAgent can, for example, be used to
set your own Renderer instance (details below). Finally, you retrieve a SAX
DefaultHandler instance from the Fop instance to which you can send your
FO file.
To embed Apache FOP in your application, first create a new
org.apache.fop.apps.FopFactory instance. This object can be used to launch multiple
rendering runs. For each run, create a new org.apache.fop.apps.Fop instance through
one of the factory methods of FopFactory. In the method call you specify which output
format (i.e. Renderer) to use and, if the selected renderer requires an OutputStream,
which OutputStream to use for the results of the rendering. You can customize FOP's
behaviour in a rendering run by supplying your own FOUserAgent instance. The
FOUserAgent can, for example, be used to set your own Renderer instance (details
below). Finally, you retrieve a SAX DefaultHandler instance from the Fop object and
use that as the SAXResult of your transformation.
</p>
<note>
We recently changed FOP's outer API to what we consider the final API. This might require
some changes in your application. The main reasons for these changes were performance
improvements due to better reuse of reusable objects and reduced use of static variables
for added flexibility in complex environments.
</note>
</section>
<section id="basics">
<title>Basic Usage Pattern</title>
@@ -52,32 +60,36 @@
<p>Here is the basic pattern to render an XSL-FO file to PDF:
</p>
<source><![CDATA[
import org.apache.fop.apps.FopFactory;
import org.apache.fop.apps.Fop;
import org.apache.fop.apps.MimeConstants;

/*..*/

// Step 1: Construct fop with desired output format
Fop fop = new Fop(MimeConstants.MIME_PDF);
// Step 1: Construct a FopFactory
// (reuse if you plan to render multiple documents!)
FopFactory fopFactory = FopFactory.newInstance();

// Step 2: Setup output stream.
// Step 2: Set up output stream.
// Note: Using BufferedOutputStream for performance reasons (helpful with FileOutputStreams).
OutputStream out = new BufferedOutputStream(new FileOutputStream(new File("C:/Temp/myfile.pdf")));

try {
fop.setOutputStream(out);
// Step 3: Construct fop with desired output format
Fop fop = fopFactory.newFop(MimeConstants.MIME_PDF, out);

// Step 3: Setup JAXP using identity transformer
// Step 4: Setup JAXP using identity transformer
TransformerFactory factory = TransformerFactory.newInstance();
Transformer transformer = factory.newTransformer(); // identity transformer
// Step 4: Setup input and output for XSLT transformation
// Step 5: Setup input and output for XSLT transformation
// Setup input stream
Source src = new StreamSource(new File("C:/Temp/myfile.fo"));

// Resulting SAX events (the generated FO) must be piped through to FOP
Result res = new SAXResult(fop.getDefaultHandler());
// Step 5: Start XSLT transformation and FOP processing
// Step 6: Start XSLT transformation and FOP processing
transformer.transform(src, res);

} finally {
@@ -89,16 +101,24 @@ try {
</p>
<ul>
<li>
<strong>Step 1:</strong> You create a new Fop instance and set it up for PDF
output.
<strong>Step 1:</strong> You create a new FopFactory instance. The FopFactory instance holds
references to configuration information and cached data. It's important to reuse this
instance if you plan to render multiple documents during a JVM's lifetime.
</li>
<li>
<strong>Step 2:</strong> You set up an OutputStream that the generated document
will be written to. It's a good idea to buffer the OutputStream as demonstrated
to improve performance.
</li>
<li>
<strong>Step 2:</strong> You tell FOP where to save the generated PDF file
later. It's a good idea to buffer the OutputStream as demonstrated to improve
performance.
<strong>Step 3:</strong> You create a new Fop instance through one of the factory
methods on the FopFactory. You tell the FopFactory what your desired output format
is. This is done by using the MIME type of the desired output format (ex. "application/pdf").
You can use one of the MimeConstants.* constants. The second parameter is the
OutputStream you've setup up in step 2.
</li>
<li>
<strong>Step 3:</strong> We recommend that you use JAXP Transformers even
<strong>Step 4</strong> We recommend that you use JAXP Transformers even
if you don't do XSLT transformations to generate the XSL-FO file. This way
you can always use the same basic pattern. The example here sets up an
"identity transformer" which just passes the input (Source) unchanged to the
@@ -106,7 +126,7 @@ try {
XSLT transformations.
</li>
<li>
<strong>Step 4:</strong> Here you set up the input and output for the XSLT
<strong>Step 5:</strong> Here you set up the input and output for the XSLT
transformation. The Source object is set up to load the "myfile.fo" file.
The Result is set up so the output of the XSLT transformation is sent to FOP.
The FO file is sent to FOP in the form of SAX events which is the most efficient
@@ -114,7 +134,7 @@ try {
because that affects performance negatively.
</li>
<li>
<strong>Step 5:</strong> Finally, we start the XSLT transformation by starting
<strong>Step 6:</strong> Finally, we start the XSLT transformation by starting
the JAXP Transformer. As soon as the JAXP Transformer starts to send its output
to FOP, FOP itself starts its processing in the background. When the
<code>transform()</code> method returns FOP will also have finished converting
@@ -141,11 +161,6 @@ try {
to a file to check if that part generates the expected output. An example for that
can be found in the <a href="#examples">Embedding examples</a> (See "ExampleXML2FO").
</p>
<note>
Please be aware that you should not reuse a Fop instance for additional rendering runs.
Recreate a new instance for each rendering run. This is a relatively inexpensive
operation and will be further optimized shortly.
</note>
<section id="basic-logging">
<title>Logging</title>
<p>
@@ -185,9 +200,9 @@ try {
Once the Fop instance is set up, call <code>getDefaultHandler()</code> to obtain a SAX
DefaultHandler instance to which you can send the SAX events making up the XSL-FO
document you'd like to render. FOP processing starts as soon as the DefaultHandler's
<code>startDocument()</code> methods is called. Processing stops again when the
<code>startDocument()</code> method is called. Processing stops again when the
DefaultHandler's <code>endDocument()</code> method is called. Please refer to the basic
usage pattern shown above to render a simply XSL-FO document.
usage pattern shown above to render a simple XSL-FO document.
</p>
</section>

@@ -200,10 +215,10 @@ try {
on the basic usage pattern above is to set up the Transformer differently:
</p>
<source><![CDATA[
//before (without XSLT):
//without XSLT:
//Transformer transformer = factory.newTransformer(); // identity transformer
//after (with XSLT):
//with XSLT:
Source xslt = new StreamSource(new File("mystylesheet.xsl"));
Transformer transformer = factory.newTransformer(xslt);]]></source>
</section>
@@ -211,7 +226,7 @@ try {
<section id="input">
<title>Input Sources</title>
<p>
The input XSL-FO document is always handled internally as SAX (see the
The input XSL-FO document is always received by FOP as a SAX stream (see the
<a href="../dev/design/parsing.html">Parsing Design Document</a> for the rationale).
</p>
<p>
@@ -229,19 +244,19 @@ try {
<strong>File:</strong> <code>Source src = new StreamSource(new File("C:/Temp/myinputfile.xml"));</code>
</li>
<li>
<strong>String:</strong> <code>Source src = new StreamSource(new StringReader(myString)); //myString is a String</code>
<strong>String:</strong> <code>Source src = new StreamSource(new StringReader(myString)); // myString is a String</code>
</li>
<li>
<strong>InputStream:</strong> <code>Source src = new StreamSource(new MyInputStream(something));</code>
</li>
<li>
<strong>Byte Array:</strong> <code>Source src = new StreamSource(new ByteArrayInputStream(myBuffer)); //myBuffer is a byte[] here</code>
<strong>Byte Array:</strong> <code>Source src = new StreamSource(new ByteArrayInputStream(myBuffer)); // myBuffer is a byte[] here</code>
</li>
<li>
<strong>DOM:</strong> <code>Source src = new DOMSource(myDocument); //myDocument is a Document or a Node</code>
<strong>DOM:</strong> <code>Source src = new DOMSource(myDocument); // myDocument is a Document or a Node</code>
</li>
<li>
<strong>Java Objects:</strong> Please have a look at the <a href="#examples">Embedding examples</a> which contains an example for this.
<strong>Java Objects:</strong> Please have a look at the <a href="#examples">Embedding examples</a> which contain an example for this.
</li>
</ul>
<p>
@@ -255,134 +270,176 @@ try {
<section id="config-internal">
<title>Configuring Apache FOP Programmatically</title>
<p>
Apache FOP provides a class called FOUserAgent which is used to customize FOP's
behaviour. If you wish to do that, the first step is to create your own instance
of FOUserAgent and pass that to the Fop constructor:
</p>
<source><![CDATA[
FOUserAgent userAgent = new FOUserAgent();
Fop fop = new Fop(MimeConstants.MIME_POSTSCRIPT, userAgent);]]></source>
<p>
You can do all sorts of things on the user agent:
Apache FOP provides two levels on which you can customize FOP's
behaviour: the FopFactory and the user agent.
</p>
<ul>
<li>
<p>
The <strong>base URL</strong> to use when resolving relative URLs. Example:
</p>
<source>userAgent.setBaseURL("file:///C:/Temp/");</source>
</li>
<li>
<p>
Disable <strong>strict validation</strong>. When disabled FOP is less strict about the rules established by the XSL-FO specification. Example:
</p>
<source>userAgent.setStrictValidation(false);</source>
</li>
<li>
<p>
Set the <strong>producer</strong> of the document. This is metadata information that can be used for certain output formats such as PDF. The default producer is "Apache FOP". Example:
</p>
<source>userAgent.setProducer("MyKillerApplication");</source>
</li>
<li>
<p>
Set the <strong>creating user</strong> of the document. This is metadata information that can be used for certain output formats such as PDF. Example:
</p>
<source>userAgent.setCreator("John Doe");</source>
</li>
<li>
<p>
Set the <strong>author</strong> of the document. This is metadata information that can be used for certain output formats such as PDF. Example:
</p>
<source>userAgent.setAuthor("John Doe");</source>
</li>
<li>
<p>
Override the <strong>creation date and time</strong> of the document. This is metadata information that can be used for certain output formats such as PDF. Example:
</p>
<source>userAgent.setCreationDate(new Date());</source>
</li>
<li>
<p>
Set the <strong>title</strong> of the document. This is metadata information that can be used for certain output formats such as PDF. Example:
</p>
<source>userAgent.setTitle("Invoice No 138716847");</source>
</li>
<li>
<p>
Set the <strong>keywords</strong> of the document. This is metadata information that can be used for certain output formats such as PDF. Example:
</p>
<source>userAgent.setKeywords("XML XSL-FO");</source>
</li>
<li>
<p>
Set the <strong>source resolution</strong> for the document. This is used internally to determine the pixel
size for SVG images and bitmap images without resolution information. Default: 72 dpi. Example:
</p>
<source>userAgent.setSourceResolution(96); //=96dpi (dots/pixels per Inch)</source>
</li>
<li>
<p>
Set the <strong>target resolution</strong> for the document. This is used to
specify the output resolution for bitmap images generated by bitmap renderers
(such as the TIFF renderer) and by bitmaps generated by Apache Batik for filter
effects and such. Default: 72 dpi. Example:
</p>
<source>userAgent.setTargetResolution(300); //=300dpi (dots/pixels per Inch)</source>
</li>
<li>
<p>
Set <strong>your own Renderer instance</strong>. If you want to supply your own renderer or
configure a Renderer in a special way you can give the instance to the FOUserAgent. Normally,
the Renderer instance is created by FOP. Example:
</p>
<source>userAgent.setRendererOverride(myRenderer); //myRenderer is an org.apache.fop.render.Renderer</source>
</li>
<li>
<p>
Set <strong>your own FOEventHandler instance</strong>. If you want to supply your own FOEventHandler or
configure an FOEventHandler subclass in a special way you can give the instance to the FOUserAgent. Normally,
the FOEventHandler instance is created by FOP. Example:
</p>
<source>userAgent.setFOEventHandlerOverride(myFOEventHandler); //myFOEventHandler is an org.apache.fop.fo.FOEventHandler</source>
</li>
<li>
<p>
Manually add a <strong>ElementMapping instance</strong>. If you want to supply a special FOP extension
you can give the instance to the FOUserAgent. Normally, the FOP extensions can be automatically detected
(see the documentation on extension for more info).
</p>
<source>userAgent.addElementMapping(myElementMapping); //myElementMapping is a org.apache.fop.fo.ElementMapping</source>
</li>
<li>
<p>
Set a <strong>URIResolver</strong> for custom URI resolution. By supplying a JAXP URIResolver you can add
custom URI resolution functionality to FOP. For example, you can use
<a href="ext:xml.apache.org/commons/resolver">Apache XML Commons Resolver</a> to make use of XCatalogs.
</p>
<source>userAgent.setURIResolver(myResolver); //myResolver is a javax.xml.transform.URIResolver</source>
</li>
<li>
<p>
Set the <strong>parameters for PDF encryption</strong> for the document. If you create PDF files you can
instantiate and set an org.apache.fop.pdf.PDFEncryptionParams object. Example:
</p>
<source>userAgent.setPDFEncryptionParams(new PDFEncryptionParams(null, "owner", false, false, true, true));</source>
</li>
<li>
<p>
Enable an <strong>alternative set of rules for text indents</strong> that tries to mimic the behaviour of many commercial
FO implementations that chose to break the specification in this aspect. The default of this option is
'false' which causes Apache FOP to behave exactly as describes in the specification. To enable the
alternative behaviour, call:
</p>
<source>userAgent.setBreakIndentInheritanceOnReferenceAreaBoundary(true);</source>
</li>
</ul>
<note>
You should not reuse an FOUserAgent instance between FOP rendering runs although you can. Especially
in multi-threaded environment, this is a bad idea.
</note>
<section id="fop-factory">
<title>Customizing the FopFactory</title>
<p>
The FopFactory holds configuration data and references to objects which are reusable over
multiple rendering runs. It's important to instantiate it only once (except in special
environments) and reuse it every time to create new FOUserAgent and Fop instances.
</p>
<p>
You can set all sorts of things on the FopFactory:
</p>
<ul>
<li>
<p>
The <strong>font base URL</strong> to use when resolving relative URLs for fonts. Example:
</p>
<source>fopFactory.setFontBaseURL("file:///C:/Temp/fonts");</source>
</li>
<li>
<p>
Disable <strong>strict validation</strong>. When disabled FOP is less strict about the rules
established by the XSL-FO specification. Example:
</p>
<source>fopFactory.setStrictValidation(false);</source>
</li>
<li>
<p>
Enable an <strong>alternative set of rules for text indents</strong> that tries to mimic the behaviour of many commercial
FO implementations, that chose to break the specification in this respect. The default of this option is
'false', which causes Apache FOP to behave exactly as described in the specification. To enable the
alternative behaviour, call:
</p>
<source>fopFactory.setBreakIndentInheritanceOnReferenceAreaBoundary(true);</source>
</li>
<li>
<p>
Set the <strong>source resolution</strong> for the document. This is used internally to determine the pixel
size for SVG images and bitmap images without resolution information. Default: 72 dpi. Example:
</p>
<source>fopFactory.setSourceResolution(96); // =96dpi (dots/pixels per Inch)</source>
</li>
<li>
<p>
Manually add an <strong>ElementMapping instance</strong>. If you want to supply a special FOP extension
you can give the instance to the FOUserAgent. Normally, the FOP extensions can be automatically detected
(see the documentation on extension for more info). Example:
</p>
<source>fopFactory.addElementMapping(myElementMapping); // myElementMapping is a org.apache.fop.fo.ElementMapping</source>
</li>
<li>
<p>
Set a <strong>URIResolver</strong> for custom URI resolution. By supplying a JAXP URIResolver you can add
custom URI resolution functionality to FOP. For example, you can use
<a href="ext:xml.apache.org/commons/resolver">Apache XML Commons Resolver</a> to make use of XCatalogs. Example:
</p>
<source>fopFactory.setURIResolver(myResolver); // myResolver is a javax.xml.transform.URIResolver</source>
<note>
Both the FopFactory and the FOUserAgent have a method to set a URIResolver. The URIResolver on the FopFactory
is primarily used to resolve URIs on factory-level (hyphenation patterns, for example) and it is always used
if no other URIResolver (for example on the FOUserAgent) resolved the URI first.
</note>
</li>
</ul>
</section>
<section id="user-agent">
<title>Customizing the User Agent</title>
<p>
The user agent is the entity that allows you to interact with a single rendering run, i.e. the processing of a single
document. If you wish to customize the user agent's behaviour, the first step is to create your own instance
of FOUserAgent using the appropriate factory method on FopFactory and pass that
to the factory method that will create a new Fop instance:
</p>
<source><![CDATA[
FopFactory fopFactory = FopFactory.newInstance(); // Reuse the FopFactory if possible!
// do the following for each new rendering run
FOUserAgent userAgent = fopFactory.newFOUserAgent();
// customize userAgent
Fop fop = fopFactory.newFop(MimeConstants.MIME_POSTSCRIPT, userAgent, out);]]></source>
<p>
You can do all sorts of things on the user agent:
</p>
<ul>
<li>
<p>
The <strong>base URL</strong> to use when resolving relative URLs. Example:
</p>
<source>userAgent.setBaseURL("file:///C:/Temp/");</source>
</li>
<li>
<p>
Set the <strong>producer</strong> of the document. This is metadata information that can be used for certain output formats such as PDF. The default producer is "Apache FOP". Example:
</p>
<source>userAgent.setProducer("MyKillerApplication");</source>
</li>
<li>
<p>
Set the <strong>creating user</strong> of the document. This is metadata information that can be used for certain output formats such as PDF. Example:
</p>
<source>userAgent.setCreator("John Doe");</source>
</li>
<li>
<p>
Set the <strong>author</strong> of the document. This is metadata information that can be used for certain output formats such as PDF. Example:
</p>
<source>userAgent.setAuthor("John Doe");</source>
</li>
<li>
<p>
Override the <strong>creation date and time</strong> of the document. This is metadata information that can be used for certain output formats such as PDF. Example:
</p>
<source>userAgent.setCreationDate(new Date());</source>
</li>
<li>
<p>
Set the <strong>title</strong> of the document. This is metadata information that can be used for certain output formats such as PDF. Example:
</p>
<source>userAgent.setTitle("Invoice No 138716847");</source>
</li>
<li>
<p>
Set the <strong>keywords</strong> of the document. This is metadata information that can be used for certain output formats such as PDF. Example:
</p>
<source>userAgent.setKeywords("XML XSL-FO");</source>
</li>
<li>
<p>
Set the <strong>target resolution</strong> for the document. This is used to
specify the output resolution for bitmap images generated by bitmap renderers
(such as the TIFF renderer) and by bitmaps generated by Apache Batik for filter
effects and such. Default: 72 dpi. Example:
</p>
<source>userAgent.setTargetResolution(300); // =300dpi (dots/pixels per Inch)</source>
</li>
<li>
<p>
Set <strong>your own Renderer instance</strong>. If you want to supply your own renderer or
configure a Renderer in a special way you can give the instance to the FOUserAgent. Normally,
the Renderer instance is created by FOP. Example:
</p>
<source>userAgent.setRendererOverride(myRenderer); // myRenderer is an org.apache.fop.render.Renderer</source>
</li>
<li>
<p>
Set <strong>your own FOEventHandler instance</strong>. If you want to supply your own FOEventHandler or
configure an FOEventHandler subclass in a special way you can give the instance to the FOUserAgent. Normally,
the FOEventHandler instance is created by FOP. Example:
</p>
<source>userAgent.setFOEventHandlerOverride(myFOEventHandler); // myFOEventHandler is an org.apache.fop.fo.FOEventHandler</source>
</li>
<li>
<p>
Set a <strong>URIResolver</strong> for custom URI resolution. By supplying a JAXP URIResolver you can add
custom URI resolution functionality to FOP. For example, you can use
<a href="ext:xml.apache.org/commons/resolver">Apache XML Commons Resolver</a> to make use of XCatalogs. Example:
</p>
<source>userAgent.setURIResolver(myResolver); // myResolver is a javax.xml.transform.URIResolver</source>
<note>
Both the FopFactory and the FOUserAgent have a method to set a URIResolver. The URIResolver on the FOUserAgent is
used for resolving URIs which are document-related. If it's not set or cannot resolve a URI, the URIResolver
from the FopFactory is used.
</note>
</li>
</ul>
<note>
You should not reuse an FOUserAgent instance between FOP rendering runs although you can. Especially
in multi-threaded environment, this is a bad idea.
</note>
</section>
</section>
<section id="config-external">
<title>Using a Configuration File</title>
@@ -398,7 +455,11 @@ import org.apache.avalon.framework.configuration.DefaultConfigurationBuilder;

DefaultConfigurationBuilder cfgBuilder = new DefaultConfigurationBuilder();
Configuration cfg = cfgBuilder.buildFromFile(new File("C:/Temp/mycfg.xml"));
userAgent.setUserConfig(cfg);]]></source>
fopFactory.setUserConfig(cfg);

/* ..or.. */

fopFactory.setUserConfig(new File("C:/Temp/mycfg.xml"));]]></source>
<p>
The layout of the configuration file is described on the <a href="configuration.html">Configuration page</a>.
</p>
@@ -408,11 +469,10 @@ userAgent.setUserConfig(cfg);]]></source>
<section id="object-reuse">
<title>Object reuse</title>
<p>
At the moment, the Fop instances shouldn't be reused. Please recreate
Fop and FOUserAgent instances for each rendering run until further notice.
We will likely add an additional object which will carry information
and configuration which can be reused between rendering runs to further
optimize this.
Fop instances shouldn't (and can't) be reused. Please recreate
Fop and FOUserAgent instances for each rendering run using the FopFactory.
This is a cheap operation as all reusable information is held in the
FopFactory. That's why it's so important to reuse the FopFactory instance.
</p>
</section>
<section id="awt">
@@ -439,9 +499,9 @@ userAgent.setUserConfig(cfg);]]></source>
<p>
To get the number of pages that were rendered by FOP you can call
<code>Fop.getResults()</code>. This returns a <code>FormattingResults</code> object
where you can lookup the number of pages produced. It also gives you the
where you can look up the number of pages produced. It also gives you the
page-sequences that were produced along with their id attribute and their
number of pages. This is particularly useful if you render multiple
numbers of pages. This is particularly useful if you render multiple
documents (each enclosed by a page-sequence) and have to know the number of
pages of each document.
</p>
@@ -458,16 +518,16 @@ userAgent.setUserConfig(cfg);]]></source>
(parser, XSL transformer, SQL datasource etc.).
</li>
<li>
Depending on the target OutputStream (in case of an FileOutputStream, but not
Depending on the target OutputStream (in case of a FileOutputStream, but not
for a ByteArrayOutputStream, for example) it may improve performance considerably
if you buffer the OutputStream using a BufferedOutputStream:
<code>fop.setOutputStream(new java.io.BufferedOutputStream(out));</code>
<code>out = new java.io.BufferedOutputStream(out);</code>
<br/>
Make sure you properly close the OutputStream when FOP is finished.
</li>
<li>
Cache the stylesheet. If you use the same stylesheet multiple times
you can setup a JAXP <code>Templates</code> object and reuse it each time you do
you can set up a JAXP <code>Templates</code> object and reuse it each time you do
the XSL transformation. (More information can be found
<a class="fork" href="http://www.javaworld.com/javaworld/jw-05-2003/jw-0502-xsl.html">here</a>.)
</li>
@@ -475,14 +535,18 @@ userAgent.setUserConfig(cfg);]]></source>
Use an XSLT compiler like <a class="fork" href="http://xml.apache.org/xalan-j/xsltc_usage.html">XSLTC</a>
that comes with Xalan-J.
</li>
<li>
Fine-tune your stylesheet to make the XSLT process more efficient and to create XSL-FO that can
be processed by FOP more efficiently. Less is more: Try to make use of property inheritance where possible.
</li>
</ul>
</section>
<section id="multithreading">
<title>Multithreading FOP</title>
<p>
Apache FOP may currently not be completely thread safe.
FOP uses some static variables (for example for the image cache). This code
has not been fully tested for multi-threading issues, yet.
The code has not been fully tested for multi-threading issues, yet.
If you encounter any suspicious behaviour, please notify us.
</p>
<p>
There is also a known issue with fonts being jumbled between threads when using
@@ -494,13 +558,11 @@ userAgent.setUserConfig(cfg);]]></source>
<title>Examples</title>
<p>
The directory "{fop-dir}/examples/embedding" contains several working examples.
In contrast to the examples above the examples here primarily use JAXP for
XML access. This may be easier to understand for people familiar with JAXP.
</p>
<section id="ExampleFO2PDF">
<title>ExampleFO2PDF.java</title>
<p>This
<a href="http://svn.apache.org/viewcvs.cgi/xmlgraphics/fop/tags/fop-0_92-beta/examples/embedding/java/embedding/ExampleFO2PDF.java?view=markup">
<a href="http://svn.apache.org/viewcvs.cgi/xmlgraphics/fop/trunk/examples/embedding/java/embedding/ExampleFO2PDF.java?view=markup">
example</a>
demonstrates the basic usage pattern to transform an XSL-FO
file to PDF using FOP.
@@ -510,7 +572,7 @@ file to PDF using FOP.
<section id="ExampleXML2FO">
<title>ExampleXML2FO.java</title>
<p>This
<a href="http://svn.apache.org/viewcvs.cgi/xmlgraphics/fop/tags/fop-0_92-beta/examples/embedding/java/embedding/ExampleXML2FO.java?view=markup">
<a href="http://svn.apache.org/viewcvs.cgi/xmlgraphics/fop/trunk/examples/embedding/java/embedding/ExampleXML2FO.java?view=markup">
example</a>
has nothing to do with FOP. It is there to show you how an XML
file can be converted to XSL-FO using XSLT. The JAXP API is used to do the
@@ -522,7 +584,7 @@ classpath (ex. <a href="http://xml.apache.org/xalan-j">Xalan</a>).
<section id="ExampleXML2PDF">
<title>ExampleXML2PDF.java</title>
<p>This
<a href="http://svn.apache.org/viewcvs.cgi/xmlgraphics/fop/tags/fop-0_92-beta/examples/embedding/java/embedding/ExampleXML2PDF.java?view=markup">
<a href="http://svn.apache.org/viewcvs.cgi/xmlgraphics/fop/trunk/examples/embedding/java/embedding/ExampleXML2PDF.java?view=markup">
example</a>
demonstrates how you can convert an arbitrary XML file to PDF
using XSLT and XSL-FO/FOP. It is a combination of the first two examples
@@ -542,13 +604,13 @@ performance is significantly higher with SAX.
<section id="ExampleObj2XML">
<title>ExampleObj2XML.java</title>
<p>This
<a href="http://svn.apache.org/viewcvs.cgi/xmlgraphics/fop/tags/fop-0_92-beta/examples/embedding/java/embedding/ExampleObj2XML.java?view=markup">
<a href="http://svn.apache.org/viewcvs.cgi/xmlgraphics/fop/trunk/examples/embedding/java/embedding/ExampleObj2XML.java?view=markup">
example</a>
is a preparatory example for the next one. It's an example that
shows how an arbitrary Java object can be converted to XML. It's an often
needed task to do this. Often people create a DOM tree from a Java object and
use that. This is pretty straightforward. The example here however shows how
to do this using SAX which will probably be faster and not even more
use that. This is pretty straightforward. The example here, however, shows how
to do this using SAX, which will probably be faster and not even more
complicated once you know how this works.
</p>
<figure src="images/EmbeddingExampleObj2XML.png" alt="Example Java object to XML"/>
@@ -556,13 +618,13 @@ complicated once you know how this works.
For this example we've created two classes: ProjectTeam and ProjectMember
(found in xml-fop/examples/embedding/java/embedding/model). They represent
the same data structure found in
xml-fop/examples/embedding/xml/xml/projectteam.xml. We want to serialize a
project team with several members which exist as Java objects to XML.
xml-fop/examples/embedding/xml/xml/projectteam.xml. We want to serialize to XML a
project team with several members which exist as Java objects.
Therefore we created the two classes: ProjectTeamInputSource and
ProjectTeamXMLReader (in the same place as ProjectTeam above).
</p>
<p>
The XMLReader implementation (regard it as a special kind of XML parser)is
The XMLReader implementation (regard it as a special kind of XML parser) is
responsible for creating SAX events from the Java object. The InputSource
class is only used to hold the ProjectTeam object to be used.
</p>
@@ -575,7 +637,7 @@ used. For more detailed information see other resources on JAXP (ex.
<section id="ExampleObj2PDF">
<title>ExampleObj2PDF.java</title>
<p>This
<a href="http://svn.apache.org/viewcvs.cgi/xmlgraphics/fop/tags/fop-0_92-beta/examples/embedding/java/embedding/ExampleObj2PDF.java?view=markup">
<a href="http://svn.apache.org/viewcvs.cgi/xmlgraphics/fop/trunk/examples/embedding/java/embedding/ExampleObj2PDF.java?view=markup">
example</a>
combines the previous and the third to demonstrate
how you can transform a Java object to a PDF directly in one smooth run
@@ -588,7 +650,7 @@ using FOP as before.
<section id="ExampleDOM2PDF">
<title>ExampleDOM2PDF.java</title>
<p>This
<a href="http://svn.apache.org/viewcvs.cgi/xmlgraphics/fop/tags/fop-0_92-beta/examples/embedding/java/embedding/ExampleDOM2PDF.java?view=markup">
<a href="http://svn.apache.org/viewcvs.cgi/xmlgraphics/fop/trunk/examples/embedding/java/embedding/ExampleDOM2PDF.java?view=markup">
example</a>
has FOP use a DOMSource instead of a StreamSource in order to
use a DOM tree as input for an XSL transformation.
@@ -597,9 +659,9 @@ use a DOM tree as input for an XSL transformation.
<section id="ExampleSVG2PDF">
<title>ExampleSVG2PDF.java (PDF Transcoder example)</title>
<p>This
<a href="http://svn.apache.org/viewcvs.cgi/xmlgraphics/fop/tags/fop-0_92-beta/examples/embedding/java/embedding/ExampleSVG2PDF.java?view=markup">
<a href="http://svn.apache.org/viewcvs.cgi/xmlgraphics/fop/trunk/examples/embedding/java/embedding/ExampleSVG2PDF.java?view=markup">
example</a>
shows use of the PDF Transcoder, a sub-application within FOP.
shows the usage of the PDF Transcoder, a sub-application within FOP.
It is used to generate a PDF document from an SVG file.
</p>
</section>

+ 41
- 11
src/documentation/content/xdocs/0.92/fonts.xml View File

@@ -1,6 +1,6 @@
<?xml version="1.0" standalone="no"?>
<!--
Copyright 1999-2005 The Apache Software Foundation
Copyright 1999-2006 The Apache Software Foundation

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@@ -208,16 +208,18 @@ will produce incorrect results.</td>
<tr>
<td>Character Display</td>
<td>Correct.</td>
<td>Correct if and only if the font is embedded in the output. (This is possible
because, although the underlying characters are encoded incorrectly, the embedded font is
also encoded incorrectly).</td>
<td>Correct, but copy/paste won't work in Acrobat Reader. (FOP currently doesn't emit the /ToUnicode table which is necessary for copy/paste to work.)</td>
</tr>
<tr>
<td>Embedding the Font</td>
<td>Optional.</td>
<td>Mandatory. Not embedding the font produces invalid PDF documents.</td>
</tr>
</table>
<warning id="cid-keyed-encoding-ttf">As shown in the above table, regardless of
whether the font is embedded or not, text generated from a CID-keyed font metrics file
will <em>never </em>be encoded properly.
Further, if the related font is not embedded, it cannot even be displayed properly.
Obviously, this behavior is not desirable, and we hope to correct it in upcoming releases.</warning>
<warning>
You may experience failures with certain TrueType fonts, especially if they don't contain
the so-called "cmap" table. TTFReader can currently not deal with font like this.
</warning>
</section>
<section id="truetype-collections-metrics">
<title>TrueType Collections Font Metrics</title>
@@ -241,9 +243,8 @@ It will display all of the font names and exit with an Exception.</p>
<ul>
<li>
URLs are used to access the font metric and font files.
<!--Relative URLs are resolved relative to the fontBaseDir property (or baseDir) if available.-->
Relative URLs are resolved relative to the font-base property (or base) if available.
See <a href="configuration.html">FOP: Configuration</a> for more information.
<note>Relative font URLs are currently not possible. You need to specify absolute URLs. Patches are welcome! :-)</note>
</li>
<li>The "kerning" and "embed-url" attributes are optional. Kerning is currently not used at all. If embedding is off, the output will position the text correctly (from the metrics file), but it will not be displayed or printed correctly unless the viewer has the applicable font available to their local system.</li>
<li>When setting the embed-url attribute for Type 1 fonts, be sure to specify the PFB (actual font data), not PFM (font metrics) file that you used to generate the XML font metrics file.</li>
@@ -256,6 +257,11 @@ It will display all of the font names and exit with an Exception.</p>
<note>The font is simply embedded into the PDF file, it is not converted.</note>
<p>Font embedding is enabled in the userconfig.xml file and controlled by the embed-url attribute.
If you don't specify the embed-url attribute the font will not be embedded, but will only be referenced.</p>
<warning>
Omitting the embed-url attribute for CID-encoded TrueType fonts will currently produce invalid
PDF files! If you create the XML font metric file using the "-enc ansi" option, you can omit
the embed-url attribute for TrueType fonts but you're restricted to the WinAnsi character set.
</warning>
<p>When FOP embeds a font, it adds a prefix to the fontname to ensure that the name will not match the fontname of an installed font.
This is helpful with older versions of Acrobat Reader that preferred installed fonts over embedded fonts.</p>
<p>When embedding PostScript fonts, the entire font is always embedded.</p>
@@ -268,6 +274,30 @@ This will cause the whole font to be embedded in the pdf document.
Characters will be WinAnsi encoded (as specified in the PDF spec), so you lose the ability to use characters from other character sets.
See <a href="#ttf-encoding">Table of TTF Encoding Options</a> for more details.</p>
</section>
<section id="embedding-base14">
<title>Explicitely embedding the base 14 fonts</title>
<p>
There are cases where you might want to force the embedding of one or more of the base 14 fonts that
can normally be considered available on the target platform (viewer, printer). One of these cases is
PDF/A which mandates the embedding of even the base 14 fonts. Embedding a font such as Helvetica or
Courier is straight-forward. The "Symbol" and "ZapfDingbats" fonts, however, currently present a
problem because FOP cannot correctly determine the encoding of these two single-byte fonts through
the PFM file. FOP now correctly interprets the "encoding" value in the XML font metrics file, but the
PFMReader application writes "UnknownEncoding" to the generated XML file. In order to embed "Symbol"
and "ZapfDingbats" you have to manually change the XML font metrics file and specify "SymbolEncoding"
or "ZapfdingbatsEncoding" encoding respectively as the value for the "encoding" element.
</p>
<p>Example:</p>
<source><![CDATA[
<?xml version="1.0" encoding="UTF-8"?>
<font-metrics type="TYPE1">
<font-name>Symbol</font-name>
<embed/>
<encoding>SymbolEncoding</encoding>
<cap-height>673</cap-height>
<x-height>766</x-height>
[..]]]></source>
</section>
</section>
</body>
</document>

+ 1
- 1
src/documentation/content/xdocs/0.92/hyphenation.xml View File

@@ -113,7 +113,7 @@
be created from the supplied pattern(s)).</li>
<li>Put the pattern source file(s) into a directory of your choice and
configure FOP to look for custom patterns in this directory, by setting the
<a href="configuration.html#hyphenation-dir">&lt;hyphenation-dir&gt;</a>
<a href="configuration.html">&lt;hyphenation-base&gt;</a>
configuration option.</li>
</ul>
</li>

+ 145
- 0
src/documentation/content/xdocs/0.92/intermediate.xml View File

@@ -0,0 +1,145 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright 2006 The Apache Software Foundation

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<!-- $Id$ -->
<!DOCTYPE document PUBLIC "-//APACHE//DTD Documentation V2.0//EN" "http://forrest.apache.org/dtd/document-v20.dtd">
<document>
<header>
<title>Intermediate Format</title>
<version>$Revision$</version>
</header>
<body>
<note>
Please note that the intermediate format is an <strong>advanced feature</strong> and can be ignored by most
users of Apache FOP.
</note>
<section id="introduction">
<title>Introduction</title>
<p>
The intermediate format (IF) is a proprietary XML format that represents the area tree
generated by the layout engine. The area tree is conceptually defined in the
<a href="http://www.w3.org/TR/xsl/slice1.html#section-N742-Formatting">XSL-FO specification in chapter 1.1.2</a>.
The IF can be generated through the area tree XML Renderer (the XMLRenderer).
</p>
<p>
The intermediate format can be used to generate intermediate documents that are modified
before they are finally rendered to their ultimate output format. Modifications include
adjusting and changing trait values, adding or modifying area objects, inserting prefabricated
pages, overlays, imposition (n-up, rotation, scaling etc.). Multiple IF files can be combined
to a single output file.
</p>
</section>
<section id="usage">
<title>Usage of the Intermediate Format</title>
<p>
As already mentioned, the IF is generated by using the <strong>XMLRenderer</strong> (MIME type:
<strong>application/X-fop-areatree</strong>). So, you basically set the right MIME type for
the output format and process your FO files as if you would create a PDF file. However, there
is an important detail to consider: The various Renderers don't all use the same font sources.
To be able to create the right area tree for the ultimate output file, you need to create
the IF file using the right font setup. This is achieved by telling the XMLRenderer to mimic
another renderer. This is done by calling the XMLRenderer's mimicRenderer() method with an
instance of the ultimate target renderer as the single parameter. This has a consequence: An
IF file rendered with the Java2DRenderer may not look as expected when it was actually generated
for the PDF renderer. For renderers that use the same font setup, this restriction does not
apply (PDF and PS, for example). Generating the intermediate format file is the first step.
</p>
<p>
The second step is to reparse the IF file using the <strong>AreaTreeParser</strong> which is
found in the org.apache.fop.area package. The pages retrieved from the IF file are added to an
AreaTreeModel instance from where they are normally rendered using one of the available Renderer
implementations. You can find examples for the IF processing in the
<a href="http://svn.apache.org/viewcvs.cgi/xmlgraphics/fop/trunk/examples/embedding/java/embedding/intermediate/"><code>examples/embedding</code></a>
directory in the FOP distribution
</p>
<p>
The basic pattern to parse the IF format looks like this:
</p>
<source><![CDATA[
FopFactory fopFactory = FopFactory.newInstance();
// Setup output
OutputStream out = new java.io.FileOutputStream(pdffile);
out = new java.io.BufferedOutputStream(out);
try {
//Setup fonts and user agent
FontInfo fontInfo = new FontInfo();
FOUserAgent userAgent = fopFactory.newFOUserAgent();

//Construct the AreaTreeModel that will received the individual pages
AreaTreeModel treeModel = new RenderPagesModel(userAgent,
MimeConstants.MIME_PDF, fontInfo, out);
//Parse the IF file into the area tree
AreaTreeParser parser = new AreaTreeParser();
Source src = new StreamSource(myIFFile);
parser.parse(src, treeModel, userAgent);
//Signal the end of the processing. The renderer can finalize the target document.
treeModel.endDocument();
} finally {
out.close();
}]]></source>
<p>
This example simply reads an IF file and renders it to a PDF file. Please note, that in normal
FOP operation you're shielded from having to instantiate the FontInfo object yourself. This
is normally a task of the AreaTreeHandler which is not present in this scenario. The same
applies to the AreaTreeModel instance, in this case an instance of a subclass called
RenderPagesModel. RenderPagesModel is ideal in this case as it has very little overhead
processing the individual pages. An important line in the example is the call to
<code>endDocument()</code> on the AreaTreeModel. This lets the Renderer know that the processing
is now finished.
</p>
<p>
The intermediate format can also be used from the <a href="running.html#standalone-start">command-line</a>
by using the "-atin" parameter for specifying the area tree XML as input file. You can also
specify a "mimic renderer" by inserting a MIME type between "-at" and the output file.
</p>
<section id="concat">
<title>Concatenating Documents</title>
<p>
This initial example is obviously not very useful. It would be faster to create the PDF file
directly. As the <a href="http://svn.apache.org/repos/asf/xmlgraphics/fop/trunk/examples/embedding/java/embedding/intermediate/ExampleConcat.java">ExampleConcat.java</a>
example shows you can easily parse multiple IF files in a row and add the parsed pages to the
same AreaTreeModel instance which essentially concatenates all the input document to one single
output document.
</p>
</section>
<section id="modifying">
<title>Modifying Documents</title>
<p>
One of the most important use cases for the intermediate format is obviously modifying the area
tree XML before finally rendering it to the target format. You can easily use XSLT to process
the IF file according to your needs. Please note, that we will currently not formally describe
the intermediate format. You need to have a good understanding its structure so you don't
create any non-parseable files. We may add an XML Schema and more detailed documentation at a
later time. You're invited to help us with that.
</p>
</section>
<section id="advanced">
<title>Advanced Use</title>
<p>
The generation of the intermediate format as well as it parsing process has been designed to allow
for maximum flexibility and optimization. Please note that you can call <code>setTransformerHandler()</code> on
XMLRenderer to give the XMLRenderer your own TransformerHandler instance in case you would like to
do custom serialization (to a W3C DOM, for example) and/or to directly modify the area tree using
XSLT. The AreaTreeParser on the other side allows you to retrieve a ContentHandler instance where
you can manually send SAX events to to start the parsing process (see <code>getContentHandler()</code>).
</p>
</section>
</section>
</body>
</document>

+ 37
- 15
src/documentation/content/xdocs/0.92/output.xml View File

@@ -1,6 +1,6 @@
<?xml version="1.0" standalone="no"?>
<!--
Copyright 1999-2005 The Apache Software Foundation
Copyright 1999-2006 The Apache Software Foundation

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@@ -67,8 +67,8 @@
<source><![CDATA[proc = Runtime.getRuntime().exec("lp -d" + print_queue + " -o -dp -");
out = proc.getOutputStream();]]></source>
<p>
Set the OutputStream (out) to the PCLRenderer and it happily sends the
PCL to the UNIX printer queue.
Set the output MIME type to "application/x-pcl" (MimeConstants.MIME_PCL) and
it happily sends the PCL to the UNIX printer queue.
</p>
</section>
</section>
@@ -83,12 +83,13 @@ out = proc.getOutputStream();]]></source>
compatible.
</p>
<p>
Note that FOP does not currently support "tagged PDF", PDF/X or PDF/A.
Note that FOP does not currently support "tagged PDF", PDF/X or PDF/A-1a.
<a href="pdfa.html">Support for PDF/A-1b</a> has recently been added, however.
</p>
<section id="pdf-fonts">
<title>Fonts</title>
<p>
PDF has a set of fonts that are always available to all PDF viewers,
PDF has a set of fonts that are always available to all PDF viewers;
to quote from the PDF Specification:

<em>"PDF prescribes a set of 14 standard fonts that can be used without prior
@@ -125,8 +126,8 @@ out = proc.getOutputStream();]]></source>
try {
ByteArrayOutputStream fopout = new ByteArrayOutputStream();
FileOutputStream outfile = new FileOutputStream(args[2]);
Fop fop = new Fop(MimeConstants.MIME_PDF);
fop.setOutputStream(fopout);
FopFactory fopFactory = FopFactory.newInstance();
Fop fop = fopFactory.newFop(MimeConstants.MIME_PDF, fopout);
Transformer transformer = TransformerFactory.newInstance().newTransformer(
new StreamSource(new File(args[1])));
@@ -201,11 +202,10 @@ out = proc.getOutputStream();]]></source>
<section id="ps-limitations">
<title>Limitations</title>
<ul>
<li>Images and SVG may not be display correctly. SVG support is far from being complete. No image transparency is available.</li>
<li>Images and SVG may not be displayed correctly. SVG support is far from being complete. No image transparency is available.</li>
<li>Only Type 1 fonts are supported.</li>
<li>Multibyte characters are not supported.</li>
<li>PPD support is still missing.</li>
<li>The renderer is not yet configurable.</li>
</ul>
</section>
</section>
@@ -222,9 +222,13 @@ out = proc.getOutputStream();]]></source>
<section id="xml">
<title>XML (Area Tree XML)</title>
<p>
This is for testing and verification. The XML created is simply
a representation of the internal area tree put into XML. It does
not perform any other purpose.
This is primarily for testing and verification. The XML created is simply
a representation of the internal area tree put into XML. We use that to verify
the functionality of FOP's layout engine.
</p>
<p>
The other use case of the Area Tree XML is as FOP's "intermediate format". More information
on that can be found on the page dedicated to the <a href="intermediate.html">Intermediate Format</a>.
</p>
</section>
<section id="awt">
@@ -364,14 +368,32 @@ out = proc.getOutputStream();]]></source>
This format creates an SVG document that has links between the pages.
This is primarily for slides and creating svg images of pages.
Large documents will create SVG files that are far too large for
and SVG viewer to handle. Since FO documents usually have text the
an SVG viewer to handle. Since FO documents usually have text the
SVG document will have a large number of text elements.
The font information for the text is obtained from the JVM in the
same way as the AWT viewer, if the SVG is view where the fonts are
different, such as another platform, then the page may appear wrong.
same way as for the AWT viewer. If the SVG is viewed on a
system where the fonts are different, such as another platform,
then the page may look wrong.
</p>
</section>
</section>
<section id="wishlist">
<title>Wish list</title>
<p>
Apache FOP is easily extensible and allows you to add new output formats to enhance FOP's functionality. There's a number of output formats
which are on our wish list. We're looking for volunteers to help us implement them.
</p>
<ul>
<li>
<a href="http://en.wikipedia.org/wiki/Advanced_Function_Presentation">AFP (Advanced Function Presentation)</a>:
The renderer has already been built and is in the process of being brought into the Apache FOP codebase.
</li>
<li>
<a href="http://en.wikipedia.org/wiki/OpenDocument">ODF (Open Document Format)</a>:
The standardized successor to OpenOffice's file format.
</li>
</ul>
</section>

</body>
</document>

+ 132
- 0
src/documentation/content/xdocs/0.92/pdfa.xml View File

@@ -0,0 +1,132 @@
<?xml version="1.0" standalone="no"?>
<!--
Copyright 2006 The Apache Software Foundation

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<!-- $Id$ -->
<!DOCTYPE document PUBLIC "-//APACHE//DTD Documentation V2.0//EN" "document-v20.dtd">
<document>
<header>
<title>PDF/A (ISO 19005)</title>
<version>$Revision: 389563 $</version>
<authors>
<person name="Jeremias Märki" email="jeremias@apache.org"/>
</authors>
</header>
<body>
<section id="overview">
<title>Overview</title>
<warning>
Support for PDF/A is available beginning with version 0.92.
</warning>
<p>
PDF/A is a standard which turns PDF into an "electronic document file
format for long-term preservation". PDF/A-1 is the first part of the
standard and is documented in
<a href="http://www.iso.org/iso/en/CatalogueDetailPage.CatalogueDetail?CSNUMBER=38920&amp;ICS1=37&amp;ICS2=100&amp;ICS3=99">ISO 19005-1:2005(E)</a>.
Work on PDF/A-2 is in progress at
<a href="http://www.aiim.org/standards.asp?ID=25013">AIIM</a>.
</p>
<p>
Design documentation on PDF/A can be found on FOP's Wiki on the
<a href="http://wiki.apache.org/xmlgraphics-fop/PDFA1ConformanceNotes">PDFA1ConformanceNotes</a> page.
</p>
</section>
<section id="status">
<title>Implementation Status</title>
<p>
<strong>PDF/A-1b</strong> is implemented to the degree that FOP supports
the creation of the elements described in ISO 19005-1.
</p>
<p>
There is a restriction with
XMP metadata. If an XMP metadata packet is present in the fo:declarations
element of an FO file, the values from the XMP packet are not synchronized
with the Info PDF object as is mandated by chapter 6.7.3 of the ISO document.
However, if no XMP packet is supplied FOP automatically generates an XMP
packet from the values in the Info PDF object.
</p>
<p>
Tests have been performed against jHove and Adobe Acrobat 7.0.7 (Preflight function).
</p>
<p>
<strong>PDF/A-1a</strong> is not implemented, yet. This is mostly because of the requirement
for tagged PDF which is not available in FOP, yet.
</p>
</section>
<section id="command-line">
<title>Usage (command line)</title>
<p>
If you specify "-pdfa1b" instead of "-pdf" for the output format on the
command line, support for PDF/A-1b is activated. If there is a violation of
one of the validation rules for PDF/A, an error message is presented and the
processing stops.
</p>
</section>
<section id="embedded">
<title>Usage (embedded)</title>
<p>
When FOP is embedded in another Java application you can set a special option
on the renderer options in the user agent to activate the PDF/A-1b profile.
Here's an example:
</p>
<source><![CDATA[
FOUserAgent userAgent = fopFactory.newFOUserAgent();
userAgent.getRendererOptions().put("pdf-a-mode", "PDF/A-1b");
Fop fop = fopFactory.newFop(MimeConstants.MIME_PDF, userAgent);
[..]]]></source>
<p>
If one of the validation rules of PDF/A is violated, an PDFConformanceException
(descendant of RuntimeException) is thrown.
</p>
</section>
<section id="rules">
<title>PDF/A in Action</title>
<p>
There are a number of things that must be looked after if you activate a PDF/A
profile. If you receive a PDFConformanceException, have a look at the following
list (not necessarily comprehensive):
</p>
<ul>
<li>
Make sure all (!) fonts are embedded. If you use base 14 fonts (like Helvetica)
you need to obtain a license for them and embed them like any other font.
</li>
<li>
Don't use PDF encryption. PDF/A doesn't allow it.
</li>
<li>
Don't use CMYK images without an ICC color profile. PDF/A doesn't allow mixing
color spaces and FOP currently only properly supports the sRGB color space. Please
note that FOP embeds a standard sRGB ICC profile (sRGB IEC61966-2.1) as the
primary output intent for the PDF.
</li>
<li>
Don't use non-RGB colors in SVG images. Same issue as with CMYK images.
</li>
<li>
Don't use EPS graphics with fo:external-graphic. Embedding EPS graphics in PDF
is deprecated since PDF 1.4 and prohibited by PDF/A.
</li>
<li>
PDF is forced to version 1.4 if PDF/A-1 is activated.
</li>
<li>
No filter must be specified explicitely for metadata objects. Metadata must be
embedded in clear text so non-PDF-aware applications can extract the XMP metadata.
</li>
</ul>
</section>
</body>
</document>

+ 17
- 5
src/documentation/content/xdocs/0.92/pdfencryption.xml View File

@@ -1,6 +1,6 @@
<?xml version="1.0" standalone="no"?>
<!--
Copyright 1999-2005 The Apache Software Foundation
Copyright 1999-2006 The Apache Software Foundation

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@@ -139,11 +139,11 @@ import org.apache.fop.pdf.PDFEncryptionParams;

[..]

FOUserAgent userAgent = new FOUserAgent();
useragent.setPDFEncryptionParams(new PDFEncryptionParams(
FOUserAgent userAgent = fopFactory.newFOUserAgent();
useragent.getRendererOptions().put("encryption-params", new PDFEncryptionParams(
null, "password", false, false, true, true));
Fop fop = new Fop(MimeConstants.MIME_PDF, userAgent);
driver.setOutputStream(...]]></source>
Fop fop = fopFactory.newFop(MimeConstants.MIME_PDF, userAgent);
[..]]]></source>
<p>
The parameters for the constructor of PDFEncryptionParams are:
</p>
@@ -155,6 +155,18 @@ driver.setOutputStream(...]]></source>
<li>allowEditContent: true if editing content is allowed</li>
<li>allowEditAnnotations: true if editing annotations is allowed</li>
</ol>
<p>
Alternatively, you can set each value separately in the Map provided by
FOUserAgent.getRendererOptions() by using the following keys:
</p>
<ol>
<li>user-password: String</li>
<li>owner-password: String</li>
<li>noprint: Boolean or "true"/"false"</li>
<li>nocopy: Boolean or "true"/"false"</li>
<li>noedit: Boolean or "true"/"false"</li>
<li>noannotations: Boolean or "true"/"false"</li>
</ol>
</section>
<section>
<title>Environment</title>

+ 4
- 2
src/documentation/content/xdocs/0.92/running.xml View File

@@ -128,7 +128,7 @@ Fop [options] [-fo|-xml] infile [-xsl file] [-awt|-pdf|-mif|-rtf|-tiff|-png|-pcl
-fo infile xsl:fo input file
-xml infile xml input file, must be used together with -xsl
-xsl stylesheet xslt stylesheet
-atin infile area tree input file
-param name value <value> to use for parameter <name> in xslt stylesheet
(repeat '-param name value' for each parameter)

@@ -144,7 +144,9 @@ Fop [options] [-fo|-xml] infile [-xsl file] [-awt|-pdf|-mif|-rtf|-tiff|-png|-pcl
-ps outfile input will be rendered as PostScript file (outfile req'd)
-txt outfile input will be rendered as text file (outfile req'd)
-svg outfile input will be rendered as an svg slides file (outfile req'd)
-at outfile representation of area tree as XML (outfile req'd)
-at [mime] out representation of area tree as XML (outfile req'd)
specify optional mime output to allow AT to be converted
to final format later
-print input file will be rendered and sent to the printer
see options with "-print help"
-out mime outfile input will be rendered using the given MIME type

+ 22
- 18
src/documentation/content/xdocs/0.92/servlets.xml View File

@@ -1,6 +1,6 @@
<?xml version="1.0" standalone="no"?>
<!--
Copyright 1999-2005 The Apache Software Foundation
Copyright 1999-2006 The Apache Software Foundation

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@@ -46,6 +46,11 @@
</ul>
<p/>
<p>The source code for the servlet can be found under {fop-dir}/src/java/org/apache/fop/servlet/FopServlet.java.</p>
<note>
This example servlet should not be used on a public web server connected to the Internet as it does not contain
any measures to prevent Denial-of-Service-Attacks. It is provided as an example and as a starting point for
your own servlet.
</note>
</section>
<section id="servlet">
<title>Create your own Servlet</title>
@@ -57,14 +62,15 @@
<p>
Here is a minimal code snippet to demonstrate the basics:
</p>
<source>public void doGet(HttpServletRequest request,
<source>private FopFactory fopFactory = FopFactory.newInstance();
private TransformerFactory tFactory = TransformerFactory.newInstance();
public void doGet(HttpServletRequest request,
HttpServletResponse response) throws ServletException {
try {
response.setContentType("application/pdf");
Fop fop = new Fop(MimeConstants.MIME_PDF);
fop.setOutputStream(response.getOutputStream());
TransformerFactory factory = TransformerFactory.newInstance();
Transformer transformer = factory.newTransformer();
Fop fop = fopFactory.newFop(MimeConstants.MIME_PDF, response.getOutputStream());
Transformer transformer = tFactory.newTransformer();
Source src = new StreamSource("foo.fo");
Result res = new SAXResult(fop.getDefaultHandler());
transformer.transform(src, res);
@@ -81,30 +87,29 @@
<section id="xslt">
<title>Adding XSL tranformation (XSLT)</title>
<p>
A common requirement is the to transform an XML source to
A common requirement is to transform an XML source to
XSL-FO using an XSL transformation. It is recommended to use
JAXP for this task. The following snippet shows the basic
code:
</p>
<source>
protected TransformerFactory transformerFactory;
<source>private FopFactory fopFactory = FopFactory.newInstance();
private TransformerFactory tFactory = TransformerFactory.newInstance();

public void init() throws ServletException {
this.transformerFactory = TransformerFactory.newInstance();
//Optionally customize the FopFactory and TransformerFactory here
}

[..]

//Setup FOP
Fop fop = new Fop(MimeConstants.MIME_PDF);

//Setup a buffer to obtain the content length
ByteArrayOutputStream out = new ByteArrayOutputStream();
fop.setOutputStream(out);

//Setup FOP
Fop fop = fopFactory.newFop(MimeConstants.MIME_PDF, out);

//Setup Transformer
Source xsltSrc = new StreamSource(new File("foo-xml2fo.xsl"));
Transformer transformer = this.transformerFactory.newTransformer(xsltSrc);
Transformer transformer = tFactory.newTransformer(xsltSrc);

//Make sure the XSL transformation's result is piped through to FOP
Result res = new SAXResult(fop.getDefaultHandler());
@@ -138,7 +143,7 @@ public void init() throws ServletException {
</p>
<p>
Because you have an explicit <code>Transformer</code> object, you can also use it to
explicitly set parameters for the transformation run.
explicitely set parameters for the transformation run.
</p>
</section>
<section id="cfg">
@@ -251,5 +256,4 @@ public void init() throws ServletException {
</p>
</section>
</body>
</document>
<!-- Last Line of $RCSfile$ -->
</document>

+ 9
- 9
src/documentation/content/xdocs/0.92/upgrading.xml View File

@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright 2005 The Apache Software Foundation
Copyright 2005-2006 The Apache Software Foundation

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@@ -31,13 +31,17 @@
<ul>
<li>
More than half of the codebase has been rewritten over the last three years. The code is
relatively new and possibly not as stable as version 0.20.5 in every regard.
relatively new and possibly not as stable as version 0.20.5 in every regard. But the code
is <strong>quickly approaching production level</strong>, especially when you're happy
with only PDF and PostScript output.
</li>
<li>
The API of FOP has changed considerably and is not backwards-compatible with version 0.20.5.
</li>
<li>
The new API is not stable, yet. Please be aware that further changes might still occur!
There have been changes to the end-user API between 0.91 beta and 0.92 beta. With version 0.92,
the API is now considered stable. Some methods have been deprecated and will be removed with
the next release. If you upgrade from 0.91 beta, you will need to adjust your Java code.
</li>
<li>
<p>
@@ -64,14 +68,10 @@
</li>
<li>
By looking at the <a href="../compliance.html">Compliance page</a> you might get the impression
that the new code is much more advanced than version 0.20.5. That's true but there are still
a few things that may not be handled as gracefully by the new code as by version 0.20.5.
that the new code is much more advanced than version 0.20.5. That's true but there may still
be a few things that may not be handled as gracefully by the new code as by version 0.20.5.
</li>
</ul>
<p>
So, please evaluate carefully before messing up your production environment! Actually we do
recommend against using the FOP development version in a production system.
</p>
</section>
<section id="issues">
<title>What you need to know when you upgrade!</title>

+ 2
- 0
src/documentation/content/xdocs/site.xml View File

@@ -102,7 +102,9 @@

<features label="Features">
<output label="Output Targets" href="output.html"/>
<if label="Intermediate Format" href="intermediate.html"/>
<pdfencryption label="PDF Encryption" href="pdfencryption.html"/>
<pdfa label="PDF/A" href="pdfa.html"/>
<graphics label="Graphics" href="graphics.html"/>
<fonts label="Fonts" href="fonts.html"/>
<hyphenation label="Hyphenation" href="hyphenation.html"/>

Loading…
Cancel
Save