Phase 3: Rendering the pages
It is the task of the rendering phase to describe the area
tree in the target page description language, so that viewers for that
language can render the pages. Rendering is done page by page. For
each page the rendering system is handed a PageViewport, and it walks
the area subtree below it. For each area it retrieves the traits and
data, and generates the required output.
The layout of a page is not finished until all forward
references on that page have been resolved. As a consequence pages are
finished out of pagination order. Some renderers support out of
order rendering of pages,
AbstractRenderer.supportsOutOfOrder(). If a
renderer does, a finished page is handed over to it
immediately. Otherwise, the layout system keeps finished pages until
all preceding pages are also finished and have been handed over to the
renderer. In principle, the PDF renderer supports out of order
rendering. In current FOP (27 June 2004) this has been disabled
because the support is broken.
This stack at a deep position, rendering a leader in a block
in a flow in the body region, shows some details of rendering. Note
how the hierarchy of the area tree can be recognized. The lower
frames show how the rendering system is called by the layout system:
main[1] where
[1] org.apache.fop.render.pdf.PDFRenderer.renderLeader (PDFRenderer.java:1,266)
[2] org.apache.fop.render.AbstractRenderer.serveVisitor (AbstractRenderer.java:832)
[3] org.apache.fop.area.inline.Leader.acceptVisitor (Leader.java:118)
[4] org.apache.fop.render.AbstractRenderer.renderLineArea (AbstractRenderer.java:610)
[5] org.apache.fop.render.pdf.PDFRenderer.renderLineArea (PDFRenderer.java:830)
[6] org.apache.fop.render.AbstractRenderer.renderBlocks (AbstractRenderer.java:547)
[7] org.apache.fop.render.AbstractRenderer.renderBlock (AbstractRenderer.java:588)
[8] org.apache.fop.render.pdf.PDFRenderer.renderBlock (PDFRenderer.java:513)
[9] org.apache.fop.render.AbstractRenderer.renderBlocks (AbstractRenderer.java:538)
[10] org.apache.fop.render.AbstractRenderer.renderFlow (AbstractRenderer.java:473)
[11] org.apache.fop.render.AbstractRenderer.renderMainReference (AbstractRenderer.java:456)
[12] org.apache.fop.render.AbstractRenderer.renderBodyRegion (AbstractRenderer.java:392)
[13] org.apache.fop.render.AbstractRenderer.renderRegionViewport (AbstractRenderer.java:338)
[14] org.apache.fop.render.AbstractRenderer.renderPageAreas (AbstractRenderer.java:310)
[15] org.apache.fop.render.pdf.PDFRenderer.renderPage (PDFRenderer.java:471)
[16] org.apache.fop.area.RenderPagesModel.addPage (RenderPagesModel.java:117)
[17] org.apache.fop.area.AreaTree.addPage (AreaTree.java:143)
[18] org.apache.fop.layoutmgr.PageLayoutManager.finishPage (PageLayoutManager.java:532)
[19] org.apache.fop.layoutmgr.PageLayoutManager.doLayout (PageLayoutManager.java:231)
Obviously there is a lot to be documented about the rendering
system, and about each renderer separately. Because I do not (yet)
know much about the rendering system, I will have to leave that task
to others. I only add the obvious: Rendering requires precise
programming: spacing and progress calculations, saving and restoring
dimensions, etc. It also requires tracking the state in the output
format.