The IlvFlow class for creating a document with styled text

A document can be filled in one of two ways: either you decide to create pages, fill them with IlvPrintableObject instances, and add them to a document, or you create a document that contains styled text. In the second case you use the IlvFlow class.
The IlvFlow class represents a flow of text with styling attributes that constitutes the content of the document to be printed. A document can have only one IlvFlow object, which is created using:
public IlvFlow IlvPrintableDocument.getFlow()
Once the flow is created you can specify its content using the following methods:
  • void add(String text)
    Adds the specified text to the current paragraph.
  • void add(Image image, int alignment)
    Adds the image to the current line of text using the specified alignment on the line.
  • void add(IlvFlowObject object, int alignment)
    Adds the object in the current line of text using the specified alignment on the line.
The IlvFlowObject interface allows you to add virtually any kind of drawing to a flow. Some Rogue Wave® JViews packages provide classes that implement this interface, so that you can add a Rogue Wave JViews Charts component to a flow of text.
You can also control the paragraphs and the pages of the flow using the following methods:
  • void newLine()
    Starts a new paragraph in the flow of text.
  • void newPage()
    Starts a new page in the flow of text.
Each text added in the flow can be styled using the following method:
  • void setTextStyle(IlvFlow.TextStyle style)
By calling this method, you change the current text style that will be used for the next text added to the flow. The TextStyle object allows you to change the colors (background and foreground color) of the text, the font used, and also the paragraph alignment.