aboutsummaryrefslogtreecommitdiffstats
path: root/src/documentation/content/xdocs/trunk/graphics.xml
blob: 9f56f05262803b187d5fff3b87f8b843b2c594c5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
<?xml version="1.0" standalone="no"?>
<!--
  Licensed to the Apache Software Foundation (ASF) under one or more
  contributor license agreements.  See the NOTICE file distributed with
  this work for additional information regarding copyright ownership.
  The ASF licenses this file to You 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>Apache FOP: Graphics Formats</title>
    <version>$Revision$</version>
  </header>
  <body>
    <section id="support-overview">
      <title>Overview of Graphics Support</title>
      <p>
        The table below summarizes the <em>theoretical</em> support for graphical formats within FOP. In other words, within the constraints of the limitations listed here, these formats <em>should</em> work. However, many of them have not been tested, and there may be limitations that have not yet been discovered or documented. The packages needed to support some formats are not included in the FOP distribution and must be installed separately. Follow the links in the "Support Thru" column for more details.
      </p>
      <table>
        <tr>
          <th>Format</th>
          <th>Type</th>
          <th><a href="#native">FOP native support</a></th>
          <th><a href="#batik">Batik SVG</a></th>
          <th><a href="#batik-codecs">Batik codecs</a></th>
          <th><a href="#imageio">Image I/O</a></th>
          <th><a href="#jai">JAI</a></th>
          <th><a href="#jimi">JIMI</a></th>
        </tr>
        <tr>
          <td><a href="#bmp">BMP</a> (Microsoft Windows Bitmap)</td>
          <td>bitmap</td>
          <td>X</td>
          <td></td>
          <td></td>
          <td></td>
          <td></td>
          <td></td>
        </tr>
        <tr>
          <td><a href="#eps">EPS</a> (Encapsulated PostScript)</td>
          <td>metafile (both bitmap and vector), probably most frequently used for vector drawings</td>
          <td>(X)</td>
          <td></td>
          <td></td>
          <td></td>
          <td></td>
          <td></td>
        </tr>
        <tr>
          <td>GIF (Graphics Interchange Format)</td>
          <td>bitmap</td>
          <td>X</td>
          <td></td>
          <td></td>
          <td>X</td>
          <td>X</td>
          <td>X</td>
        </tr>
        <tr>
          <td><a href="#jpeg">JPEG</a> (Joint Photographic Experts Group)</td>
          <td>bitmap</td>
          <td>(X)</td>
          <td></td>
          <td></td>
          <td></td>
          <td></td>
          <td></td>
        </tr>
        <tr>
          <td><a href="#png">PNG</a> (Portable Network Graphic)</td>
          <td>bitmap</td>
          <td></td>
          <td></td>
          <td>X</td>
          <td></td>
          <td></td>
          <td></td>
        </tr>
        <tr>
          <td><a href="#svg">SVG</a> (Scalable Vector Graphics)</td>
          <td>vector (with embedded bitmaps)</td>
          <td></td>
          <td>X</td>
          <td></td>
          <td></td>
          <td></td>
          <td></td>
        </tr>
        <tr>
          <td><a href="#tiff">TIFF</a> (Tag Image Format File)</td>
          <td>bitmap</td>
          <td>(X)</td>
          <td></td>
          <td>X</td>
          <td></td>
          <td>X</td>
          <td></td>
          <!--td><a href="#native">FOP native</a> or <a href="#jai">JAI</a>, depending on the subformat. See <a href="#tiff">TIFF</a> for more details.(JIMI also supports TIFF, but this has not been implemented within FOP).</td-->
        </tr>
      </table>
      <note>"(X)" means restricted support. Please see the details below.</note>
    </section>
    <section id="packages">
      <title>Graphics Packages</title>
      <section id="native">
        <title>FOP Native</title>
        <p>
          FOP has native ability to handle some graphic file formats.
        </p>
      </section>
      <section id="batik-codecs">
        <title>Batik codecs</title>
        <p>
          Apache Batik contains codecs for PNG and TIFF access. FOP can use these.
        </p>
      </section>
      <section id="imageio">
        <title>Image I/O (JDK 1.4 or higher)</title>
        <p>
          For JDKs 1.4 or higher, FOP provides a wrapper to load images through the 
          <a class="fork" href="http://java.sun.com/j2se/1.4.2/docs/guide/imageio/index.html">JDK's Image I/O API</a> (JSR 015).
          Image I/O allows to dynamically add additional image codecs. An example of such an add-on library are the
          <a class="fork" href="http://java.sun.com/products/java-media/jai/">JAI Image I/O Tools</a> available from Sun.
        </p>
      </section>
      <section id="jimi">
        <title>JIMI</title>
        <p>
          Because of licensing issues, the JIMI image library is not included in the FOP distribution. First, <a class="fork" href="http://java.sun.com/products/jimi">download</a> and install it.
