Search
Printing and Print Preview

Print or Preview a Diagram

Call the print method to print the current DiagramView. The printPreview method opens a preview window that shows how the diagram would look when printed on paper.

Settings for Printing

The PrintOptions class exposes the available settings for printing. An instance of this class is accessible by calling the DiagramView's getPrintOptions method. Apart from properties inherited from RenderOptions, the print options object exposes members for customizing the header of printed pages, such as DocumentName, HeaderFormat and HeaderFont.

Size of a Printed Diagram

If the background image is set and the printing of the background image is enabled by performing the RenderOptions.setEnableBackgroundImage method, the size of the printed diagram is defined solely by the document bounds (obtained through the getBounds method). If the actual diagram items occupy only a small portion of the document, there might be some pages printed that do not display any items but just a part of the background image. To avoid that, call resizeToFitItems before printing.

If no background image is used, JDiagram prints only the part of the document containing all items that are both visible (getVisible, setVisible) and printable (getPrintable, setPrintable). That avoids printing blank pages.

Print Scaling

Use the setScale method to print a diagram in larger or smaller proportions than the actual ones.