From: William Victor Mote The Area Tree is an internal representation of the result document. This
is a set of java classes that can put together a set of objects that
@@ -16,7 +16,7 @@ represent the pages and their contents.
The Area Tree follows the description of the area tree in the XSL:FO specification.
-The Area Tree consists of a set of pages, the actual implemenation places +
The Area Tree consists of a set of pages, the actual implemenation places these in a set of page sequences.
@@ -25,7 +25,7 @@ a set of page sequences.The PageViewPort and Page with the regions is created by the LayoutMasterSet. The contents are then placed by the layout managers. Once the layout of a page is complete then it is added to the Area Tree.
-Inside the page is a set of RegionViewport+Region pairs for each region on +
Inside the page is a set of RegionViewport+Region pairs for each region on the page.
@@ -42,7 +42,7 @@ area Word is also used for a group of consecutive characters.The image and instream foreign object areas are placed inside a viewport. The leader (with use content) and unresolved page number areas are resolved to other inline areas.
-Once a LineArea is filled with inline areas then the inline areas need to +
Once a LineArea is filled with inline areas then the inline areas need to be aligned and adjusted to fill the line properly.
@@ -69,8 +69,8 @@ line area or from the block area. so that if a references is resolved during layout the page can be easily found and then fixed. Once all the forward references are resolved then the page is ready to be rendered. -To layout a page any areas that cannot be resolved need to reserve space. -Once the inline area is resolved then the complete line should be adjusted +
To layout a page any areas that cannot be resolved need to reserve space. +Once the inline area is resolved then the complete line should be adjusted to accomodate any change in space used by the area.
@@ -103,7 +103,7 @@ The StorePagesModel stores all the pages so that any page can be later accessed.The Area Tree retains the concept of page sequences (this is not in the area tree in the spec) so that this information can be passed to the -renderer. This is useful for setting the title and organising the groups +renderer. This is useful for setting the title and organising the groups of page sequences.
@@ -113,5 +113,5 @@ of page sequences.
The FO Tree is a representation of the XSL:FO document. This
diff --git a/docs/design/understanding/handling_attributes.xml b/docs/design/understanding/handling_attributes.xml
index 1ae043059..81af0b40f 100644
--- a/docs/design/understanding/handling_attributes.xml
+++ b/docs/design/understanding/handling_attributes.xml
@@ -1,13 +1,13 @@
- Yet to come :)) Yet to come :)) Images may only be needed to be loaded when the image is rendered to the
+ Images may only be needed to be loaded when the image is rendered to the
output or to find the dimensions.
An image url may be invalid, this can be costly to find out so we need to
-keep a list of invalid image urls.
We have a number of different caching schemes that are possible.
All images are referred to using the url given in the XSL:FO after
removing "url('')" wrapping. This does
@@ -25,7 +25,7 @@ have the url as a reference.
The images are handled through a static interface in ImageFactory.
(insert image)
+(insert image)
Yet to come :))
-Yet to come :))
+The PDF Library is an independant package of classes in FOP. These class provide a simple way to construct documents and add the contents. The @@ -26,12 +26,12 @@ There are a number of methods that can be used to create/add certain PDF objects
The PDF Document is built by creating a page for each page in the Area Tree.
This page then has all the contents added. The page is then added to the document and available objects can be written to the output stream.
-The contents of the page are things such as text, lines, images etc. -The PDFRenderer inserts the text directly into a pdf stream. +
The contents of the page are things such as text, lines, images etc. +The PDFRenderer inserts the text directly into a pdf stream. The text consists of markup to set fonts, set text position and add text.
-Most of the simple pdf markup is inserted directly into a pdf stream. +
Most of the simple pdf markup is inserted directly into a pdf stream. Other more complex objects or commonly used objects are added through java classes. -Some pdf objects such as an image consists of two parts.
+Some pdf objects such as an image consists of two parts.It has a separate object for the image data and another bit of markup to display the image in a certain position on the page.
The java objects that represent a pdf object implement a method that returns the markup for inserting into a stream. The method is: byte[] toPDF().
@@ -74,5 +74,5 @@ The method is: byte[] toPDF(). -During XML Parsing, the FO tree is constructed. For each FO object (some
subclass of FObj), the tree builder then passes the list of all
attributes specified on the FO element to the handleAttrs method. This
@@ -115,7 +115,7 @@ but may not be completely up-to-date
The AbstractRenderer does most of the work to iterate through the area -tree parts. This means that the most renderers simply need to implement -the specific parts with inserting text, images and lines. The methods can -easily be overridden to handle things in a different way or do some extra +
The AbstractRenderer does most of the work to iterate through the area +tree parts. This means that the most renderers simply need to implement +the specific parts with inserting text, images and lines. The methods can +easily be overridden to handle things in a different way or do some extra processing.
The fonts are setup by the renderer being used. The font metrics are used +
The fonts are setup by the renderer being used. The font metrics are used during the layout process to determine the size of characters.
The render context is used by handlers. It contains information about the -current state of the renderer. Such as the page, the position and any +
The render context is used by handlers. 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.
Peter said : Do we have a volunteer to track - Keiron's tutorials and turn them into web page documentation?
The answer is yes - we have, but the work is on progress !
The answer is yes + we have, but the work is on progress !
SVG is rendered through Batik.
The XML from the XSL:FO document - is converted into an SVG DOM with batik. This DOM is then set as the Document - on the Foreign Object area in the Area Tree.
This DOM is then available to - be rendered by the renderer.
SVG is rendered in the renderers via an - XMLHandler in the FOUserAgent. This XML handler is used to render the SVG. The - SVG is rendered by using batik. Batik converts the SVG DOM into an internal - structure that can be drawn into a Graphics2D. So for PDF we use a - PDFGraphics2D to draw into.
This creates the necessary PDF information to - create the SVG image in the PDF document.
Most of the work is done in the - PDFGraphics2D class. There are also a few bridges that are plugged into batik - to provide different behaviour for some SVG elements.
Normally batik converts text into a set of curved - shapes.
This is handled as any other shapes when rendering to the output. This - is not always desirable as the shapes have very fine curves. This can cause the - output to look a bit bad in PDF and PS (it can be drawn properly but is not by - default). These curves also require much more data than the original - text.
To handle this there is a PDFTextElementBridge that is set when - using the bridge in batik. If the text is simple enough for the text to be - drawn in the PDF as with all other text then this sets the TextPainter to use - the PDFTextPainter. This inserts the text directly into the PDF using the - drawString method on the PDFGraphics2D.
Text is considered simple if the - font is available, the font size is useable and there are no tspans or other - complications. This can make the resulting PDF significantly - smaller.
To support links in PDF another batik - element bridge is used. The PDFAElementBridge creates a PDFANode which inserts - a link into the PDF document via the PDFGraphics2D.
Since links are - positioned on the page without any transforms then we need to transform the - coordinates of the link area so that they match the current position of the a - element area. This transform may also need to account for the svg being - positioned on the page.
Images are normally drawn - into the PDFGraphics2D. This then creates a bitmap of the image data that can - be inserted into the PDF document.
As PDF can support jpeg images then another - element bridge is used so that the jpeg can be directly inserted into the - PDF.
Batik provides a mechanism to - convert SVG into various formats. Through FOP we can convert an SVG document - into a single paged PDF document. The page contains the SVG drawn as best as - possible on the page. There is a PDFDocumentGraphics2D that creates a - standalone PDF document with a single page. This is then drawn into by batik in - the same way as with the PDFGraphics2D.
When rendering to AWT the SVG is simply drawn onto the - awt canvas using batik.
The PS Renderer uses a similar technique as the - PDF Renderer.
The SVG Renderer simply embeds the SVG inside an svg - element.
SVG is rendered through Batik.
The XML from the XSL:FO document + is converted into an SVG DOM with batik. This DOM is then set as the Document + on the Foreign Object area in the Area Tree.
This DOM is then available to + be rendered by the renderer.
SVG is rendered in the renderers via an + XMLHandler in the FOUserAgent. This XML handler is used to render the SVG. The + SVG is rendered by using batik. Batik converts the SVG DOM into an internal + structure that can be drawn into a Graphics2D. So for PDF we use a + PDFGraphics2D to draw into.
This creates the necessary PDF information to + create the SVG image in the PDF document.
Most of the work is done in the + PDFGraphics2D class. There are also a few bridges that are plugged into batik + to provide different behaviour for some SVG elements.
Normally batik converts text into a set of curved + shapes.
This is handled as any other shapes when rendering to the output. This + is not always desirable as the shapes have very fine curves. This can cause the + output to look a bit bad in PDF and PS (it can be drawn properly but is not by + default). These curves also require much more data than the original + text.
To handle this there is a PDFTextElementBridge that is set when + using the bridge in batik. If the text is simple enough for the text to be + drawn in the PDF as with all other text then this sets the TextPainter to use + the PDFTextPainter. This inserts the text directly into the PDF using the + drawString method on the PDFGraphics2D.
Text is considered simple if the + font is available, the font size is useable and there are no tspans or other + complications. This can make the resulting PDF significantly + smaller.
To support links in PDF another batik + element bridge is used. The PDFAElementBridge creates a PDFANode which inserts + a link into the PDF document via the PDFGraphics2D.
Since links are + positioned on the page without any transforms then we need to transform the + coordinates of the link area so that they match the current position of the a + element area. This transform may also need to account for the svg being + positioned on the page.
Images are normally drawn + into the PDFGraphics2D. This then creates a bitmap of the image data that can + be inserted into the PDF document.
As PDF can support jpeg images then another + element bridge is used so that the jpeg can be directly inserted into the + PDF.
Batik provides a mechanism to + convert SVG into various formats. Through FOP we can convert an SVG document + into a single paged PDF document. The page contains the SVG drawn as best as + possible on the page. There is a PDFDocumentGraphics2D that creates a + standalone PDF document with a single page. This is then drawn into by batik in + the same way as with the PDFGraphics2D.
When rendering to AWT the SVG is simply drawn onto the + awt canvas using batik.
The PS Renderer uses a similar technique as the + PDF Renderer.
The SVG Renderer simply embeds the SVG inside an svg + element.
FOP takes an xml file does its magic and then writes a document to a - stream.
-xml -> [FOP] -> document
+ stream. +xml -> [FOP] -> document
The document could be pdf, ps etc. or directed to a printer or the screen. The principle remains the same. The xml document must be in the XSL:FO - format.
+ format.For convenience we provide a mechanism to handle XML+XSL as - input.
+ input.The xml document is always handled internally as SAX. The SAX events are used to read the elements, attributes and text data of the FO document. After the manipulation of the data the renderer writes out the pages in the appropriate format. It may write as it goes, a page at a time or the whole document at once. Once finished the document should contain all the data in the - chosen format ready for whatever use.
The fo data goes through a few stages. Each piece of data will generally go through the process in the same way but some information may be used a number of times or in a different order. To reduce - memory one stage will start before the previous is completed.
+ memory one stage will start before the previous is completed.SAX Handler -> FO Tree -> Layout Managers -> Area Tree - -> Render -> document
+ -> Render -> documentIn the case of rtf, mif etc.
SAX Handler -> FO Tree ->
- Structure Renderer -> document
The FO Tree is constructed from the xml document. It is an internal representation of the xml document and it is like a DOM with some differences. The Layout Managers use the FO Tree do their layout stuff and create an Area @@ -69,26 +69,26 @@ convert the information into the render format. For example the PDF Renderer creates a PDF Document. For each page in the Area Tree the renderer creates a PDF Page and places the contents of the page into the PDF Page. Once a PDF Page - is complete then it can be written to the output stream.
+ is complete then it can be written to the output stream.For the structure documents the Structure listener will read directly from the FO Tree and create the document. These documents do not need - the layout process or the Area Tree.
Verify Structure Listener - concept.
Since everyone knows the basics we can get - into the various stages starting with the XML handling.
+ into the various stages starting with the XML handling.FOP can take the input XML in a number of ways:
Driver
.
Stream
, String
etc.
The SAX Events which are fired on the SAX Handler, class
FOTreeBuilder
, must represent an XSL:FO document. If not there will be an
- error. Any problems with the XML being well formed are handled here.
The element mapping is a hashmap of all the elements in a particular namespace. This makes it easy to create a different object for each element. Element mappings are static to save on @@ -68,14 +68,14 @@ This must contain a line with the fully qualified name of a class that implements the org.apache.fop.fo.ElementMapping interface. This will then be loaded automatically at the start. Internal mappings are: FO, SVG and Extension - (pdf bookmarks)
The SAX Events will fire all the information for the document with start element, end element, text data etc. This information is used to build up a representation of the FO document. To do this for a namespace there is a set of element mappings. When an element + namepsace mapping is found then it can create an object for that element. If the element is not found then it creates a dummy object or a generic DOM for unknown - namespaces.
+ namespaces.The object is then setup and then given attributes for the element. For the FO Tree the attributes are converted into properties. The FO objects use a property list mapping to convert the attributes into a list of properties @@ -83,7 +83,7 @@ constructed. This DOM can then be passed through to the renderer. Other element mappings can be used in different ways, for example to create elements that create areas during the layout process or setup information for the renderer - etc.
+ etc.While the tree building is mainly about creating the FO Tree there are some stages that can propagate to the renderer. At @@ -98,9 +98,9 @@ sequence. The page may not yet be complete, however, containing forward page number references, for example.)
-