Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

renderers.xml 8.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229
  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 V1.3//EN" "http://forrest.apache.org/dtd/document-v13.dtd">
  18. <document>
  19. <header>
  20. <title>Apache™ FOP Design: Renderers</title>
  21. <version>$Revision$</version>
  22. <authors>
  23. <person name="Keiron Liddle" email="keiron@aftexsw.com"/>
  24. </authors>
  25. </header>
  26. <body>
  27. <section id="intro">
  28. <title>Introduction</title>
  29. <p>A renderer is primarily designed to convert a given area tree into the output
  30. document format. It should be able to produce pages and fill the pages
  31. with the text and graphical content. Usually the output is sent to
  32. an output stream.</p>
  33. <p>Some output formats may support extra information that is not available
  34. from the area tree or depends on the destination of the document.</p>
  35. <p>Each renderer is given an area tree to render to its output format.
  36. The area tree is simply a representation of the pages and the placement
  37. of text and graphical objects on those pages.</p>
  38. <p>The renderer will be given each page as it is ready and an output stream
  39. to write the data out.
  40. All pages are supplied in the order they appear in the document.
  41. In order to save memory it is
  42. possble to render the pages out of order. Any page that is not ready to
  43. be rendered is setup by the renderer first so that it can reserve a space
  44. or reference for when the page is ready to be rendered.The renderer is responsible for managing the
  45. output format and associated data and flow.</p>
  46. </section>
  47. <section id="issues">
  48. <title>Design Issues</title>
  49. <section id="issue-renderers-responsible">
  50. <title>Renderers are Responsible</title>
  51. <p>Each renderer is totally responsible for its output format.</p>
  52. </section>
  53. <section id="issue-output-stream">
  54. <title>Send Output to a Stream</title>
  55. </section>
  56. </section>
  57. <section id="fonts">
  58. <title>Fonts</title>
  59. <p>Because font metrics (and therefore layout) are obtained in two different ways depending on the renderer, the renderer actually sets up the fonts being used. The font metrics are used
  60. during the layout process to determine the size of characters.</p>
  61. </section>
  62. <section id="context">
  63. <title>Render Context</title>
  64. <p>The render context is used by handlers.
  65. It contains information about the current state of the renderer, such as the page, the position, and any other miscellanous objects that are required to draw into the page.</p>
  66. </section>
  67. <section>
  68. <title>XML Handling</title>
  69. <p>A document may contain information in the form of XML for an image or instream foreign object.
  70. This XML is handled through the user agent.
  71. A standard extension for PDF is the SVG handler.</p>
  72. <p>If there is XML in the SVG namespace it is given to the handler which renders the SVG into the pdf document at the given location.
  73. This separation means that other XML handlers can easily be added.</p>
  74. </section>
  75. <section>
  76. <title>Extensions</title>
  77. <p>Document level extensions are handled with an extension handler.
  78. This handles the information from the AreaTree and adds renders it to the document.
  79. An example is the pdf bookmarks. This information first needs to have all references resolved.
  80. Then the extension handler is ready to put the information into the pdf document.</p>
  81. </section>
  82. <section id="implement">
  83. <title>Renderer Implementations</title>
  84. <table>
  85. <tr>
  86. <th>Name</th>
  87. <th>Type</th>
  88. <th>Font Source</th>
  89. <th>Font Embedding?</th>
  90. <th>Out of Order Rendering?</th>
  91. <th>Notes</th>
  92. </tr>
  93. <tr>
  94. <td>PDF</td>
  95. <td>Paginated</td>
  96. <td>FOP</td>
  97. <td>Yes</td>
  98. <td>Yes</td>
  99. <td>Uses the PDFDocument classes to create a PDF document. Most of the work is to insert text or create lines. SVG is handled by the XML handler that uses the PDFGraphics2D and batik to
  100. draw the svg into the pdf page.</td>
  101. </tr>
  102. <tr>
  103. <td>PostScript</td>
  104. <td>Paginated</td>
  105. <td>FOP</td>
  106. <td>Not implemented</td>
  107. <td>?</td>
  108. <td>Similar to PDF.</td>
  109. </tr>
  110. <tr>
  111. <td>PCL</td>
  112. <td>Paginated</td>
  113. <td>FOP</td>
  114. <td>?</td>
  115. <td>?</td>
  116. <td>Similar to PDF.</td>
  117. </tr>
  118. <tr>
  119. <td>SVG</td>
  120. <td>Paginated</td>
  121. <td>?</td>
  122. <td>?</td>
  123. <td>?</td>
  124. <td>Creates a single svg document that contains all the pages rendered
  125. with page sequences horizontally and pages vertically. Adds
  126. links between the pages so that it can be viewed by clicking on the page
  127. to go to the next page.</td>
  128. </tr>
  129. <tr>
  130. <td>TXT</td>
  131. <td>Paginated</td>
  132. <td>N/A</td>
  133. <td>N/A</td>
  134. <td>No</td>
  135. <td>Outputs to a text document.</td>
  136. </tr>
  137. <tr>
  138. <td>AWT</td>
  139. <td>Paginated</td>
  140. <td>AWT</td>
  141. <td>N/A</td>
  142. <td>?</td>
  143. <td>This draws the pages into an AWT graphic.</td>
  144. </tr>
  145. <tr>
  146. <td>XML</td>
  147. <td>Paginated</td>
  148. <td>FOP</td>
  149. <td>No</td>
  150. <td>No</td>
  151. <td>Creates an XML file that represents the AreaTree.</td>
  152. </tr>
  153. <tr>
  154. <td>Print</td>
  155. <td>Paginated</td>
  156. <td>AWT</td>
  157. <td>?</td>
  158. <td>No</td>
  159. <td>Prints the document using the java printing facitlities. The AWT
  160. rendering is used to draw the pages onto the printjob.</td>
  161. </tr>
  162. <tr>
  163. <td>RTF</td>
  164. <td>Structural</td>
  165. <td>N/A</td>
  166. <td>N/A</td>
  167. <td>No</td>
  168. <td>Structural format uses a different rendering mechanism.</td>
  169. </tr>
  170. <tr>
  171. <td>MIF</td>
  172. <td>Structural</td>
  173. <td>N/A</td>
  174. <td>N/A</td>
  175. <td>No</td>
  176. <td>Structural format uses a different rendering mechanism.</td>
  177. </tr>
  178. </table>
  179. </section>
  180. <section id="add">
  181. <title>Adding a Renderer</title>
  182. <p>You can add other renderers by implementing the Renderer interface.
  183. However, the AbstractRenderer does most of what is needed, including iterating through the tree parts, so it is probably better to extend this.
  184. This means that you only need to implement the basic functionality such as text, images, and lines.
  185. AbstractRenderer's methods can easily be overridden to handle things in a different way or do some extra processing.</p>
  186. <p>The relevent AreaTree structures that will need to be rendered are:</p>
  187. <ul>
  188. <li>Page</li>
  189. <li>Viewport</li>
  190. <li>Region</li>
  191. <li>Span</li>
  192. <li>Block</li>
  193. <li>Line</li>
  194. <li>Inline</li>
  195. </ul>
  196. <p>A renderer implementation does the following:</p>
  197. <ul>
  198. <li>render each individual page</li>
  199. <li>clip and align child areas to a viewport</li>
  200. <li>handle all types of inline area, text, image etc.</li>
  201. <li>draw various lines and rectangles</li>
  202. </ul>
  203. </section>
  204. <section id="multiple">
  205. <title>Multiple Renderers</title>
  206. <p>The layout of the document depends mainly on the font being used.
  207. If two renderers have the same font metrics then it is possible to use the same Area Tree to render both. This can be handled by the AreaTree Handler.</p>
  208. </section>
  209. <section id="status">
  210. <title>Status</title>
  211. <section id="status-todo">
  212. <title>To Do</title>
  213. </section>
  214. <section id="status-wip">
  215. <title>Work In Progress</title>
  216. </section>
  217. <section id="status-complete">
  218. <title>Completed</title>
  219. <ul>
  220. <li>new renderer model</li>
  221. <li>new interface for structured documents, rtf and mif</li>
  222. <li>added handlers for xml in renderer</li>
  223. </ul>
  224. </section>
  225. </section>
  226. </body>
  227. </document>