Then, copy the file "JimiProClasses.zip" from the archive to {fop-install-dir}/lib/jimi-1.0.jar. Please note that FOP binary distributions are compiled with JIMI support, so there is no need for you to build FOP to add the support. If jimi-1.0.jar is installed in the right place, it will automatically be used by FOP, otherwise it will not.
        </p>
      </section>
      <section id="jai">
        <title>JAI (Java Advanced Imaging API)</title>
        <warning>JAI support is available for Release 0.20.5 and later. The comments in this section do not apply to releases earlier than 0.20.5.</warning>
        <p>
          FOP has been compiled with JAI support, but JAI is not included in the FOP distribution.
To use it, install <a href="http://java.sun.com/products/java-media/jai">JAI</a>, then copy the jai_core.jar and the jai_codec.jar files to {fop-install-dir}/lib.
JAI is much faster than JIMI, but is not available for all platforms. See <a href="http://java.sun.com/products/java-media/jai/forDevelopers/jaifaq.html#platforms">What platforms are supported?</a> on the JAI FAQ page for more details.
        </p>
      </section>
      <section id="batik">
        <title>Batik</title>
        <p>Current FOP distributions include a distribution of the Apache <a class="fork" href="ext:batik">Batik</a> version 1.6.
It is automatically installed with FOP.
Because Batik's API changes frequently, it is highly recommended that you use the version that ships with FOP, at least when running FOP.</p>
        <warning>Batik must be run in a graphical environment.</warning>
        <p>Batik must be run in a graphical environment.
