You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

graphics.xml 18KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343
  1. <?xml version="1.0" standalone="no"?>
  2. <!--
  3. Copyright 1999-2005 The Apache Software Foundation
  4. Licensed under the Apache License, Version 2.0 (the "License");
  5. you may not use this file except in compliance with the License.
  6. You may obtain a copy of the License at
  7. http://www.apache.org/licenses/LICENSE-2.0
  8. Unless required by applicable law or agreed to in writing, software
  9. distributed under the License is distributed on an "AS IS" BASIS,
  10. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  11. See the License for the specific language governing permissions and
  12. limitations under the License.
  13. -->
  14. <!-- $Id$ -->
  15. <!DOCTYPE document PUBLIC "-//APACHE//DTD Documentation V2.0//EN" "http://forrest.apache.org/dtd/document-v20.dtd">
  16. <document>
  17. <header>
  18. <title>Apache FOP: Graphics Formats</title>
  19. <version>$Revision$</version>
  20. </header>
  21. <body>
  22. <section id="support-overview">
  23. <title>Overview of Graphics Support</title>
  24. <p>
  25. 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.
  26. </p>
  27. <table>
  28. <tr>
  29. <th>Format</th>
  30. <th>Type</th>
  31. <th><a href="#native">FOP native support</a></th>
  32. <th><a href="#batik">Batik SVG</a></th>
  33. <th><a href="#batik-codecs">Batik codecs</a></th>
  34. <th><a href="#imageio">Image I/O</a></th>
  35. <th><a href="#jai">JAI</a></th>
  36. <th><a href="#jimi">JIMI</a></th>
  37. </tr>
  38. <tr>
  39. <td><a href="#bmp">BMP</a> (Microsoft Windows Bitmap)</td>
  40. <td>bitmap</td>
  41. <td>X</td>
  42. <td></td>
  43. <td></td>
  44. <td></td>
  45. <td></td>
  46. <td></td>
  47. </tr>
  48. <tr>
  49. <td><a href="#eps">EPS</a> (Encapsulated PostScript)</td>
  50. <td>metafile (both bitmap and vector), probably most frequently used for vector drawings</td>
  51. <td>(X)</td>
  52. <td></td>
  53. <td></td>
  54. <td></td>
  55. <td></td>
  56. <td></td>
  57. </tr>
  58. <tr>
  59. <td>GIF (Graphics Interchange Format)</td>
  60. <td>bitmap</td>
  61. <td>X</td>
  62. <td></td>
  63. <td></td>
  64. <td>X</td>
  65. <td>X</td>
  66. <td>X</td>
  67. </tr>
  68. <tr>
  69. <td><a href="#jpeg">JPEG</a> (Joint Photographic Experts Group)</td>
  70. <td>bitmap</td>
  71. <td>(X)</td>
  72. <td></td>
  73. <td></td>
  74. <td></td>
  75. <td></td>
  76. <td></td>
  77. </tr>
  78. <tr>
  79. <td><a href="#png">PNG</a> (Portable Network Graphic)</td>
  80. <td>bitmap</td>
  81. <td></td>
  82. <td></td>
  83. <td>X</td>
  84. <td></td>
  85. <td></td>
  86. <td></td>
  87. </tr>
  88. <tr>
  89. <td><a href="#svg">SVG</a> (Scalable Vector Graphics)</td>
  90. <td>vector (with embedded bitmaps)</td>
  91. <td></td>
  92. <td>X</td>
  93. <td></td>
  94. <td></td>
  95. <td></td>
  96. <td></td>
  97. </tr>
  98. <tr>
  99. <td><a href="#tiff">TIFF</a> (Tag Image Format File)</td>
  100. <td>bitmap</td>
  101. <td>(X)</td>
  102. <td></td>
  103. <td>X</td>
  104. <td></td>
  105. <td>X</td>
  106. <td></td>
  107. <!--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-->
  108. </tr>
  109. </table>
  110. <note>"(X)" means restricted support. Please see the details below.</note>
  111. </section>
  112. <section id="packages">
  113. <title>Graphics Packages</title>
  114. <section id="native">
  115. <title>FOP Native</title>
  116. <p>
  117. FOP has native ability to handle some graphic file formats.
  118. </p>
  119. </section>
  120. <section id="batik-codecs">
  121. <title>Batik codecs</title>
  122. <p>
  123. Apache Batik contains codecs for PNG and TIFF access. FOP can use these.
  124. </p>
  125. </section>
  126. <section id="imageio">
  127. <title>Image I/O (JDK 1.4 or higher)</title>
  128. <p>
  129. For JDKs 1.4 or higher, FOP provides a wrapper to load images through the
  130. <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).
  131. Image I/O allows to dynamically add additional image codecs. An example of such an add-on library are the
  132. <a class="fork" href="http://java.sun.com/products/java-media/jai/">JAI Image I/O Tools</a> available from Sun.
  133. </p>
  134. </section>
  135. <section id="jimi">
  136. <title>JIMI</title>
  137. <p>
  138. 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.
  139. 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.
  140. </p>
  141. </section>
  142. <section id="jai">
  143. <title>JAI (Java Advanced Imaging API)</title>
  144. <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>
  145. <p>
  146. FOP has been compiled with JAI support, but JAI is not included in the FOP distribution.
  147. 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.
  148. 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.
  149. </p>
  150. </section>
  151. <section id="batik">
  152. <title>Batik</title>
  153. <p>Current FOP distributions include a distribution of the Apache <a class="fork" href="ext:batik">Batik</a> version 1.6.
  154. It is automatically installed with FOP.
  155. 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>
  156. <warning>Batik must be run in a graphical environment.</warning>
  157. <p>Batik must be run in a graphical environment.
  158. It uses AWT classes for rendering SVG, which in turn require an X server on Unixish systems.
  159. 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>
  160. <p>Here are some workarounds:</p>
  161. <ul>
  162. <li>If you are using JDK 1.4, start it with the <code>-Djava.awt.headless=true</code> command line option.</li>
  163. <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>
  164. <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>
  165. </ul>
  166. </section>
  167. </section>
  168. <section id="bmp">
  169. <title>BMP</title>
  170. <p>FOP native support for BMP images is limited to the RGB color-space.</p>
  171. </section>
  172. <section id="eps">
  173. <title>EPS</title>
  174. <p>FOP provides support for two output targets:</p>
  175. <ul>
  176. <li>PostScript (full support).</li>
  177. <li>
  178. PDF (partial support). Due to the lack of a built-in PostScript interpreter, FOP
  179. can only embed the EPS file into the PDF. Acrobat Reader will not currently display
  180. the EPS (it doesn't have a PostScript interpreter, either) but it will be shown
  181. correctly when you print the PDF on a PostScript-capable printer. PostScript devices
  182. (including GhostScript) will render the EPS correctly.
  183. </li>
  184. </ul>
  185. <p>
  186. Other output targets can't be supported at the moment because
  187. FOP lacks a PostScript interpreter. Furthermore, FOP is not able
  188. to parse the preview bitmaps sometimes contained in EPS files.
  189. </p>
  190. </section>
  191. <section id="jpeg">
  192. <title>JPEG</title>
  193. <p>FOP native support of JPEG does not include all variants, especially those containing unusual color lookup tables and color profiles.
  194. 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.
  195. Specifying 24-bit color output may also help.
  196. For the PDF and PostScript renderers most JPEG images can be passed through without decompression.
  197. User reports indicate that grayscale, RGB, and CMYK color-spaces are all rendered properly.
  198. </p>
  199. </section>
  200. <section id="png">
  201. <title>PNG</title>
  202. <p>If using JAI for PNG support, only RGB and RGBA color-spaces are supported for FOP rendering.</p>
  203. </section>
  204. <section id="svg">
  205. <title>SVG</title>
  206. <section id="svg-intro">
  207. <title>Introduction</title>
  208. <p>FOP uses <a href="#batik">Batik</a> for SVG support.
  209. This format can be handled as an <code>fo:instream-foreign-object</code> or in a separate
  210. file referenced with <code>fo:external-graphic</code>.</p>
  211. <note>
  212. Batik's SVG Rasterizer utility may also be used to convert standalone SVG
  213. documents into PDF. For more information please see the
  214. <a href="http://xml.apache.org/batik/svgrasterizer.html">SVG Rasterizer documentation</a>
  215. on the Batik site.
  216. </note>
  217. </section>
  218. <section id="svg-pdf-graphics">
  219. <title>Placing SVG Graphics into PDF</title>
  220. <p>
  221. The SVG is rendered into PDF by using PDF commands to draw and fill
  222. lines and curves. This means that the graphical objects created with
  223. this remain as vector graphics.
  224. </p>
  225. <p>
  226. There are a number of SVG things that cannot be converted directly into
  227. PDF. Parts of the graphic such as effects, patterns and images are inserted
  228. into the PDF as a raster graphic. The resolution of this graphic may not
  229. be ideal depending on the FOP dpi (72dpi) and the scaling for that graphic.
  230. We hope to improve this in the future.</p>
  231. <p>
  232. Currently transparency is not supported in PDF so many svg images that
  233. contain effects or graphics with transparent areas will not be displayed
  234. correctly.
  235. </p>
  236. </section>
  237. <section id="svg-pdf-text">
  238. <title>Placing SVG Text into PDF</title>
  239. <p>If possible, Batik will use normal PDF text when inserting text. It does
  240. this by checking if the text can be drawn normally and the font is
  241. supported. This example svg <a href="../dev/svg/text.svg">text.svg</a> /
  242. <!--link href="../dev/svg/text.pdf"-->text.pdf<!--/link-->
  243. shows how various types and effects with text are handled.
  244. Note that tspan and outlined text are not yet implemented.</p>
  245. <p>
  246. Otherwise, text is converted and drawn as a set of shapes by batik, using the stroking text painter.
  247. This means that a typical character will
  248. have about 10 curves (each curve consists of at least 20 characters).
  249. This can make the pdf files large and when the pdf is viewed the
  250. viewer does not normally draw those fine curves very well (turning on
  251. Smooth Line Art in the Acrobat preferences will fix this).
  252. If the text is inserted into the PDF using the inbuilt text commands
  253. for PDF it will use a single character.
  254. </p>
  255. <p>
  256. For PDF output, there is a <a href="configuration.html#svg-strokeSVGText">configuration option to force SVG text to be rendered as text</a>.
  257. The drawback to this approach is that it is effective only for available fonts (including embedded fonts).
  258. Font sizes are rounded to the next integer point size.
  259. This will be improved in the future.
  260. </p>
  261. <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.
  262. 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).
  263. 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>
  264. </section>
  265. <section id="svg-scaling">
  266. <title>Scaling</title>
  267. <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.
  268. For everything to work properly, the two should be equal.
  269. The SVG standard leaves this issue as an implementation detail.
  270. FOP will probably implement a scaling mechanism in the future.</p>
  271. </section>
  272. <section id="svg-problems">
  273. <title>Known Problems</title>
  274. <ul>
  275. <li>
  276. soft mask transparency is combined with white so that it looks better
  277. on pdf 1.3 viewers but this causes the soft mask to be slightly lighter
  278. or darker on pdf 1.4 viewers
  279. </li>
  280. <li>
  281. there is some problem with a gradient inside a pattern causing a pdf
  282. error when viewed in acrobat 5
  283. </li>
  284. <li>
  285. text is not always handled correctly, it may select the wrong font
  286. especially if characters have multiple fonts in the font list
  287. </li>
  288. <li>
  289. more pdf text handling could be implemented
  290. It could draw the string using the attributed character iterator
  291. to handle tspans and other simple changes of text.
  292. </li>
  293. <li>
  294. JPEG images are not inserted directly into the pdf document
  295. This area has not been implemented yet since the appropriate
  296. method in batik is static
  297. </li>
  298. <li>
  299. Uniform transparency for images and other svg elements that are converted
  300. into a raster graphic are not drawn properly in PDF. The image is opaque.
  301. </li>
  302. </ul>
  303. </section>
  304. </section>
  305. <section id="tiff">
  306. <title>TIFF</title>
  307. <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>
  308. <ul>
  309. <li>single channel images (i.e., bi-level and grayscale only)</li>
  310. <li>uncompressed images, or images using CCITT T.4, CCITT T.6, or JPEG compression</li>
  311. <li>images using white-is-zero encoding in the TIFF PhotometricInterpretation tag</li>
  312. </ul>
  313. <p><em>JAI:</em> Supports RGB and RGBA only for FOP rendering.</p>
  314. </section>
  315. <section id="resolution">
  316. <title>Graphics Resolution</title>
  317. <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>
  318. <ul>
  319. <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>
  320. <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>
  321. <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>
  322. </ul>
  323. <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>
  324. <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>
  325. </section>
  326. <section id="caching">
  327. <title>Image caching</title>
  328. <p>
  329. FOP caches images between runs. The URL is used as a key to identify images which means that when
  330. a particular URL appears again, the image is taken from the cache. If you have a servlet that
  331. generates a different image each time it is called with the same URL you need to use a constantly
  332. changing dummy parameter on the URL to avoid caching.
  333. </p>
  334. <p>
  335. The image cache has been improved considerably in the redesigned code. Therefore, a resetCache() method
  336. has become unnecessary. If you still experience OutOfMemoryErrors, please notify us.
  337. </p>
  338. </section>
  339. </body>
  340. </document>