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.

output.xml 68KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401
  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. <!-- Output Formats: Renderers -->
  19. <document>
  20. <header>
  21. <title>Apache™ FOP Output Formats</title>
  22. <version>$Revision$</version>
  23. <authors>
  24. <person name="Keiron Liddle" email="keiron@aftexsw.com"/>
  25. <person name="Art Welch" email=""/>
  26. </authors>
  27. </header>
  28. <body>
  29. <p>
  30. Apache™ FOP supports multiple output formats by using a different renderer for each format.
  31. The renderers do not all have the same set of capabilities, sometimes because of
  32. the output format itself, sometimes because some renderers get more development
  33. attention than others.
  34. </p>
  35. <section id="general">
  36. <title>General Information</title>
  37. <section id="general-fonts">
  38. <title>Fonts</title>
  39. <p>
  40. Most FOP renderers use a FOP-specific system for font registration.
  41. However, the Java2D/AWT and print renderers use the Java AWT package, which gets its
  42. font information from the operating system registration.
  43. This can result in several differences, including actually using different fonts,
  44. and having different font metrics for the same font.
  45. The net effect is that the layout of a given FO document can be quite different between
  46. renderers that do not use the same font information.
  47. </p>
  48. <p>
  49. Theoretically, there's some potential to make the output of the PDF/PS renderers match
  50. the output of the Java2D-based renderers. If FOP used the font metrics from its own
  51. font subsystem but still used Java2D for text painting in the Java2D-based renderers,
  52. this could probably be achieved. However, this approach hasn't been implemented, yet.
  53. </p>
  54. <p>
  55. With a work-around, it is possible to match the PDF/PS output in a Java2D-based
  56. renderer pretty closely. The clue is to use the
  57. <a href="intermediate.html">intermediate format</a>. The trick is to layout the
  58. document using FOP's own font subsystem but then render the document using Java2D.
  59. Here are the necessary steps (using the command-line):
  60. </p>
  61. <ol>
  62. <li>
  63. Produce an IF file: <code>fop -fo myfile.fo -at application/pdf myfile.at.xml</code><br/>
  64. Specifying "application/pdf" for the "-at" parameter causes FOP to use FOP's own
  65. font subsystem (which is used by the PDF renderer). Note that no PDF file is created
  66. in this step.
  67. </li>
  68. <li>Render to a PDF file: <code>fop -atin myfile.at.xml -pdf myfile.pdf</code></li>
  69. <li>Render to a Java2D-based renderer:
  70. <ul>
  71. <li><code>fop -atin myfile.at.xml -print</code></li>
  72. <li><code>fop -atin myfile.at.xml -awt</code></li>
  73. <li><code>fop -atin myfile.at.xml -tiff myfile.tiff</code></li>
  74. </ul>
  75. </li>
  76. </ol>
  77. </section>
  78. <section id="general-direct-output">
  79. <title>Output to a Printer or Other Device</title>
  80. <p>
  81. The most obvious way to print your document is to use the FOP
  82. <a href="#print">print renderer</a>, which uses the Java2D API (AWT).
  83. However, you can also send output from the Postscript renderer directly to a Postscript
  84. device, or output from the PCL renderer directly to a PCL device.
  85. </p>
  86. <p>
  87. Here are Windows command-line examples for Postscript and PCL:
  88. </p>
  89. <source><![CDATA[fop ... -ps \\computername\printer]]></source>
  90. <source><![CDATA[fop ... -pcl \\computername\printer]]></source>
  91. <p>
  92. Here is some Java code to accomplish the task in UNIX:
  93. </p>
  94. <source><![CDATA[proc = Runtime.getRuntime().exec("lp -d" + print_queue + " -o -dp -");
  95. out = proc.getOutputStream();]]></source>
  96. <p>
  97. Set the output MIME type to "application/x-pcl" (MimeConstants.MIME_PCL) and
  98. it happily sends the PCL to the UNIX printer queue.
  99. </p>
  100. </section>
  101. </section>
  102. <section id="pdf">
  103. <title>PDF</title>
  104. <p>
  105. PDF is the best supported output format. It is also the most accurate
  106. with text and layout. This creates a PDF document that is streamed out
  107. as each page is rendered. This means that the internal page index
  108. information is stored near the end of the document.
  109. The PDF version supported is 1.4. PDF versions are forwards/backwards
  110. compatible.
  111. </p>
  112. <p>
  113. Note that FOP does not currently support PDF/A-1a.
  114. Support for <a href="accessibility.html">Tagged PDF</a>, <a href="pdfa.html">PDF/A-1b</a>
  115. and <a href="pdfx.html">PDF/X</a> has recently been added, however.
  116. </p>
  117. <section id="pdf-fonts">
  118. <title>Fonts</title>
  119. <p>
  120. PDF has a set of fonts that are always available to all PDF viewers;
  121. to quote from the PDF Specification:
  122. <em>"PDF prescribes a set of 14 standard fonts that can be used without prior
  123. definition.
  124. These include four faces each of three Latin text typefaces (Courier,
  125. Helvetica, and Times), as well as two symbolic fonts (Symbol and ITC Zapf
  126. Dingbats). These fonts, or suitable substitute fonts with the same metrics, are
  127. guaranteed to be available in all PDF viewer applications."</em>
  128. </p>
  129. </section>
  130. <section id="pdf-postprocess">
  131. <title>Post-processing</title>
  132. <p>
  133. FOP does not currently support several desirable PDF features: watermarks and signatures.
  134. One workaround is to use Adobe Acrobat (the full version, not the Reader) to process
  135. the file manually or with scripting that it supports.
  136. </p>
  137. <p>
  138. Another popular post-processing tool is <a href="http://www.lowagie.com/iText">iText</a>,
  139. which has tools for adding security features, document properties, watermarks, and many
  140. other features to PDF files.
  141. </p>
  142. <warning>
  143. Caveat: iText may swallow PDF bookmarks. But
  144. <a href="http://issues.apache.org/bugzilla/show_bug.cgi?id=37589">Jens Stavnstrup tells us</a>
  145. that this doesn't happen if you use iText's PDFStamper.
  146. </warning>
  147. <p>
  148. Here is some sample code that uses iText to encrypt a FOP-generated PDF. (Note that FOP now
  149. supports <a href="pdfencryption.html">PDF encryption</a>. However the principles for using
  150. iText for other PDF features are similar.)
  151. </p>
  152. <source><![CDATA[public static void main(String args[]) {
  153. try {
  154. ByteArrayOutputStream fopout = new ByteArrayOutputStream();
  155. FileOutputStream outfile = new FileOutputStream(args[2]);
  156. FopFactory fopFactory = FopFactory.newInstance();
  157. Fop fop = fopFactory.newFop(MimeConstants.MIME_PDF, fopout);
  158. Transformer transformer = TransformerFactory.newInstance().newTransformer(
  159. new StreamSource(new File(args[1])));
  160. transformer.transform(new StreamSource(new File(args[0])),
  161. new SAXResult(fop.getDefaultHandler()));
  162. PdfReader reader = new PdfReader(fopout.toByteArray());
  163. int n = reader.getNumberOfPages();
  164. Document document = new Document(reader.getPageSizeWithRotation(1));
  165. PdfWriter writer = PdfWriter.getInstance(document, outfile);
  166. writer.setEncryption(PdfWriter.STRENGTH40BITS, "pdf", null,
  167. PdfWriter.AllowCopy);
  168. document.open();
  169. PdfContentByte cb = writer.getDirectContent();
  170. PdfImportedPage page;
  171. int rotation;
  172. int i = 0;
  173. while (i < n) {
  174. i++;
  175. document.setPageSize(reader.getPageSizeWithRotation(i));
  176. document.newPage();
  177. page = writer.getImportedPage(reader, i);
  178. rotation = reader.getPageRotation(i);
  179. if (rotation == 90 || rotation == 270) {
  180. cb.addTemplate(page, 0, -1f, 1f, 0, 0,
  181. reader.getPageSizeWithRotation(i).height());
  182. } else {
  183. cb.addTemplate(page, 1f, 0, 0, 1f, 0, 0);
  184. }
  185. System.out.println("Processed page " + i);
  186. }
  187. document.close();
  188. } catch( Exception e) {
  189. e.printStackTrace();
  190. }
  191. }]]></source>
  192. <p>
  193. Check the iText tutorial and documentation for setting access flags, password,
  194. encryption strength and other parameters.
  195. </p>
  196. </section>
  197. <section id="pdf-watermark">
  198. <title>Watermarks</title>
  199. <p>
  200. In addition to the <a href="#pdf-postprocess">PDF Post-processing</a> options, consider the following workarounds:
  201. </p>
  202. <ul>
  203. <li>
  204. Use a background image for the body region.
  205. </li>
  206. <li>
  207. (submitted by Trevor Campbell) Place an image in a
  208. region that overlaps the flowing text. For example, make
  209. region-before large enough to contain your image. Then include a
  210. block (if necessary, use an absolutely positioned block-container)
  211. containing the watermark image in the static-content for the
  212. region-before. Note that the image will be drawn on top of the
  213. normal content.
  214. </li>
  215. </ul>
  216. </section>
  217. <section id="pdf-extensions">
  218. <title>Extensions</title>
  219. <p>The PDF Renderer supports some PDF specific extensions which can be embedded
  220. into the input FO document. To use the extensions the appropriate namespace must
  221. be declared in the fo:root element like this:</p>
  222. <source><![CDATA[
  223. <fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format"
  224. xmlns:pdf="http://xmlgraphics.apache.org/fop/extensions/pdf">
  225. ]]></source>
  226. <section id="pdf-embedded-file">
  227. <title>Embedded Files</title>
  228. <p>
  229. It is possible to attach/embed arbitrary files into a PDF file. You can give a name and
  230. a description of the file. Example:
  231. </p>
  232. <source><![CDATA[
  233. <fo:declarations>
  234. <pdf:embedded-file filename="image.jpg" src="url(file:///C:/Temp/myimage.jpg)" description="My image"/>
  235. <pdf:embedded-file src="url(file:///C:/Temp/MyTextDoc.odt)"/>
  236. </fo:declarations>
  237. ]]></source>
  238. <p>
  239. <code>pdf:embedded-file</code> must be a child of <code>fo:declarations</code>.
  240. The "src" property is used to reference the file that is to be embedded. This property
  241. uses the "uri-specification" datatype from the XSL-FO specification.
  242. The "filename" property is optional. If it is missing the filename is automatically set
  243. from the URI/IRI of the "src" property. An optional description can also be added to
  244. further describe the file attachment.
  245. </p>
  246. <p>
  247. It is also possible to reference an embedded file from an <code>fo:basic-link</code>.
  248. Use the special "embedded-file:" URI scheme with the filename as single argument after
  249. the URI scheme. Example:
  250. </p>
  251. <source><![CDATA[
  252. <fo:basic-link external-destination="url(embedded-file:image.jpg)">Attached Image</fo:basic-link>
  253. ]]></source>
  254. <p>
  255. Note: Not all PDF Viewers (including some Acrobat Versions) will open the embedded file
  256. when clicking on the link. In that case, the user will have to open he attachment via
  257. the separate list of file attachments.
  258. </p>
  259. </section>
  260. </section>
  261. </section>
  262. <section id="ps">
  263. <title>PostScript</title>
  264. <p>
  265. The PostScript renderer has been brought up to a similar quality as the
  266. PDF renderer, but may still be missing certain features. It provides good
  267. support for most text and layout.
  268. Images and SVG are not fully supported, yet. Currently, the PostScript
  269. renderer generates PostScript Level 3 with most DSC comments. Actually,
  270. the only Level 3 features used are the FlateDecode and DCTDecode
  271. filter (the latter is used for 1:1 embedding of JPEG images), everything
  272. else is Level 2.
  273. </p>
  274. <section id="ps-configuration">
  275. <title>Configuration</title>
  276. <p>
  277. The PostScript renderer configuration currently allows the following settings:
  278. </p>
  279. <source><![CDATA[<renderer mime="application/postscript">
  280. <auto-rotate-landscape>false</auto-rotate-landscape>
  281. <language-level>3</language-level>
  282. <optimize-resources>false</optimize-resources>
  283. <safe-set-page-device>false</safe-set-page-device>
  284. <dsc-compliant>true</dsc-compliant>
  285. <rendering>quality</rendering>
  286. </renderer>]]></source>
  287. <p>
  288. The default value for the "auto-rotate-landscape" setting is "false". Setting it
  289. to "true" will automatically rotate landscape pages and will mark them as landscape.
  290. </p>
  291. <p>
  292. The default value for the "language-level" setting is "3". This setting specifies
  293. the PostScript language level which should be used by FOP. Set this to "2"
  294. only if you don't have a Level 3 capable interpreter.
  295. </p>
  296. <p>
  297. The default value for the "optimize-resources" setting is "false". Setting it
  298. to "true" will produce the PostScript file in two steps. A temporary file will be
  299. written first which will then be processed to add only the fonts which were really
  300. used and images are added to the stream only once as PostScript forms. This will
  301. reduce file size but can potentially increase the memory needed in the interpreter
  302. to process.
  303. </p>
  304. <p>
  305. The default value for the "safe-set-page-device" setting is "false". Setting it
  306. to "true" will cause the renderer to invoke a postscript macro which guards against
  307. the possibility of invalid/unsupported postscript key/values being issued to the
  308. implementing postscript page device.
  309. </p>
  310. <p>
  311. The default value for the "dsc-compliant" setting is "true". Setting it
  312. to "false" will break DSC compliance by minimizing the number of setpagedevice
  313. calls in the postscript document output. This feature may be useful when unwanted
  314. blank pages are experienced in your postscript output. This problem is caused by
  315. the particular postscript implementation issuing unwanted postscript subsystem
  316. initgraphics/erasepage calls on each setpagedevice call.
  317. </p>
  318. <p>
  319. The default value for the "rendering" setting is "quality". Setting it to "size"
  320. optimizes rendering for smaller file sizes which can involve minor compromises in
  321. rendering quality. For example, solid borders are then painted as plain rectangles
  322. instead of the elaborate painting instructions required for mixed-color borders.
  323. </p>
  324. </section>
  325. <section id="ps-limitations">
  326. <title>Limitations</title>
  327. <ul>
  328. <li>Images and SVG may not be displayed correctly. SVG support is far from being complete. No image transparency is available.</li>
  329. <li>Only Type 1 fonts are supported.</li>
  330. <li>Multibyte characters are not supported.</li>
  331. <li>PPD support is still missing.</li>
  332. </ul>
  333. </section>
  334. </section>
  335. <section id="pcl">
  336. <title>PCL</title>
  337. <p>
  338. This format is for the Hewlett-Packard PCL printers and other printers
  339. supporting PCL. It should produce output as close to identical as possible
  340. to the printed output of the PDFRenderer within the limitations of the
  341. renderer, and output device.
  342. </p>
  343. <p>
  344. The output created by the PCLRenderer is generic PCL 5, HP GL/2 and PJL.
  345. This should allow any device fully supporting PCL 5 to be able to
  346. print the output generated by the PCLRenderer. PJL is used to control the
  347. print job and switch to the PCL language. PCL 5 is used for text, raster
  348. graphics and rectangular fill graphics. HP GL/2 is used for more complex
  349. painting operations. Certain painting operations are done off-screen and
  350. rendered to PCL as bitmaps because of limitations in PCL 5.
  351. </p>
  352. <section id="pcl-references">
  353. <title>References</title>
  354. <ul>
  355. <li><a href="http://en.wikipedia.org/wiki/Printer_Control_Language">WikiPedia entry on PCL</a></li>
  356. <li><a href="http://h20000.www2.hp.com/bizsupport/TechSupport/Document.jsp?objectID=bpl04568">Technical reference documents on PCL from Hewlett-Packard</a></li>
  357. </ul>
  358. </section>
  359. <section id="pcl-limitations">
  360. <title>Limitations</title>
  361. <ul>
  362. <li>
  363. Text or graphics outside the left or top of the printable area are not
  364. rendered properly. This is a limitation of PCL, not FOP. In general,
  365. things that should print to the left of the printable area are shifted
  366. to the right so that they start at the left edge of the printable area.
  367. </li>
  368. <li>
  369. The Helvetica and Times fonts are not well supported among PCL printers
  370. so Helvetica is mapped to Arial and Times is mapped to Times New. This
  371. is done in the PCLRenderer, no changes are required in the FO's. The
  372. metrics and appearance for Helvetica/Arial and Times/Times New are
  373. nearly identical, so this has not been a problem so far.
  374. </li>
  375. <li>For the non-symbol fonts, the ISO 8859-1 symbol set is used (PCL set "0N").</li>
  376. <li>
  377. All fonts available to the Java2D subsystem are usable. The texts are
  378. painted as bitmap much like the Windows PCL drivers do.
  379. </li>
  380. <li>Multibyte characters are not supported.</li>
  381. <li>
  382. At the moment, only monochrome output is supported. PCL5c color extensions
  383. will only be implemented on demand. Color and grayscale images are converted
  384. to monochrome bitmaps (1-bit). Dithering only occurs if the JAI image library
  385. is available.
  386. </li>
  387. <li>
  388. Images are scaled up to the next resolution level supported by PCL (75,
  389. 100, 150, 200, 300, 600 dpi). For color and grayscale images an even
  390. higher PCL resolution is selected to give the dithering algorithm a chance
  391. to improve the bitmap quality.
  392. </li>
  393. <li>
  394. Currently, there's no support for clipping and image transparency, largely
  395. because PCL 5 has certain limitations.
  396. </li>
  397. </ul>
  398. </section>
  399. <section id="pcl-configuration">
  400. <title>Configuration</title>
  401. <p>
  402. The PCL renderer configuration currently allows the following settings:
  403. </p>
  404. <source><![CDATA[<renderer mime="application/x-pcl">
  405. <rendering>quality</rendering>
  406. <text-rendering>bitmap</text-rendering>
  407. <disable-pjl>false</disable-pjl>
  408. </renderer>]]></source>
  409. <p>
  410. The default value for the "rendering" setting is "speed" which causes borders
  411. to be painted as plain rectangles. In this mode, no special borders (dotted,
  412. dashed etc.) are available. If you want support for all border modes, set the
  413. value to "quality" as indicated above. This will cause the borders to be painted
  414. as bitmaps.
  415. </p>
  416. <p>
  417. The default value for the "text-rendering" setting is "auto" which paints the
  418. base fonts using PCL fonts. Non-base fonts are painted as bitmaps through Java2D.
  419. If the mix of painting methods results in unwelcome output, you can set this
  420. to "bitmap" which causes all text to be rendered as bitmaps.
  421. </p>
  422. <p>
  423. The default value for the "disable-pjl" setting is "false". This means that
  424. the PCL renderer usually generates PJL commands before and after the document
  425. in order to switch a printer into PCL language. PJL commands can be disabled
  426. if you set this value to "true".
  427. </p>
  428. <p>
  429. You can control the output resolution for the PCL using the "target resolution"
  430. setting on the FOUserAgent. The actual value will be rounded up to the next
  431. supported PCL resolution. Currently, only 300 and 600 dpi are supported which
  432. should be enough for most use cases. Note that this setting directly affects
  433. the size of the output file and the print quality.
  434. </p>
  435. </section>
  436. <section id="pcl-extensions">
  437. <title>Extensions</title>
  438. <p>The PCL Renderer supports some PCL specific extensions which can be embedded
  439. into the input FO document. To use the extensions the appropriate namespace must
  440. be declared in the fo:root element like this:</p>
  441. <source><![CDATA[
  442. <fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format"
  443. xmlns:pcl="http://xmlgraphics.apache.org/fop/extensions/pcl">
  444. ]]></source>
  445. <section id="pcl-page-source">
  446. <title>Page Source (Tray selection)</title>
  447. <p>
  448. The page-source extension attribute on fo:simple-page-master allows to
  449. select the paper tray the sheet for a particular simple-page-master is
  450. to be taken from. Example:
  451. </p>
  452. <source><![CDATA[
  453. <fo:layout-master-set>
  454. <fo:simple-page-master master-name="simple" pcl:paper-source="2">
  455. ...
  456. </fo:simple-page-master>
  457. </fo:layout-master-set>
  458. ]]></source>
  459. <p>
  460. Note: the tray number is a positive integer and the value depends on
  461. the target printer. Not all PCL printers support the same paper trays.
  462. Usually,
  463. "1" is the default tray,
  464. "2" is the manual paper feed,
  465. "3" is the manual envelope feed,
  466. "4" is the "lower" tray and
  467. "7" is "auto-select".
  468. Consult the technical reference for your printer for all available values.
  469. </p>
  470. </section>
  471. <section id="pcl-output-bin">
  472. <title>Output Bin</title>
  473. <p>
  474. The <code>output-bin</code> extension attribute on fo:simple-page-master allows to
  475. select the output bin into which the printed output should be fed. Example:
  476. </p>
  477. <source><![CDATA[
  478. <fo:layout-master-set>
  479. <fo:simple-page-master master-name="simple" pcl:output-bin="2">
  480. ...
  481. </fo:simple-page-master>
  482. </fo:layout-master-set>
  483. ]]></source>
  484. <p>
  485. Note: the output bin number is a positive integer and the value depends on
  486. the target printer. Not all PCL printers support the same output bins.
  487. Usually,
  488. "1" is the upper output bin,
  489. "2" is the lower (rear) output bin.
  490. Consult the technical reference for your printer for all available values.
  491. </p>
  492. </section>
  493. <section id="pcl-duplex-mode">
  494. <title>Page Duplex Mode</title>
  495. <p>
  496. The duplex-mode extension attribute on fo:simple-page-master allows to
  497. select the duplex mode to be used for a particular simple-page-master.
  498. Example:
  499. </p>
  500. <source><![CDATA[
  501. <fo:layout-master-set>
  502. <fo:simple-page-master master-name="simple" pcl:duplex-mode="0">
  503. ...
  504. </fo:simple-page-master>
  505. </fo:layout-master-set>
  506. ]]></source>
  507. <p>
  508. Note: the duplex is a positive integer and the value depends on
  509. the target printer. Not all PCL printers support duplexing.
  510. Usually,
  511. "0" is simplex,
  512. "1" is duplex (long-edge binding),
  513. "2" is duplex (short-edge binding).
  514. Consult the technical reference for your printer for all available values.
  515. </p>
  516. </section>
  517. </section>
  518. </section>
  519. <section id="afp">
  520. <title>AFP</title>
  521. <p>
  522. The FOP AFP Renderer deals with creating documents conforming to the IBM AFP document architecture
  523. also refered to as MO:DCA (Mixed Object Document Content Architecture).
  524. </p>
  525. <p>
  526. The mapping of XSL-FO elements to the major MO:DCA structures is as follows:
  527. </p>
  528. <table>
  529. <tr>
  530. <th>XSL-FO element</th>
  531. <th>MO:DCA-P object</th>
  532. </tr>
  533. <tr>
  534. <td>fo:root</td>
  535. <td>Document</td>
  536. </tr>
  537. <tr>
  538. <td>fo:page-sequence</td>
  539. <td>Page Group</td>
  540. </tr>
  541. <tr>
  542. <td>fo:simple-page-master</td>
  543. <td>Page</td>
  544. </tr>
  545. </table>
  546. <p>
  547. FOP creates exactly one Document per Printfile with an optional Resource Group at the
  548. beginning. FOP does not create document indices.
  549. </p>
  550. <section id="afp-references">
  551. <title>References</title>
  552. <ul>
  553. <li><a href="http://en.wikipedia.org/wiki/Advanced_Function_Presentation">AFP (Advanced Function Presentation)</a></li>
  554. <li><a href="http://wiki.apache.org/xmlgraphics-fop/AFPResources">AFP Resources on the FOP WIKI</a></li>
  555. <li><a href="http://wiki.apache.org/xmlgraphics-fop/AFPOutput">Technical notes on AFP output in FOP</a></li>
  556. </ul>
  557. </section>
  558. <section id="afp-limitations">
  559. <title>Limitations</title>
  560. <p>This list is most likely badly incomplete.</p>
  561. <ul>
  562. <li>
  563. Clipping of text and graphics is not supported.
  564. </li>
  565. <li>
  566. Only IBM outline and raster fonts and to a limited extend the original fonts built into FOP are supported.
  567. Support for TrueType fonts may be added later.
  568. </li>
  569. </ul>
  570. </section>
  571. <section id="afp-compatibility">
  572. <title>Deployment in older environments</title>
  573. <p>
  574. There are still a big number of older (or limited) MO:DCA/IPDS environments in production
  575. out there. AFP has grown in functionality over time and not every environment supports the
  576. latest features. We're trying to make AFP output work in as many environments as possible.
  577. However, to make AFP output work on older environments it is recommended to set to
  578. configuration to 1 bit per pixel (see below on how to do this). In this case, all images
  579. are converted to bi-level images using IOCA function set 10 (FS10) and are enclosed in
  580. page-segments since some implementation cannot deal with IOCA objects directly.
  581. If a higher number of bits per pixel is configured, FOP has to switch to at least FS11
  582. which may not work everywhere.
  583. </p>
  584. </section>
  585. <section id="afp-configuration">
  586. <title>Configuration</title>
  587. <section id="afp-font-config">
  588. <title>Fonts</title>
  589. <p>The AFP Renderer requires special configuration particularly related to fonts.
  590. AFP Render configuration is done through the normal FOP configuration file. The MIME type
  591. for the AFP Renderer is application/x-afp which means the AFP Renderer section in the FOP configuration file
  592. looks like:</p>
  593. <source><![CDATA[<renderer mime="application/x-afp">
  594. <!-- AFP Renderer -->
  595. ...
  596. </renderer>]]></source>
  597. <p>There are 4 font configuration variants supported:</p>
  598. <ol>
  599. <li>IBM Raster fonts</li>
  600. <li>IBM Outline fonts</li>
  601. <li>IBM CID-keyed (Type 0) fonts</li>
  602. <li>FOP built-in Base14 fonts</li>
  603. </ol>
  604. <p>A typical raster font configuration looks like:</p>
  605. <source><![CDATA[ <!-- This is an example of mapping actual IBM raster fonts / code pages to a FOP font -->
  606. <font>
  607. <!-- The afp-font element defines the IBM code page, the matching Java encoding and the
  608. base URI for the font -->
  609. <afp-font type="raster" codepage="T1V10500" encoding="Cp500" base-uri="fonts/ibm/">
  610. <!-- For a raster font a separate element for each font size is required providing
  611. the font size and the corresponding IBM Character set name -->
  612. <afp-raster-font size="7" characterset="C0N20070"/>
  613. <afp-raster-font size="8" characterset="C0N20080"/>
  614. <afp-raster-font size="10" characterset="C0N20000"/>
  615. <afp-raster-font size="11" characterset="C0N200A0"/>
  616. <afp-raster-font size="12" characterset="C0N200B0"/>
  617. <afp-raster-font size="14" characterset="C0N200D0"/>
  618. <afp-raster-font size="16" characterset="C0N200F0"/>
  619. <afp-raster-font size="18" characterset="C0N200H0"/>
  620. <afp-raster-font size="20" characterset="C0N200J0"/>
  621. <afp-raster-font size="24" characterset="C0N200N0"/>
  622. <afp-raster-font size="30" characterset="C0N200T0"/>
  623. <afp-raster-font size="36" characterset="C0N200Z0"/>
  624. </afp-font>
  625. <!-- These are the usual FOP font triplets as they apply to this font -->
  626. <font-triplet name="serif" style="normal" weight="normal"/>
  627. <font-triplet name="Times" style="normal" weight="normal"/>
  628. <font-triplet name="Times-Roman" style="normal" weight="normal"/>
  629. <font-triplet name="TimesNewRoman" style="normal" weight="normal"/>
  630. </font>]]></source>
  631. <p>An outline font configuration is simpler as the individual font size entries are not required.
  632. However, the characterset definition is now required within the afp-font element.</p>
  633. <source><![CDATA[ <font>
  634. <afp-font type="outline" codepage="T1V10500" encoding="Cp500" characterset="CZH200 "
  635. base-uri="file:/fonts/ibm" />
  636. <font-triplet name="sans-serif" style="normal" weight="normal"/>
  637. <font-triplet name="Helvetica" style="normal" weight="normal"/>
  638. <font-triplet name="any" style="normal" weight="normal"/>
  639. </font>
  640. ]]></source>
  641. <p>
  642. If "base-uri" is missing or a relative URI, the fonts are resolved relative to
  643. the font base URI specified in the configuration (or on the FopFactory).
  644. </p>
  645. <note>
  646. Previously, the location of the font files was given by the "path" attribute. This is still
  647. supported for the time being, but you should move to using the more flexible "base-uri"
  648. attribute so you can profit from the power of URI resolvers.
  649. </note>
  650. <p>A CID-keyed font (Type 0, double-byte outline font) configuration is much the same as an outline font.
  651. However, the characterset definition is now required within the afp-font element.</p>
  652. <source><![CDATA[ <font>
  653. <afp-font type="CIDKeyed" characterset="CZJHMNU"
  654. codepage="T1120000" encoding="UnicodeBigUnmarked"
  655. base-uri="file:/fonts/ibm" />
  656. <font-triplet name="J-Heisei Mincho" style="normal" weight="normal" />
  657. </font>
  658. ]]></source>
  659. <p>
  660. Note that the value of the encoding attribute in the example is the double-byte encoding 'UnicodeBigUnmarked' (UTF-16BE).
  661. </p>
  662. <p>Experimentation has shown that the font metrics for the FOP built-in Base14 fonts are actually
  663. very similar to some of the IBM outline and raster fonts. In cases were the IBM font files are not
  664. available the base-uri attribute in the afp-font element can be replaced by a base14-font attribute
  665. giving the name of the matching Base14 font. In this case the AFP Renderer will take the
  666. font metrics from the built-in font.</p>
  667. <source><![CDATA[ <!-- The following are examples of defining outline fonts based on FOP built-in
  668. font metrics for the Adobe Base14 fonts -->
  669. <!-- sans-serif fonts based on Helvetica -->
  670. <font>
  671. <afp-font type="outline" codepage="T1V10500" encoding="Cp500" characterset="CZH200 "
  672. base14-font="Helvetica" />
  673. <font-triplet name="sans-serif" style="normal" weight="normal"/>
  674. <font-triplet name="Helvetica" style="normal" weight="normal"/>
  675. <font-triplet name="any" style="normal" weight="normal"/>
  676. </font>
  677. <font>
  678. <afp-font type="outline" codepage="T1V10500" encoding="Cp500" characterset="CZH300 "
  679. base14-font="HelveticaOblique" />
  680. <font-triplet name="sans-serif" style="italic" weight="normal"/>
  681. <font-triplet name="Helvetica" style="italic" weight="normal"/>
  682. <font-triplet name="any" style="italic" weight="normal"/>
  683. </font>
  684. <font>
  685. <afp-font type="outline" codepage="T1V10500" encoding="Cp500" characterset="CZH400 "
  686. base14-font="HelveticaBold" />
  687. <font-triplet name="sans-serif" style="normal" weight="bold"/>
  688. <font-triplet name="Helvetica" style="normal" weight="bold"/>
  689. <font-triplet name="any" style="normal" weight="bold"/>
  690. </font>
  691. <font>
  692. <afp-font type="outline" codepage="T1V10500" encoding="Cp500" characterset="CZH500 "
  693. base14-font="HelveticaBoldOblique" />
  694. <font-triplet name="sans-serif" style="italic" weight="bold"/>
  695. <font-triplet name="Helvetica" style="italic" weight="bold"/>
  696. <font-triplet name="any" style="italic" weight="bold"/>
  697. </font>
  698. <!-- serif fonts based on Times Roman -->
  699. <font>
  700. <afp-font type="outline" codepage="T1V10500" encoding="Cp500" characterset="CZN200 "
  701. base14-font="TimesRoman" />
  702. <font-triplet name="serif" style="normal" weight="normal"/>
  703. <font-triplet name="Times" style="normal" weight="normal"/>
  704. <font-triplet name="Times-Roman" style="normal" weight="normal"/>
  705. </font>
  706. <!-- The following are examples of defining raster fonts based on FOP built-in
  707. font metrics for the Adobe Base14 fonts -->
  708. <!-- monospaced fonts based on Courier -->
  709. <font>
  710. <afp-font type="raster" codepage="T1V10500" encoding="Cp500">
  711. <afp-raster-font size="7" characterset="C0420070" base14-font="Courier"/>
  712. <afp-raster-font size="8" characterset="C0420080" base14-font="Courier"/>
  713. <afp-raster-font size="10" characterset="C0420000" base14-font="Courier"/>
  714. <afp-raster-font size="12" characterset="C04200B0" base14-font="Courier"/>
  715. <afp-raster-font size="14" characterset="C04200D0" base14-font="Courier"/>
  716. <afp-raster-font size="20" characterset="C04200J0" base14-font="Courier"/>
  717. </afp-font>
  718. <font-triplet name="monospace" style="normal" weight="normal"/>
  719. <font-triplet name="Courier" style="normal" weight="normal"/>
  720. </font>
  721. <font>
  722. <afp-font type="raster" codepage="T1V10500" encoding="Cp500">
  723. <afp-raster-font size="7" characterset="C0440070" base14-font="CourierBold"/>
  724. <afp-raster-font size="8" characterset="C0440080" base14-font="CourierBold"/>
  725. <afp-raster-font size="10" characterset="C0440000" base14-font="CourierBold"/>
  726. <afp-raster-font size="12" characterset="C04400B0" base14-font="CourierBold"/>
  727. <afp-raster-font size="14" characterset="C04400D0" base14-font="CourierBold"/>
  728. <afp-raster-font size="20" characterset="C04400J0" base14-font="CourierBold"/>
  729. </afp-font>
  730. <font-triplet name="monospace" style="normal" weight="bold"/>
  731. <font-triplet name="Courier" style="normal" weight="bold"/>
  732. </font>]]></source>
  733. <p>
  734. By default, all manually configured fonts are embedded, unless they are matched in the
  735. <a href="fonts.html#embedding"><code>referenced-fonts</code> section of the configuration file</a>.
  736. However, the default fonts shown above will not be embedded.
  737. </p>
  738. <p>
  739. For double byte EBCDIC encoded character sets, there is an optional tag that must be set to prevent
  740. characters from being miscoded. This defaults to "false" if not specified.</p>
  741. <source><![CDATA[
  742. <afp-font type="CIDKeyed" codepage="T10835 " encoding="Cp937" characterset="CZTKAI" ebcdic-dbcs="true"/>]]>
  743. </source>
  744. </section>
  745. <section id="afp-renderer-resolution-config">
  746. <title>Output Resolution</title>
  747. <p>By default the AFP Renderer creates output with a resolution of 240 dpi.
  748. This can be overridden by the &lt;renderer-resolution/&gt; configuration element. Example:</p>
  749. <source><![CDATA[
  750. <renderer-resolution>240</renderer-resolution>]]></source>
  751. </section>
  752. <section id="afp-line-width-correction-config">
  753. <title>Line Width Correction</title>
  754. <p>The default line width in AFP is device dependent. This means that a line width specified in, say,
  755. a SVG source file may not render the way it was intended. The output AFP line with can be corrected
  756. by the &lt;line-width-correction/&gt; configuration element. Example:</p>
  757. <source><![CDATA[
  758. <line-width-correction>2.5</line-width-correction>]]></source>
  759. </section>
  760. <section id="afp-image-config">
  761. <title>Images</title>
  762. <p>By default the AFP Renderer converts all images to 8 bit grey level.
  763. This can be overridden by the &lt;images/&gt; configuration element. Example:</p>
  764. <source><![CDATA[
  765. <images mode="color" />
  766. ]]></source>
  767. <p>This will put images as RGB images into the AFP output stream. The default setting is:</p>
  768. <source><![CDATA[
  769. <images mode="b+w" bits-per-pixel="8" native="true"/>
  770. ]]></source>
  771. <p>Only the values "color" and "b+w" are allowed for the mode attribute.</p>
  772. <p>The bits-per-pixel attribute is ignored if mode is "color". For "b+w" mode is must be 1, 4, or 8.</p>
  773. <source><![CDATA[
  774. <images native="true"/>
  775. ]]></source>
  776. <p>When the native attribute is specified and set to "true", all image resources will be natively injected
  777. into the datastream using an object container rather than being converted into an IOCA FS45 image.
  778. Support for native image formats (e.g. JPEG, TIFF, GIF) is not always available on printer implementations
  779. so by default this configuration option is set to "false".</p>
  780. <p>
  781. Setting <code>cmyk="true"</code> on the <code>images</code> element will enable CMYK
  782. colors. This will only have an effect if the color mode is set to "color". Example:
  783. </p>
  784. <source><![CDATA[
  785. <images mode="color" cmyk="true"/>]]></source>
  786. <p>
  787. When the color mode is set to 1 bit (bi-level), the "dithering-quality" attribute can
  788. be used to select the level of quality to use when converting images to bi-level images.
  789. Valid values for this attribute are floating point numbers from 0.0 (fastest) to
  790. 1.0 (best), or special values: "minimum" (=0.0), "maximum" (1.0),
  791. "medium" (0.5, the default). For the higher settings to work as expected, JAI needs to
  792. be present in the classpath. If JAI is present, 0.0 results in a minimal darkness-level
  793. switching between white and black. 0.5 does bayer-based dithering and 1.0 will use
  794. error-diffusion dithering. The higher the value, the higher the quality and the slower
  795. the processing of the images.
  796. </p>
  797. <source><![CDATA[
  798. <images mode="b+w" bits-per-pixel="1" dithering-quality="maximum"/>]]></source>
  799. <p>
  800. When the boolean attribute pseg (default false) is set to true, non-inline FS11 and FS45 IOCA images are wrapped in page segment.
  801. This option is provided to support printers/print servers that require this MO:DCA structure.
  802. </p>
  803. <source><![CDATA[
  804. <images mode="b+w" bits-per-pixel="8" pseg="true"/>]]></source>
  805. <p>
  806. Setting the boolean attribute fs45 to true (default false) will force all images to FS45.
  807. </p>
  808. <source><![CDATA[
  809. <images mode="b+w" bits-per-pixel="8" fs45="true"/>]]></source>
  810. <p>
  811. By default, JPEG images are rasterized to a bitmap and the bitmap is included in the AFP doc.
  812. However it is possible to encode in a lossless way to maintain maximum quality. But due
  813. to lack of support for compression schemes like LZW (patent concerns), bitmap data is currently
  814. not compressed resulting in large AFP files. Using the "allow-embedding" attribute on jpeg child
  815. element allows the user to pass the JPEG as is in the document. The default is set to "false" since
  816. there are compatibility concerns as some AFP printers don't support JPEG decoding. Using the
  817. "bitmap-encoding-quality" attribute it is possible to enable lossy compression (JPEG baseline
  818. DCT). The default is "1.0" which means lossless encoding. Setting a value lower than 1.0, JPEG
  819. compression is enabled and the setting is used as the quality setting when encoding bitmap data.
  820. Note that this setting does not always have an effect. Bi-level (1 bit) bitmaps are not compressed
  821. using JPEG. Example:
  822. </p>
  823. <source><![CDATA[
  824. <images mode="color" cmyk="true">
  825. <jpeg allow-embedding="false" bitmap-encoding-quality="0.8"/>
  826. </images>]]></source>
  827. </section>
  828. <section id="afp-goca-config">
  829. <title>GOCA (Vector Graphics)</title>
  830. <p>
  831. Not all AFP implementations support GOCA. Some also have bugs related to GOCA. Therefore,
  832. it is desirable to have some control over the generation of GOCA graphics.
  833. </p>
  834. <p>
  835. GOCA is enabled by default. You can disable GOCA entirely in which case the AFP support
  836. falls back to generating bitmaps for vector graphics. Example:
  837. </p>
  838. <source><![CDATA[
  839. <goca enabled="false"/>]]></source>
  840. <p>
  841. Some AFP implementations have trouble rendering text in GOCA. You can instruct the AFP
  842. support to render text as shapes (i.e. use vector graphics to paint text). Example:
  843. </p>
  844. <source><![CDATA[
  845. <goca enabled="true" text="shapes"/>]]></source>
  846. <p>
  847. If you disable GOCA or let text render as shapes, the size of the generated AFP usually
  848. increases considerably.
  849. </p>
  850. </section>
  851. <section id="afp-shading-config">
  852. <title>Shading</title>
  853. <p>
  854. By default, filled rectangles are painted using their given color using a PTOCA I-axis rule
  855. (DIR). But not all environments handle these colors correctly. That's why a setting is
  856. supported that paints the rectangles using an ordered dither pattern (bi-level) with
  857. an inline IOCA FS10 image that is used together with the "replicate and trim" mapping.
  858. The optional "shading" element can be used to control the shading mode. Its default value
  859. is "color". To enable the dithered mode, use "dithered". Example:
  860. </p>
  861. <source><![CDATA[
  862. <shading>dithered</shading>
  863. ]]></source>
  864. </section>
  865. <section id="afp-resource-group-file">
  866. <title>Resource Group File</title>
  867. <p>By default the AFP Renderer will place all data resource objects such as images within
  868. the document of the main output datastream. An external resource group file where document resources
  869. may be specified with the &lt;resource-group-file/&gt; configuration element. Example:</p>
  870. <source><![CDATA[
  871. <resource-group-file>external_resources.afp</resource-group-file>
  872. ]]></source>
  873. <note>Be careful when using this option not to overwrite existing resource files from previous rendering runs.</note>
  874. </section>
  875. <section id="afp-resource-level-defaults">
  876. <title>Resource Level Defaults</title>
  877. <p>
  878. By default, bitmap image objects (or page segments derived from them) are put in the
  879. print-file-level resource group and GOCA graphics are inlined for compatibility with
  880. the AFP Workbench tool.
  881. </p>
  882. <p>
  883. It is possible to override these defaults, either per image (see the
  884. <link href="#afp-foreign-attributes-resource">afp:resource-level</link>
  885. extension attribute below) or by specifying different defaults in the configuration:
  886. </p>
  887. <source><![CDATA[
  888. <default-resource-levels goca="print-file" bitmap="inline"/>]]></source>
  889. <p>
  890. "goca" refers to GOCA graphics and "bitmap" refers to IOCA images. The possible values
  891. for the attributes are "inline" and "print-file". In the future,
  892. additional possibilities may be added.
  893. </p>
  894. </section>
  895. </section>
  896. <section id="afp-extensions">
  897. <title>Extensions</title>
  898. <p>The AFP Renderer supports some AFP specific extensions which can be embedded into the input
  899. fo document. To use the extensions the appropriate namespace must be declared in the fo:root element like this:</p>
  900. <source><![CDATA[
  901. <fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format"
  902. xmlns:afp="http://xmlgraphics.apache.org/fop/extensions/afp">
  903. ]]></source>
  904. <section id="afp-page-overlay">
  905. <title>Page Overlay (IPO) Extension</title>
  906. <p>The include-page-overlay extension element allows to define on a per simple-page-master basis a page overlay resource. Example:</p>
  907. <source><![CDATA[
  908. <fo:layout-master-set>
  909. <fo:simple-page-master master-name="simple">
  910. <afp:include-page-overlay name="O1SAMP1 " x="20mm" y="30mm" />
  911. ...
  912. </fo:simple-page-master>
  913. </fo:layout-master-set>
  914. ]]></source>
  915. <p>The mandatory name attribute must refer to an 8 character (space padded) resource name that
  916. must be known in the AFP processing environment. Optional x and y attributes can be specified
  917. to place the Overlay at an offset from the top left of the page.</p>
  918. </section>
  919. <section id="afp-page-segment">
  920. <title>Page Segment (IPS) Extension</title>
  921. <p>The include-page-segment extension element allows to define resource substitution for fo:external-graphics elements.
  922. Example:</p>
  923. <source><![CDATA[
  924. <fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format"
  925. xmlns:afp="http://xmlgraphics.apache.org/fop/extensions/afp">
  926. <fo:layout-master-set>
  927. <fo:simple-page-master master-name="simple">
  928. <afp:include-page-segment name="S1ISLOGO" src="../../resources/images/bgimg300dpi.jpg" />
  929. <fo:region-body/>
  930. </fo:simple-page-master>
  931. </fo:layout-master-set>
  932. ]]></source>
  933. <p>The include-page-segment extension element can only occur within a simple-page-master.
  934. Multiple include-page-segment extension elements within a simple-page-master are allowed.
  935. The mandatory name attribute must refer to an 8 character
  936. (space padded) resource name that must be known in the AFP processing environment.
  937. The value of the mandatory src attribute is compared against the value of the src attribute in
  938. fo:external-graphic elements and if it is identical (string matching is used) in the generated
  939. AFP the external graphic is replaced by a reference to the given resource.
  940. </p>
  941. <p>
  942. The effect here is that whenever FOP encounters the URI specified in the extension,
  943. it will effectively generate code to include the page segment with the given name
  944. instead of embedding the image referenced by the URI. The URI is still required as
  945. the underlying image serves as a provider for the intrinsic size of the image
  946. (At the moment, FOP is unable to extract the intrinsic size of the page segment from
  947. an AFP resource file). For the image to appear in an AFP viewer or to be printed, the
  948. AFP resource must be available on the target device. FOP does not embed the page
  949. segment in the generated file. Please also note that page segments cannot be scaled.
  950. They are always rendered in their intrinsic size.
  951. </p>
  952. <p>
  953. The include-page-segment extension element has the optional attribute
  954. <i>resource-file</i>. The value of this is a URI to a resource containing a page
  955. segment with the declared name. In this case FOP embeds the page segment into the
  956. generated document so that the external resource does not have to be supplied in the
  957. print job.
  958. </p>
  959. </section>
  960. <section id="afp-tag-logical-element">
  961. <title>Tag Logical Element (TLE) Extension</title>
  962. <p>The tag-logical-element extension element allows to injects TLEs into the AFP output stream. Example:</p>
  963. <source><![CDATA[
  964. <fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format"
  965. xmlns:afp="http://xmlgraphics.apache.org/fop/extensions/afp">
  966. <fo:layout-master-set>
  967. <fo:simple-page-master master-name="simple">
  968. <afp:tag-logical-element name="The TLE Name" value="The TLE Value" />
  969. <fo:region-body/>
  970. </fo:simple-page-master>
  971. </fo:layout-master-set>
  972. [..]
  973. <fo:page-sequence master-reference="simple">
  974. <afp:tag-logical-element name="foo" value="bar"/>
  975. <fo:flow flow-name="xsl-region-body">
  976. [..]
  977. ]]></source>
  978. <p>
  979. The tag-logical-element extension element can appear within a simple-page-master
  980. (page level) or it can appear as child of page-sequence (page group level).
  981. Multiple tag-logical-element extension elements within a simple-page-master or
  982. page-sequence are allowed. The name and value attributes are mandatory.
  983. </p>
  984. </section>
  985. <section id="afp-no-operation">
  986. <title>No Operation (NOP) Extension</title>
  987. <p>The no-operation extension provides the ability to carry up to 32K of comments or any other type
  988. of unarchitected data into the AFP output stream. Example:</p>
  989. <source><![CDATA[
  990. <fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format"
  991. xmlns:afp="http://xmlgraphics.apache.org/fop/extensions/afp">
  992. <fo:layout-master-set>
  993. <fo:simple-page-master master-name="simple">
  994. <afp:no-operation name="My NOP">insert up to 32k of character data here!</afp:no-operation>
  995. </fo:simple-page-master>
  996. </fo:layout-master-set>
  997. ]]></source>
  998. <p>The no-operation extension element can appear as child of
  999. <code>simple-page-master</code> (appears after "Begin Page" BPG),
  1000. <code>page-sequence</code> (appears after "Begin Named Page Group" BNG
  1001. and <code>declarations</code> (appears after "Begin Document" BDT).
  1002. Multiple no-operation extension elements inside the same formatting object are allowed.
  1003. Each NOP will appear right after the respective "Begin" field indicated above even if it
  1004. is specified as the last child under its parent. The order inside the parent
  1005. will be maintained.
  1006. The "placement" attribute can be used to have the NOP appear before
  1007. the "End" field of the object rather than after the "Begin" field. Specify
  1008. <code>placement="before-end"</code> to do that. Please note that, at the moment, this only
  1009. has an effect for NOPs that are children of the <code>page-sequence</code> formatting
  1010. object.
  1011. The "name" attribute is mandatory but will not appear inside the AFP stream.
  1012. </p>
  1013. </section>
  1014. <section id="afp-invoke-medium-map">
  1015. <title>Invoke Medium Map (IMM) Extension</title>
  1016. <p>
  1017. The invoke-medium-map extension allows to generate IMM fields (Invoke Medium Map) in the
  1018. generated AFP output. Example:
  1019. </p>
  1020. <source><![CDATA[
  1021. <fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format"
  1022. xmlns:afp="http://xmlgraphics.apache.org/fop/extensions/afp">
  1023. [..]
  1024. <fo:page-sequence master-reference="normal">
  1025. <afp:invoke-medium-map name="MYMAP"/>
  1026. <fo:flow flow-name="xsl-region-body">
  1027. [..]
  1028. ]]></source>
  1029. <p>
  1030. The invoke-medium-map element is allowed as child of fo:page-sequence (page group
  1031. level) or fo:simple-page-master. It is NOT supported on document level (fo:root), yet.
  1032. FOP also doesn't support specifying medium maps inside XML (using BMM/EMM). It can
  1033. only reference an existing medium map by name. The medium map has to be constructed
  1034. through different means and available on the target platform.
  1035. </p>
  1036. </section>
  1037. <section id="afp-form-maps">
  1038. <title>Form Maps/Defs</title>
  1039. <p>
  1040. Apache FOP supports embedding an external form map resource in the
  1041. generated AFP output. This is done using the <code>afp:include-form-map</code>
  1042. extension. An example:
  1043. </p>
  1044. <source><![CDATA[
  1045. <fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format"
  1046. xmlns:afp="http://xmlgraphics.apache.org/fop/extensions/afp">
  1047. [..]
  1048. <fo:declarations>
  1049. <afp:include-form-map name="F1SAMP1" src="file:f1samp1.fde"/>
  1050. </fo:declarations>
  1051. ]]></source>
  1052. <p>
  1053. The <code>afp:include-form-map</code> is to be placed as a direct child of
  1054. <code>fo:declarations</code>. The <code>name</code> is an AFP resource name
  1055. (max. 8 characters) and the <code>src</code> attribute is the URI identifying the
  1056. external form map resource. When such a form map is embedded, you can use the
  1057. <code>afp:invoke-medium-map</code> extension (described above) to invoke any medium
  1058. map included in the form map.
  1059. </p>
  1060. <note>
  1061. Apache FOP doesn't support a way to define a form map or medium map using XML means
  1062. inside an XSL-FO document. You will have to build the form map with some third-party
  1063. tool.
  1064. </note>
  1065. </section>
  1066. </section>
  1067. <section id="afp-foreign-attributes">
  1068. <title>Foreign Attributes</title>
  1069. <section id="afp-foreign-attributes-resource">
  1070. <title>Resource</title>
  1071. <p>The resource foreign attributes provides the ability to name and control where data object resources
  1072. (e.g. images/scalable vector graphics) will reside in the AFP output.
  1073. The afp foreign attributes are only used in conjuntion with &lt;fo:external-graphic/&gt; and &lt;instream-foreign-object/&gt;.
  1074. Example:</p>
  1075. <source><![CDATA[
  1076. <fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format"
  1077. xmlns:afp="http://xmlgraphics.apache.org/fop/extensions/afp">
  1078. ...
  1079. <fo:block>
  1080. <fo:external-graphic width="2.0cm" content-width="2.0cm" height="1.8cm" content-height="1.8cm"
  1081. src="examples/fo/graphics/xml_feather.gif"
  1082. afp:resource-name="feather" afp:resource-level="external" afp:resource-group-file="resources.afp"/>
  1083. </fo:block>
  1084. <fo:block>
  1085. <fo:instream-foreign-object height="758.047pt" content-height="758.047pt" width="576.96pt" content-width="576.96pt"
  1086. afp:resource-name"circles" afp:resource-level="inline">
  1087. <svg xmlns="http://www.w3.org/2000/svg" width="12cm" height="12cm">
  1088. <g style="fill-opacity:0.7; stroke:black; stroke-width:0.1cm;">
  1089. <circle cx="6cm" cy="2cm" r="100" style="fill:red;" transform="translate(0,50)" />
  1090. <circle cx="6cm" cy="2cm" r="100" style="fill:blue;" transform="translate(70,150)" />
  1091. <circle cx="6cm" cy="2cm" r="100" style="fill:green;" transform="translate(-70,150)"/>
  1092. </g>
  1093. </svg>
  1094. </fo:instream-foreign-object>
  1095. </fo:block>
  1096. ]]></source>
  1097. <p>The resource-level attribute where the resource object will reside in the AFP output datastream.
  1098. The possible values for this are "inline", "print-file" and "external".
  1099. When "external" is used a resource-group-file attribute must also be specified.
  1100. Please refer to the <link href="#afp-resource-level-defaults">Resource Level Defaults</link>
  1101. above to see what is used if the resource-level attribute is not specified.
  1102. </p>
  1103. <p/>
  1104. </section>
  1105. </section>
  1106. </section>
  1107. <section id="rtf">
  1108. <title>RTF</title>
  1109. <p>
  1110. JFOR, an open source XSL-FO to RTF converter has been integrated into Apache FOP.
  1111. This will create an RTF (rich text format) document that will
  1112. attempt to contain as much information from the XSL-FO document as
  1113. possible. It should be noted that is not possible (due to RTF's limitations) to map all
  1114. XSL-FO features to RTF. For complex documents, the RTF output will never reach the feature
  1115. level from PDF, for example. Thus, using RTF output is only recommended for simple documents
  1116. such as letters.
  1117. </p>
  1118. <p>
  1119. The RTF output follows Microsoft's RTF specifications
  1120. and produces best results on Microsoft Word.
  1121. </p>
  1122. <note>RTF output is currently unmaintained and lacks many features compared to other output
  1123. formats. Using other editable formats like Open Document Format, instead of producing XSL-FO
  1124. then RTF through FOP, might give better results.</note>
  1125. <p>
  1126. These are some known restrictions compared to other supported output formats (not a complete list):
  1127. </p>
  1128. <ul>
  1129. <li>
  1130. Not supported/implemented:
  1131. <ul>
  1132. <li>break-before/after (supported by the RTF library but not tied into the RTFHandler)</li>
  1133. <li>fo:page-number-citation-last</li>
  1134. <li>keeps (supported by the RTF library but not tied into the RTFHandler)</li>
  1135. <li>region-start/end (RTF limitation)</li>
  1136. <li>multiple columns</li>
  1137. </ul>
  1138. </li>
  1139. <li>Only a single page-master is supported</li>
  1140. <li>Not all variations of fo:leader are supported (RTF limitation)</li>
  1141. <li>percentages are not supported everywhere</li>
  1142. </ul>
  1143. </section>
  1144. <section id="xml">
  1145. <title>XML (Area Tree XML)</title>
  1146. <p>
  1147. This is primarily for testing and verification. The XML created is simply
  1148. a representation of the internal area tree put into XML. We use that to verify
  1149. the functionality of FOP's layout engine.
  1150. </p>
  1151. <p>
  1152. The other use case of the Area Tree XML is as FOP's "intermediate format". More information
  1153. on that can be found on the page dedicated to the <a href="intermediate.html">Intermediate Format</a>.
  1154. </p>
  1155. </section>
  1156. <section id="awt">
  1157. <title>Java2D/AWT</title>
  1158. <p>
  1159. The Java2DRenderer provides the basic functionality for all
  1160. Java2D-based output formats (AWT viewer, direct print, PNG, TIFF).
  1161. </p>
  1162. <p>
  1163. The AWT viewer shows a window with the pages displayed inside a
  1164. Java graphic. It displays one page at a time.
  1165. The fonts used for the formatting and viewing depend on the fonts
  1166. available to your JRE.
  1167. </p>
  1168. </section>
  1169. <section id="print">
  1170. <title>Print</title>
  1171. <p>
  1172. It is possible to directly print the document from the command line.
  1173. This is done with the same code that renders to the Java2D/AWT renderer.
  1174. </p>
  1175. <section id="print-issues">
  1176. <title>Known issues</title>
  1177. <p>
  1178. If you run into the problem that the printed output is incomplete on Windows:
  1179. this often happens to users printing to a PCL printer.
  1180. There seems to be an incompatibility between Java and certain PCL printer drivers
  1181. on Windows. Since most network-enabled laser printers support PostScript, try
  1182. switching to the PostScript printer driver for that printer model.
  1183. </p>
  1184. </section>
  1185. </section>
  1186. <section id="bitmap">
  1187. <title>Bitmap (TIFF/PNG)</title>
  1188. <p>
  1189. It is possible to directly create bitmap images from the individual
  1190. pages generated by the layout engine.
  1191. This is done with the same code that renders to the Java2D/AWT renderer.
  1192. </p>
  1193. <p>
  1194. Currently, two output formats are supported: PNG and TIFF. TIFF produces
  1195. one file with multiple pages, while PNG output produces one file per
  1196. page. Note: FOP can only produce multiple files (with PNG output) if
  1197. you can set a <code>java.io.File</code> indicating the primary PNG file
  1198. using the <code>FOUserAgent.setOutputFile(File)</code> method.
  1199. </p>
  1200. <p>
  1201. The quality of the bitmap depends on the target resolution setting
  1202. on the FOUserAgent and on further settings described below.
  1203. </p>
  1204. <section id="bitmap-configuration">
  1205. <title>Configuration</title>
  1206. <p>
  1207. The TIFF and PNG renderer configuration currently allows the following settings:
  1208. </p>
  1209. <source><![CDATA[<renderer mime="image/png">
  1210. <color-mode>rgba</color-mode>
  1211. <transparent-page-background>true</transparent-page-background>
  1212. <background-color>white</background-color>
  1213. <anti-aliasing>true</anti-aliasing>
  1214. <rendering>quality</rendering>
  1215. <fonts><!-- described elsewhere --></fonts>
  1216. </renderer>]]></source>
  1217. <p>
  1218. The default value for the <code>"color-mode"</code> setting is <code>"rgba"</code> which
  1219. is equivalent to a 24bit RGB image with an 8bit alpha channel for transparency.
  1220. Valid values are:
  1221. </p>
  1222. <ul>
  1223. <li><code>rgba</code>: RGB with alpha channel (24bit + 8bit = 32bit)</li>
  1224. <li><code>rgb</code>: RGB (24bit)</li>
  1225. <li><code>gray</code>: gray (8bit)</li>
  1226. <li><code>bi-level</code> (or <code>binary</code>): bi-level (1bit)</li>
  1227. </ul>
  1228. <p>
  1229. Please note that there is currently no dithering or error diffusion available for bi-level
  1230. bitmap output.
  1231. </p>
  1232. <p>
  1233. The default value for the <code>"transparent-page-background"</code> setting is
  1234. <code>"false"</code> which paints an opaque, white background for the whole image.
  1235. If you set this to <code>"true"</code>,
  1236. no such background will be painted and you will get a transparent image if
  1237. an alpha channel is available in the output format.
  1238. </p>
  1239. <p>
  1240. The default value for the <code>"background-color"</code> setting is <code>"white"</code>.
  1241. The color specifies in which color the page background is painted. It will only be
  1242. painted if <code>"transparent-page-background"</code> is not set to <code>"true"</code>.
  1243. All XSL-FO colors (including color functions) can be used.
  1244. </p>
  1245. <p>
  1246. The default value for the <code>"anti-aliasing"</code> setting is <code>"true"</code>.
  1247. You can set this value to <code>"false"</code> to disable anti-aliasing and
  1248. thus improve rendering speeds a bit at the loss of some image quality.
  1249. </p>
  1250. <p>
  1251. The default value for the <code>"rendering"</code> setting is <code>"true"</code>.
  1252. You can set this value to <code>"false"</code> to improve rendering speeds a bit
  1253. at the loss of some image quality. If this setting has an actual effect depends
  1254. on the JVM's Java2D backend.
  1255. </p>
  1256. </section>
  1257. <section id="tiff-configuration">
  1258. <title>TIFF-specific Configuration</title>
  1259. <p>
  1260. In addition to the above values the TIFF renderer configuration allows some additional
  1261. settings:
  1262. </p>
  1263. <source><![CDATA[<renderer mime="image/tiff">
  1264. <transparent-page-background>true</transparent-page-background>
  1265. <compression>CCITT T.6</compression>
  1266. <fonts><!-- described elsewhere --></fonts>
  1267. </renderer>]]></source>
  1268. <p>
  1269. The default value for the "compression" setting is "PackBits" which
  1270. which is a widely supported RLE compression scheme for TIFF. The set of compression
  1271. names to be used here matches the set that the Image I/O API uses. Note that
  1272. not all compression schemes may be available during runtime. This depends on the
  1273. actual codecs being available. Here is a list of possible values:
  1274. </p>
  1275. <ul>
  1276. <li><code>NONE</code> (no compression)</li>
  1277. <li><code>PackBits</code> (RLE, run-length encoding)</li>
  1278. <li><code>JPEG</code></li>
  1279. <li><code>Deflate</code></li>
  1280. <li><code>LZW</code></li>
  1281. <li><code>ZLib</code></li>
  1282. <li><code>CCITT T.4</code> (Fax Group 3)</li>
  1283. <li><code>CCITT T.6</code> (Fax Group 4)</li>
  1284. </ul>
  1285. <p>
  1286. This setting may override any setting made using the <code>"color-mode"</code>. For example, if
  1287. <code>"CCITT T.6"</code> is selected, the color mode is automatically forced to <code>"bi-level"</code> because
  1288. this compression format only supports bi-level images.
  1289. </p>
  1290. <note>
  1291. If you want to use CCITT compression, please make sure you've got
  1292. <a href="http://java.sun.com/products/java-media/jai/current.html">
  1293. Java Advanced Imaging Image I/O Tools
  1294. </a>
  1295. in your classpath. The Sun JRE doesn't come with a TIFF codec built in, so it has to be
  1296. added separately. The internal TIFF codec from XML Graphics Commons only supports PackBits,
  1297. Deflate and JPEG compression for writing.
  1298. </note>
  1299. </section>
  1300. <section id="bitmap-rendering-options">
  1301. <title>Runtime Rendering Options</title>
  1302. <p>
  1303. The IF-based bitmap output implementations support a rendering option with the key
  1304. "target-bitmap-size" (value: java.awt.Dimension) that allows to force the pages to
  1305. be proportionally fit into a bitmap of a given size. This can be used to produce
  1306. thumbnails or little preview images of the individual pages. An example:
  1307. </p>
  1308. <source><![CDATA[userAgent.getRenderingOptions().put(
  1309. "target-bitmap-size", new Dimension(320, 200));]]></source>
  1310. </section>
  1311. </section>
  1312. <section id="txt">
  1313. <title>TXT</title>
  1314. <p>
  1315. The text renderer produces plain ASCII text output
  1316. that attempts to match the output of the PDFRenderer as closely as
  1317. possible. This was originally developed to accommodate an archive system
  1318. that could only accept plain text files, and is primarily useful for getting
  1319. a quick-and-dirty view of the document text. The renderer is very limited,
  1320. so do not be surprised if it gives unsatisfactory results.
  1321. </p>
  1322. <!-- OBSOLETE OBSOLETE OBSOLETE
  1323. <p>
  1324. The Text renderer works with a fixed size page buffer. The size of this
  1325. buffer is controlled with the textCPI and textLPI public variables.
  1326. The textCPI is the effective horizontal characters per inch to use.
  1327. The textLPI is the vertical lines per inch to use. From these values
  1328. and the page width and height the size of the buffer is calculated.
  1329. The formatting objects to be rendered are then mapped to this grid.
  1330. Graphic elements (lines, borders, etc) are assigned a lower priority
  1331. than text, so text will overwrite any graphic element representations.
  1332. </p>
  1333. -->
  1334. <p>
  1335. Because FOP lays the text onto a grid during layout, there are frequently
  1336. extra or missing spaces between characters and lines, which is generally
  1337. unsatisfactory.
  1338. Users have reported that the optimal settings to avoid such spacing problems are:
  1339. </p>
  1340. <ul>
  1341. <li>font-family="Courier"</li>
  1342. <li>font-size="10pt"</li>
  1343. <li>line-height="10pt"</li>
  1344. </ul>
  1345. </section>
  1346. <section id="sandbox">
  1347. <title>Output Formats in the Sandbox</title>
  1348. <p>
  1349. Due to the state of certain renderers we moved some of them to a "sandbox" area until
  1350. they are ready for more serious use. The renderers and FOEventHandlers in the sandbox
  1351. can be found under src/sandbox and are compiled into build/fop-sandbox.jar during the
  1352. main build. The output formats in the sandbox are marked as such below.
  1353. </p>
  1354. <section id="mif">
  1355. <title>MIF</title>
  1356. <warning>The MIF handler is in the sandbox and not yet functional in FOP Trunk!!! Please help us ressurrect this feature.</warning>
  1357. <p>
  1358. This format is the Maker Interchange Format which is used by
  1359. Adobe Framemaker.
  1360. </p>
  1361. </section>
  1362. <section id="svg">
  1363. <title>SVG</title>
  1364. <warning>The SVG renderer is in the sandbox and may not work as expected in FOP Trunk!!! Please help us improve this feature.</warning>
  1365. <p>
  1366. This format creates an SVG document that has links between the pages.
  1367. This is primarily for slides and creating svg images of pages.
  1368. Large documents will create SVG files that are far too large for
  1369. an SVG viewer to handle. Since FO documents usually have text the
  1370. SVG document will have a large number of text elements.
  1371. The font information for the text is obtained from the JVM in the
  1372. same way as for the AWT viewer. If the SVG is viewed on a
  1373. system where the fonts are different, such as another platform,
  1374. then the page may look wrong.
  1375. </p>
  1376. </section>
  1377. </section>
  1378. <section id="wishlist">
  1379. <title>Wish list</title>
  1380. <p>
  1381. Apache FOP is easily extensible and allows you to add new output formats to enhance FOP's functionality. There's a number of output formats
  1382. which are on our wish list. We're looking for volunteers to help us implement them.
  1383. </p>
  1384. <ul>
  1385. <li>
  1386. <a href="http://en.wikipedia.org/wiki/OpenDocument">ODF (Open Document Format)</a>:
  1387. The standardized successor to OpenOffice's file format.
  1388. </li>
  1389. </ul>
  1390. </section>
  1391. </body>
  1392. </document>