It uses AWT classes for rendering SVG, which in turn require an X server on Unixish systems.
If you run a server without X, or if you can't connect to the X server due to security restrictions or policies (a so-called "headless" environment), SVG rendering will fail.</p>
        <p>Here are some workarounds:</p>
        <ul>
          <li>If you are using JDK 1.4, start it with the <code>-Djava.awt.headless=true</code> command line option.</li>
          <li>Install an X server which provides an in-memory framebuffer without actually using a screen device or any display hardware. One example is Xvfb.</li>
          <li>Install a toolkit which emulates AWT without the need for an underlying X server. One example is the <a href="http://www.eteks.com/pja/en">PJA toolkit</a>, which is free and comes with detailed installation instructions.</li>
        </ul>
      </section>
    </section>
    <section id="bmp">
      <title>BMP</title>
      <p>FOP native support for BMP images is limited to the RGB color-space.</p>
    </section>
    <section id="eps">
      <title>EPS</title>
      <p>FOP provides support for two output targets:</p>
      <ul>
        <li>PostScript (full support).</li>
        <li>
          PDF (partial support). Due to the lack of a built-in PostScript interpreter, FOP 
          can only embed the EPS file into the PDF. Acrobat Reader will not currently display 
          the EPS (it doesn't have a PostScript interpreter, either) but it will be shown 
          correctly when you print the PDF on a PostScript-capable printer. PostScript devices 
          (including GhostScript) will render the EPS correctly.
        </li>
      </ul>
      <p>
        Other output targets can't be supported at the moment because
        FOP lacks a PostScript interpreter. Furthermore, FOP is not able
        to parse the preview bitmaps sometimes contained in EPS files.
      </p>
    </section>
    <section id="jpeg">
      <title>JPEG</title>
      <p>FOP native support of JPEG does not include all variants, especially those containing unusual color lookup tables and color profiles.
If you have trouble with a JPEG image in FOP, try opening it with an image processing program (such as Photoshop or Gimp) and then saving it.
Specifying 24-bit color output may also help.
For the PDF and PostScript renderers most JPEG images can be passed through without decompression.
User reports indicate that grayscale, RGB, and CMYK color-spaces are all rendered properly.
      </p>
    </section>
    <section id="png">
      <title>PNG</title>
      <p>If using JAI for PNG support, only RGB and RGBA color-spaces are supported for FOP rendering.</p>
    </section>
    <section id="svg">
      <title>SVG</title>
      <section id="svg-intro">
        <title>Introduction</title>
        <p>FOP uses <a href="#batik">Batik</a> for SVG support.
This format can be handled as an <code>fo:instream-foreign-object</code> or in a separate
file referenced with <code>fo:external-graphic</code>.</p>
      <note>   
Batik's SVG Rasterizer utility may also be used to convert standalone SVG
documents into PDF.  For more information please see the
<a href="http://xml.apache.org/batik/svgrasterizer.html">SVG Rasterizer documentation</a>
on the Batik site.
      </note>
      </section>
      <section id="svg-pdf-graphics">
        <title>Placing SVG Graphics into PDF</title>
        <p>
The SVG is rendered into PDF by using PDF commands to draw and fill
lines and curves. This means that the graphical objects created with
this remain as vector graphics.
        </p>
        <p>
There are a number of SVG things that cannot be converted directly into
PDF. Parts of the graphic such as effects, patterns and images are inserted
into the PDF as a raster graphic. The resolution of this graphic may not
be ideal depending on the FOP dpi (72dpi) and the scaling for that graphic.
We hope to improve this in the future.</p>
        <p>
Currently transparency is not supported in PDF so many svg images that
contain effects or graphics with transparent areas will not be displayed
correctly.
        </p>
      </section>
      <section id="svg-pdf-text">
        <title>Placing SVG Text into PDF</title>
        <p>If possible, Batik will use normal PDF text when inserting text. It does
this by checking if the text can be drawn normally and the font is
supported. This example svg <a href="../dev/svg/text.svg">text.svg</a> /
<!--link href="../dev/svg/text.pdf"-->text.pdf<!--/link-->
shows how various types and effects with text are handled.
Note that tspan and outlined text are not yet implemented.</p>
        <p>
Otherwise, text is converted and drawn as a set of shapes by batik, using the stroking text painter.
This means that a typical character will
have about 10 curves (each curve consists of at least 20 characters).
This can make the pdf files large and when the pdf is viewed the
viewer does not normally draw those fine curves very well (turning on
Smooth Line Art in the Acrobat preferences will fix this).
If the text is inserted into the PDF using the inbuilt text commands
for PDF it will use a single character.
        </p>
        <p>
For PDF output, there is a <a href="configuration.html#svg-strokeSVGText">configuration option to force SVG text to be rendered as text</a>.
The drawback to this approach is that it is effective only for available fonts (including embedded fonts).
Font sizes are rounded to the next integer point size.
This will be improved in the future.
        </p>
        <p>Note that because SVG text can be rendered as either text or a vector graphic, you may need to consider settings in your viewer for both.
The Acrobat viewer has both "smooth line art" and "smooth text" settings that may need to be set for SVG images to be displayed nicely on your screen (see Edit / Preferences / Display).
This setting will not affect the printing of your document, which should be OK in any case, but will only affect the quality of the screen display.</p>
      </section>
      <section id="svg-scaling">
        <title>Scaling</title>
        <p>Currently, SVG images are rendered with the dimensions specified <em>in the SVG file</em>, within the viewport specified in the fo:external-graphic element.
For everything to work properly, the two should be equal.
The SVG standard leaves this issue as an implementation detail.
FOP will probably implement a scaling mechanism in the future.</p>
      </section>
      <section id="svg-problems">
        <title>Known Problems</title>
        <ul>
          <li>
soft mask transparency is combined with white so that it looks better
on pdf 1.3 viewers but this causes the soft mask to be slightly lighter
or darker on pdf 1.4 viewers
          </li>
          <li>
there is some problem with a gradient inside a pattern causing a pdf
error when viewed in acrobat 5
          </li>
          <li>
text is not always handled correctly, it may select the wrong font
especially if characters have multiple fonts in the font list
          </li>
          <li>
more pdf text handling could be implemented
It could draw the string using the attributed character iterator
to handle tspans and other simple changes of text.
          </li>
          <li>
JPEG images are not inserted directly into the pdf document
This area has not been implemented yet since the appropriate
method in batik is static
          </li>
          <li>
Uniform transparency for images and other svg elements that are converted
into a raster graphic are not drawn properly in PDF. The image is opaque.
          </li>
        </ul>
      </section>
    </section>
    <section id="tiff">
      <title>TIFF</title>
      <p>FOP-native TIFF support is limited to PDF and PostScript output only. Also, according to user reports, FOP's native support for TIFF is limited to images with the following characteristics (all must be true for successful rendering):</p>
      <ul>
        <li>single channel images (i.e., bi-level and grayscale only)</li>
        <li>uncompressed images, or images using CCITT T.4, CCITT T.6, or JPEG compression</li>
        <li>images using white-is-zero encoding in the TIFF PhotometricInterpretation tag</li>
      </ul>
      <p><em>JAI:</em> Supports RGB and RGBA only for FOP rendering.</p>
    </section>
    <section id="resolution">
      <title>Graphics Resolution</title>
      <p>Some bitmapped image file formats store a dots-per-inch (dpi) or other resolution value. Since PDF and most output formats do not have a concept of resolution, but only of absolute image units (i.e. pixels) FOP ignores the resolution values as well. Instead, FOP uses the dimensions of the image as specified in the fo:external-graphic element to render the image:</p>
      <ul>
        <li>If no dimensions are given, FOP uses a default value of 72 dpi to compute the graphic's dimensions. For example, suppose a graphic 300 pixels wide and 400 pixels high. FOP will render the graphic at 4.167 inches wide, 5.555 inches high, with an apparent resolution of 72 dpi.</li>
        <li>If only one dimension is given, FOP by default uses the same aspect ratio to compute the other dimension (to avoid the appearance of stretching). For example, suppose a graphic 300 pixels wide and 400 pixels high, for which content-width = ".5in". FOP will compute the content-height = .667 inches, and will render the graphic at that size, with an apparent resolution of 600 dpi.</li>
        <li>If both dimensions are given, FOP simply renders the image in that space. For example, suppose a graphic 300 pixels wide and 400 pixels high, for which content-width = "3in" and content-height = "4in". FOP will render the graphic at that size, with an apparent resolution of 100 dpi.</li>
      </ul>
      <p>If you need a higher apparent output resolution for bitmapped images, first make sure that at least one dimension of the image is defined in your XSL-FO input. Apart from that, resolution problems are in the image file itself, and must be corrected there: use or create a higher-resolution image file.</p>
      <note>The explanation above describes only the basic default behavior. There are other attributes of the fo:external-graphic element that can affect the behavior described above.</note>
    </section>
    <section id="caching">
      <title>Image caching</title>
      <p>
        FOP caches images between runs. The URL is used as a key to identify images which means that when
        a particular URL appears again, the image is taken from the cache. If you have a servlet that
        generates a different image each time it is called with the same URL you need to use a constantly 
        changing dummy parameter on the URL to avoid caching.
      </p>
      <p>
        The image cache has been improved considerably in the redesigned code. Therefore, a resetCache() method
        has become unnecessary. If you still experience OutOfMemoryErrors, please notify us.
      </p>
    </section>
  </body>
</document>