Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

configuration.xml 21KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492
  1. <?xml version="1.0" encoding="UTF-8" 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: Configuration</title>
  21. <version>$Revision$</version>
  22. </header>
  23. <body>
  24. <section id="general">
  25. <title>Configuration File Basics</title>
  26. <p>
  27. The FOP configuration file is an XML file containing a variety of settings that are useful
  28. for controlling FOP's behavior, and for helping it find resources that you wish it to use.
  29. </p>
  30. <p>
  31. The easiest way to get started using a FOP configuration file is to copy the sample found
  32. at <code>{fop-dir}/conf/fop.xconf</code> to a location of your choice, and then to
  33. edit it according to your needs.
  34. It contains templates for the various configuration options, most of which are commented
  35. out. Remove the comments and change the settings for entries that you wish to use.
  36. Be sure to follow any instructions, including comments which specify the value range.
  37. Also, since the configuration file is XML, be sure to keep it well-formed.
  38. </p>
  39. <section id="general-available">
  40. <title>Making Configuration Available to FOP</title>
  41. <p>After creating your configuration file, you must tell FOP how to find it:</p>
  42. <ul>
  43. <li>
  44. If running FOP from the command-line, see the "-c" command-line option in
  45. <a href="running.html">Running FOP</a>.
  46. </li>
  47. <li>
  48. If running FOP as an embedded application, see
  49. <a href="embedding.html#config-external">Embedding, Using a Configuration File</a>.
  50. </li>
  51. </ul>
  52. <p>
  53. See <a href="embedding.html#config-internal">Setting the Configuration Programmatically</a>
  54. for instructions on how to do so in an embedded environment.
  55. </p>
  56. </section>
  57. </section>
  58. <section id="general-elements">
  59. <title>Summary of the General Configuration Options</title>
  60. <table>
  61. <tr>
  62. <th>Element</th>
  63. <th>Data Type (for the value)</th>
  64. <th>Description</th>
  65. <th>Default Value</th>
  66. </tr>
  67. <tr>
  68. <td>base</td>
  69. <td>URL or directory</td>
  70. <td>Specifies the base URL based on which relative URL will be resolved.</td>
  71. <td>current directory</td>
  72. </tr>
  73. <tr>
  74. <td>font-base</td>
  75. <td>URL or directory</td>
  76. <td>Specifies the base URL based on which relative font URLs will be resolved.
  77. </td>
  78. <td>base URL/directory (above)</td>
  79. </tr>
  80. <tr>
  81. <td>hyphenation-base</td>
  82. <td>URL or directory</td>
  83. <td>Specifies the base URL based on which relative URLs to hyphenation pattern
  84. files will be resolved. If not specified, support for user-supplied hyphenation
  85. patterns remains disabled.
  86. </td>
  87. <td>disabled</td>
  88. </tr>
  89. <tr>
  90. <td>source-resolution</td>
  91. <td>Integer, dpi</td>
  92. <td>
  93. Resolution in dpi (dots per inch) which is used internally to determine the pixel
  94. size for SVG images and bitmap images without resolution information.
  95. </td>
  96. <td>72 dpi</td>
  97. </tr>
  98. <tr>
  99. <td>target-resolution</td>
  100. <td>Integer, dpi</td>
  101. <td>
  102. Resolution in dpi (dots per inch) used to specify the output resolution for bitmap
  103. images generated by bitmap renderers (such as the TIFF renderer) and by bitmaps
  104. generated by Apache Batik for filter effects and such.
  105. </td>
  106. <td>72 dpi</td>
  107. </tr>
  108. <tr>
  109. <td>strict-configuration</td>
  110. <td>Boolean (true, false)</td>
  111. <td>
  112. Setting this option to 'true' will cause FOP to strictly verify the contents of the
  113. FOP configuration file to ensure that defined resources (such as fonts and base
  114. URLs/directories) are valid and available to FOP. Any errors found will cause FOP to
  115. immediately raise an exception.</td>
  116. <td>false</td>
  117. </tr>
  118. <tr>
  119. <td>strict-validation</td>
  120. <td>Boolean (true, false)</td>
  121. <td>
  122. Setting this option to 'false' causes FOP to be more forgiving about XSL-FO validity,
  123. for example, you're allowed to specify a border on a region-body which is supported
  124. by some FO implementations but is non-standard. Note that such a border would
  125. currently have no effect in Apache FOP.</td>
  126. <td>true</td>
  127. </tr>
  128. <tr>
  129. <td>break-indent-inheritance</td>
  130. <td>Boolean (true, false)</td>
  131. <td>
  132. Setting this option to 'true' causes FOP to use an alternative rule set to determine
  133. text indents specified through margins, start-indent and end-indent. Many commercial
  134. FO implementations have chosen to break the XSL specification in this aspect. This
  135. option tries to mimic their behaviour. Please note that Apache FOP may still not
  136. behave exactly like those implementations either because FOP has not fully matched
  137. the desired behaviour and because the behaviour among the commercial implementations
  138. varies. The default for this option (i.e. false) is to behave exactly like the
  139. specification describes.</td>
  140. <td>false</td>
  141. </tr>
  142. <tr>
  143. <td>default-page-settings</td>
  144. <td>n/a</td>
  145. <td>
  146. Specifies the default width and height of a page if "auto" is specified
  147. for either or both values. Use "height" and "width" attributes on the
  148. default-page-settings element to specify the two values.</td>
  149. <td>"height" 11 inches, "width" 8.26 inches</td>
  150. </tr>
  151. <tr>
  152. <td>prefer-renderer</td>
  153. <td>boolean (true, false)</td>
  154. <td>
  155. By default, FOP prefers the newer output implementations based on the
  156. <code>IFDocumentHandler</code> interface. If no such implementation can be found for
  157. a given MIME type, it looks for an implementation of the <code>Renderer</code> interface.
  158. If necessary, you can invert the lookup order to prefer the Renderer variant over the
  159. IFDocumentHandler variant by setting this value to true.
  160. </td>
  161. <td>false</td>
  162. </tr>
  163. <tr>
  164. <td>use-cache</td>
  165. <td>boolean (true, false)</td>
  166. <td>All fonts information that has been gathered as a result of "directory"
  167. or "auto-detect" font configurations will be cached for future rendering runs.
  168. This setting should improve performance on systems where
  169. fonts have been configured using the "directory" or "auto-detect" tag mechanisms.
  170. By default this option is switched on.</td>
  171. <td>true</td>
  172. </tr>
  173. <tr>
  174. <td>cache-file</td>
  175. <td>String</td>
  176. <td>This options specifies the file/directory path of the fop cache file.
  177. This option can also be specified on the command-line using the -cache option.
  178. This file is currently only used to cache font triplet information for future reference.</td>
  179. <td>${base}/conf/fop.cache</td>
  180. </tr>
  181. <tr>
  182. <td>renderers</td>
  183. <td>(see text below)</td>
  184. <td>Contains the configuration for each renderer. See below.</td>
  185. <td>N/A</td>
  186. </tr>
  187. </table>
  188. <p>
  189. This is an excerpt from the example configuration file coming with FOP:
  190. </p>
  191. <source><![CDATA[
  192. <fop version="1.0">
  193. <!-- Strict user configuration -->
  194. <strict-configuration>true</strict-configuration>
  195. <!-- Strict FO validation -->
  196. <strict-validation>true</strict-validation>
  197. <!-- Base URL for resolving relative URLs -->
  198. <base>./</base>
  199. <!-- Font Base URL for resolving relative font URLs -->
  200. <font-base>./</font-base>
  201. <!-- Source resolution in dpi (dots/pixels per inch) for determining the size of pixels in SVG and bitmap images, default: 72dpi -->
  202. <source-resolution>72</source-resolution>
  203. <!-- Target resolution in dpi (dots/pixels per inch) for specifying the target resolution for generated bitmaps, default: 72dpi -->
  204. <target-resolution>72</target-resolution>
  205. <!-- default page-height and page-width, in case
  206. value is specified as auto -->
  207. <default-page-settings height="11in" width="8.26in"/>
  208. <!-- etc. etc..... -->
  209. </fop>]]></source>
  210. </section>
  211. <section id="image-loading">
  212. <title>Image Loading Customization</title>
  213. <p>
  214. Apache FOP uses the image loading framework from
  215. <a href="http://xmlgraphics.apache.org/commons/">Apache XML Graphics Commons</a> to load
  216. images using various plug-ins. Every image loader plug-in has a hard-coded usage penalty
  217. that influences which solution is chosen if there are multiple possibilities to load an image.
  218. Sometimes, though, these penalties need to be tweaked and this can be done in the FOP
  219. configuration. An example:
  220. </p>
  221. <source><![CDATA[<fop version="1.0">
  222. [..]
  223. <image-loading>
  224. <penalty value="10000"
  225. class="org.apache.xmlgraphics.image.loader.impl.ImageLoaderRawCCITTFax"/>
  226. <penalty value="INFINITE"
  227. class="org.apache.xmlgraphics.image.loader.impl.ImageLoaderInternalTIFF"/>
  228. </image-loading>
  229. <renderers....
  230. </fop>]]></source>
  231. <p>
  232. The first penalty element increases the penalty for the raw CCITT loader. This practically
  233. forces the decoding of CCITT compressed TIFF images except if there are no TIFF codecs
  234. available.
  235. </p>
  236. <p>
  237. The second penalty element sets an "infinite" penalty for the TIFF loader using the internal
  238. TIFF codec. This practically disables that plug-in as it will never be chosen as a possible
  239. solution.
  240. </p>
  241. <p>
  242. Negative penalties are possible to promote a plug-in but a negative penalty sum will be
  243. treated as zero penalty in most cases. For more details on the image loading framework,
  244. please consult the documentation there.
  245. </p>
  246. </section>
  247. <section id="renderers">
  248. <title>Renderer configuration</title>
  249. <p>
  250. Each Renderer has its own configuration section which is identified by the
  251. MIME type the Renderer is written for, ex. "application/pdf" for the PDF Renderer.
  252. </p>
  253. <p>
  254. The configuration for the PDF Renderer could look like this:
  255. </p>
  256. <source><![CDATA[
  257. <renderers>
  258. <renderer mime="application/pdf">
  259. <filterList>
  260. <!-- provides compression using zlib flate (default is on) -->
  261. <value>flate</value>
  262. </filterList>
  263. <fonts>
  264. <font metrics-url="arial.xml" kerning="yes" embed-url="arial.ttf">
  265. <font-triplet name="Arial" style="normal" weight="normal"/>
  266. <font-triplet name="ArialMT" style="normal" weight="normal"/>
  267. </font>
  268. <font metrics-url="arialb.xml" kerning="yes" embed-url="arialb.ttf">
  269. <font-triplet name="Arial" style="normal" weight="bold"/>
  270. <font-triplet name="ArialMT" style="normal" weight="bold"/>
  271. </font>
  272. </fonts>
  273. </renderer>
  274. <renderer mime="application/postscript">
  275. <!-- etc. etc..... -->]]></source>
  276. <p>
  277. The details on the font configuration can be found on the separate <a href="fonts.html">Fonts</a> page.
  278. Note especially the section entitled <a href="fonts.html#register">Register Fonts with FOP</a>.
  279. </p>
  280. <section id="pdf-renderer">
  281. <title>Special Settings for the PDF Renderer</title>
  282. <p>
  283. The configuration element for the PDF renderer contains two elements. One is for the font configuration
  284. (please follow the link above) and one is for the "filter list". The filter list controls how the
  285. individual objects in a PDF file are encoded. By default, all objects get "flate" encoded (i.e. simply
  286. compressed with the same algorithm that is also used in ZIP files). Most users don't need to change that
  287. setting. For debugging purposes, it may be desired not to compress the internal objects at all so the
  288. generated PDF commands can be read. In that case, you can simply use the following filter list. The
  289. second filter list (type="image") ensures that all images still get compressed but also ASCII-85 encoded
  290. so the produced PDF file is still easily readable in a text editor.
  291. </p>
  292. <source><![CDATA[
  293. <renderer mime="application/pdf">
  294. <filterList>
  295. <value>null</value>
  296. </filterList>
  297. <filterList type="image">
  298. <value>flate</value>
  299. <value>ascii-85</value>
  300. </filterList>
  301. <fonts....
  302. </renderer>]]></source>
  303. <p>
  304. Another (optional) setting specific to the PDF Renderer is an output color profile, an ICC
  305. color profile which indicates the target color space the PDF file is generated for. This
  306. setting is mainly used in conjunction with the <a href="pdfx.html">PDF/X</a> feature.
  307. An example:
  308. </p>
  309. <source><![CDATA[
  310. <renderer mime="application/pdf">
  311. <filterList...
  312. <output-profile>C:\FOP\Color\EuropeISOCoatedFOGRA27.icc</output-profile>
  313. <fonts....
  314. </renderer>]]></source>
  315. <p>
  316. Some people don't have high requirements on color fidelity but instead want the smallest
  317. PDF file sizes possible. In this case it's possible to disable the default sRGB color space
  318. which XSL-FO requires. This will cause RGB colors to be generated as device-specific RGB.
  319. Please note that this option is unavailable (and will cause an error) if you enable
  320. PDF/A or PDF/X functionality or if you specify an output profile. This setting will make the
  321. PDF about 4KB smaller. To disable the sRGB color space add the following setting:
  322. </p>
  323. <source><![CDATA[
  324. <renderer mime="application/pdf">
  325. <filterList...
  326. <disable-srgb-colorspace>true</disable-srgb-colorspace>
  327. <fonts....
  328. </renderer>]]></source>
  329. <p>FOP supports encryption of PDF output, thanks to Patrick C. Lankswert.
  330. This feature is commonly used to prevent unauthorized viewing, printing, editing, copying text
  331. from the document and doing annotations. It is also possible to ask the user for a password in
  332. order to view the contents. Note that there already exist third party applications which can
  333. decrypt an encrypted PDF without effort and allow the aforementioned operations, therefore the
  334. degree of protection is limited. For further information about features and restrictions
  335. regarding PDF encryption, look at the documentation coming with Adobe Acrobat or the technical
  336. documentation on the Adobe web site.</p>
  337. <source><![CDATA[
  338. <renderer mime="application/pdf">
  339. <encryption-params>
  340. <user-password>testuserpass</user-password>
  341. <owner-password>testownerpass</owner-password>
  342. <noprint/>
  343. <nocopy/>
  344. <noedit/>
  345. <noannotations/>
  346. </encryption-params>
  347. </renderer>]]></source>
  348. </section>
  349. <section id="ps-renderer">
  350. <title>Special Settings for the PostScript Renderer</title>
  351. <p>
  352. Besides the normal font configuration (the same "fonts" element as for the PDF renderer) the PostScript
  353. renderer has an additional setting to force landscape pages to be rotated to fit on a page inserted into
  354. the printer in portrait mode. Set the value to "true" to activate this feature. The default is "false".
  355. Example:
  356. </p>
  357. <source><![CDATA[
  358. <renderer mime="application/postscript">
  359. <auto-rotate-landscape>true</auto-rotate-landscape>
  360. <fonts>
  361. <font metrics-url="arial.xml" kerning="yes" embed-url="arial.ttf">
  362. <font-triplet name="Arial" style="normal" weight="normal"/>
  363. <font-triplet name="ArialMT" style="normal" weight="normal"/>
  364. </font>
  365. <font metrics-url="arialb.xml" kerning="yes" embed-url="arialb.ttf">
  366. <font-triplet name="Arial" style="normal" weight="bold"/>
  367. <font-triplet name="ArialMT" style="normal" weight="bold"/>
  368. </font>
  369. </fonts>
  370. </renderer>]]></source>
  371. </section>
  372. <section id="pcl-renderer">
  373. <title>Special Settings for the PCL Renderer</title>
  374. <p>
  375. Non-standard fonts for the PCL renderer are made available through the Java2D subsystem which means that
  376. you don't have to do any custom font configuration in this case but you have to use the font names
  377. offered by Java.
  378. </p>
  379. <p>
  380. Additionally, there are certain settings that control how the renderer handles various elements.
  381. </p>
  382. <source><![CDATA[<renderer mime="application/vnd.hp-PCL">
  383. <rendering>quality</rendering>
  384. <text-rendering>bitmap</text-rendering>
  385. </renderer>]]></source>
  386. <p>
  387. The default value for the "rendering" setting is "speed" which causes borders
  388. to be painted as plain rectangles. In this mode, no special borders (dotted,
  389. dashed etc.) are available. If you want support for all border modes, set the
  390. value to "quality" as indicated above. This will cause the borders to be painted
  391. as bitmaps.
  392. </p>
  393. <p>
  394. The default value for the "text-rendering" setting is "auto" which paints the
  395. base fonts using PCL fonts. Non-base fonts are painted as bitmaps through Java2D.
  396. If the mix of painting methods results in unwelcome output, you can set this
  397. to "bitmap" which causes all text to be rendered as bitmaps.
  398. </p>
  399. </section>
  400. <section id="afp-renderer">
  401. <title>Special Settings for the AFP Renderer</title>
  402. <p>
  403. </p>
  404. <p>
  405. Additionally, there are certain settings that control how the renderer handles various elements.
  406. </p>
  407. <source><![CDATA[<renderer mime="application/x-afp">
  408. <images mode="b+w" bits-per-pixel="8" native="true"/>
  409. <renderer-resolution>240</renderer-resolution>
  410. <!-- a default external resource group file -->
  411. <resource-group-file>resources.afp</resource-group-file>
  412. </renderer>]]></source>
  413. <p>
  414. The default value for the images "mode" setting is "b+w" (black and white). When the images "mode" setting is "b+w" a "bits-per-pixel" setting can be provided to aid the grayscale conversion process. With this setting all images referenced in your source document are converted to an IOCA FS45 grayscale bitmap image form.
  415. When the setting is "color" all images are converted to an IOCA FS45 color bitmap image form. When "native" setting is "true", all images encountered (TIFF, GIF, JPEG and Encapsulated Postscript etc.) will be embedded directly in the datastream in their native form using a MO:DCA Object Container.
  416. </p>
  417. <p>
  418. The default value for the "renderer-resolution" is 240 dpi.
  419. </p>
  420. <!--
  421. <p>
  422. The default value for the MO:DCA "interchange-set" is "MO:DCA-L". Other compliance settings include presentation interchange sets "MO:DCA-P IS/1" and "MO:DCA-P IS/2" (Resource Groups).
  423. </p>
  424. -->
  425. <p>
  426. By default if there is no configuration definition for "resource-group-file", external resources will be placed in a file called resources.afp.
  427. </p>
  428. </section>
  429. </section>
  430. <section>
  431. <title>When it does not work</title>
  432. <p>FOP searches the configuration file for the information it
  433. expects, at the position it expects. When that information is not
  434. present, FOP will not complain, it will just continue. When there is
  435. other information in the file, FOP will not complain, it will just
  436. ignore it. That means that when your configuration information is in
  437. the file but in a different XML element, or in a different XML path,
  438. than FOP expects, it will be silently ignored.</p>
  439. <p>Check the following possibilities:</p>
  440. <ul>
  441. <li>The format of the configuration file has changed
  442. considerably between FOP 0.20.5 and FOP 1.0 and its beta versions. Did
  443. you convert your file to the new format?</li>
  444. <li>The FOP distribution contains a schema for configuration
  445. files, at src/foschema/fop-configuration.xsd. Did you validate your
  446. configuration file against it? Add the following schema location to
  447. the <code>schema</code> element:
  448. <source><![CDATA[<fop
  449. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  450. xsi:noNamespaceSchemaLocation=
  451. "http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/foschema/fop-configuration.xsd?view=co">]]>
  452. </source>
  453. and run the configuration file through a validating schema
  454. parser. Note that the schema cannot detect all errors, and that it is
  455. stricter about the order of some elements than FOP itself is.</li>
  456. <li>Run FOP in debug mode (command line option
  457. <code>-d</code>). This makes FOP report which configuration
  458. information it finds. Check if FOP finds what you expect.</li>
  459. </ul>
  460. </section>
  461. </body>
  462. </document>