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

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