Render Objects
The actual creation (drawing) of document content is done by drawing various render objects (a set of classes deriving from a common base class RenderObject) either at specific positions on a page (direct rendering) or in the block flow (block rendering). Objects rendered into the block flow (see figure below) are automatically positioned one below the other, and column and page breaks are added automatically when there is not enough space on the current column or page for the object.
The set of provided render object classes includes all the usual drawing primitives, such as RenderText, RenderImage and so on, plus some more complex classes providing higher-level functionality, such as RenderTable (but all these classes derive from the same root class, so that they can be manipulated in a similar fashion in most circumstances). All render object classes' names begin with the Render prefix. You can create instances of these classes, fine tune their attributes and use them repeatedly (just changing the actual content properties, such as text and images) to render consistent looking content in the document. Two sets of methods are provided, RenderBlock and RenderDirect, for rendering render objects into the block flow and into specific positions on page, respectively.
Alternatively, an extensive set of shortcut methods is provided to allow rendering of text and images directly, without having to create render objects. These methods also begin with the Render prefix, followed by the word specifying block flow or direct rendering (Block or Direct, respectively), followed by the type of content the method renders, for example, RenderBlockText or RenderDirectImage. It is important to note though that internally, these shortcut methods still use render objects, so most of the discussion regarding render objects here still applies (including the discussion of styles, see Styles.
To summarize, two approaches are provided by C1PrintDocument to draw the document content:
• Object approach, when render objects (such as text, images and tables) are created once, their properties are fine-tuned, and then the same render objects are reused (with only the content properties changed each time) to create the document.
• Command approach, when shortcut RenderDirect/RenderInline methods are called repeatedly to create the document.
Which approach to use depends on particular requirements and taste, and both approaches can be freely intermixed if necessary.
|