The table below summarizes the theoretical support for graphical formats within FOP. In other words, within the constraints of the limitations listed here, these formats should 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.
Format | Type | Support Thru |
---|---|---|
BMP (Microsoft Windows Bitmap) | bitmap | JIMI or JAI |
CUR | unknown | JIMI |
EPS (Encapsulated PostScript) | metafile (both bitmap and vector), probably most frequently used for vector drawings | FOP native (limited support) |
GIF (Graphics Interchange Format) | bitmap | FOP native |
FPX | unknown | JAI |
ICO (Sun Icon) | bitmap | JIMI |
JPEG (Joint Photographic Experts Group) | bitmap | FOP native |
PCX (PC Paintbrush) | bitmap | JIMI |
PICT (Macintosh PICT) | metafile | JIMI |
PNG (Portable Network Graphic) | bitmap | JIMI or JAI |
PNM (Portable aNyMap Utilities, part of the Portable Bitmap Utilies, aka pbmplus. PNM is a superset encompassing PBM or Portable Bitmap, PGM or Portable Grayscale, and PPM or Portable Pixmap.) | bitmap | JAI |
PSD (Adobe Photoshop) | bitmap | JIMI |
RAS (Sunraster) | bitmap | JIMI |
SVG (Scalable Vector Graphics) | vector (with embedded bitmaps) | Batik |
TGA (Targa) | bitmap | JIMI |
TIFF (Tag Image Format File) | bitmap | JIMI or JAI |
XBM (X BitMap) | bitmap | JIMI |
XPM (X PixMap) | bitmap | JIMI |
FOP has native ability to handle some graphic file formats.
Because of licensing issues, the JIMI image library is not included in the FOP distribution. First,
FOP has been compiled with JAI support, but JAI is not included in the FOP distribution. To use it, simply install JAI. JAI is much faster than JIMI, but is not available for all platforms. See What platforms are supported? on the JAI FAQ page for more details.
Current FOP distributions include a distribution of the Apache Software Foundation's
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.
Here are some workarounds:
-Djava.awt.headless=true
command line option.FOP provides support for two output targets:
Not all variants of JPEG are supported, 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.
FOP uses Batik for SVG support.
This format can be handled as an fo:instream-foreign-object
or in a separate
file referenced with fo:external-graphic
.
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.
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.
Currently transparency is not supported in PDF so many svg images that contain effects or graphics with transparent areas will not be displayed correctly.
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 text.svg / text.pdf shows how various types and effects with text are handled. Note that tspan and outlined text are not yet implemented.
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.
It is possible to make sure that all text is drawn into PDF using the PDF text commands (instead of the graphical shapes), by adding the following to the user config:
In a servlet environment, you can set it directly:
For information on using a configuration file in a servlet, see the FAQ on that topic.
Note that this configuration setting works only for the PDF renderer.
The drawback to forcing text to be rendered as text is that it will be confined to text that is possible for PDF fonts (including embedded fonts) and implemented with this workaround. The fonts available are the standard pdf fonts and any fonts that you have embedded using FOP. The font sizes will be rounded to an integer value. In future this will be improved.
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.
Currently, SVG images are rendered with the dimensions specified in the SVG file, 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.
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:
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.