// Creates the document.
IlvPrintableDocument document
= new IlvPrintableDocument("A Test Document");
// Gets the flow to add text and images.
IlvFlow flow = document.getFlow();
// Sets the style of text and paragraph alignment
// for the title.
IlvFlow.TextStyle style = new IlvFlow.TextStyle();
style.setFont(new Font("Helvetica", Font.BOLD, 20));
style.setAlignment(IlvFlow.TextStyle.CENTER_ALIGNMENT);
flow.setTextStyle(style);
// Adds the title text.
flow.add("The Printing Framework Document Model");
flow.newLine();
// Sets the style of text for the next paragraph.
style.setAlignment(IlvFlow.TextStyle.LEFT_ALIGNMENT);
style.setFont(new Font("Helvetica", Font.PLAIN, 16));
flow.setTextStyle(style);
flow.newLine();
flow.add("The document model provides a structure to define a multiple-page document to be printed. The document model allows you to concentrate your efforts on creating your printable document without worrying about how the document is previewed and printed. The printing framework previews and prints the document for you.");
flow.newLine();
flow.newLine();
flow.add("The following figure shows the relationship between the main classes in the document model:");
flow.newLine();
try {
// Loads an image to add.
Image image = IlvUtil.GetImageFromFile(Class.forName("demos.print.PrintExample"), "model.gif");
// Adds the image to the flow.
flow.add(image, IlvFlow.TOP_ALIGNMENT);
} catch (Exception e) {
}
// Creates the print controller.
IlvPrintingController controller = new IlvPrintingController(document);
// Previews the document.
controller.setPreviewMode(IlvPrintPreviewPanel.CONTINUOUS_MODE);
controller.printPreview(JOptionPane.getRootFrame());