Generic printing service. Printing component provides general print dialog
and easy printing support from application UI. The framework allows printer
selection and basic modifications for printing setups.
Supported printing items are text, tables, lines and images. The underlying
implementation utilises Javas printing framework. Preferences displayed
in the UI depend on the settings returned by it.
Using the API
User must implement the PPrintableDoc-class to get printing framework
to use. Also doPrinting -method must be implemented where all printable
data should be added to the printable document.
public class PrinterImpl extends PPrintableDoc
{
// Default constructor
public PrinterIml()
{
setPageHeader( createPageHeader() );
}
// Adds all printable objects to the printable document.
// With this method print framework is taken to use.
public void doPrinting()
{
...
// Create printable object and set parent for it.
PPrintableObject textObjext = new PPrintText( "Print this.", this );
// Add it to the printable document.
add( textObject );
// Create other printable object. Line requires starting and stopping points.
PPrintableLine lineObject = new PPrintLine(0, 1, 0, 0, this )
// Add it to the printable document.
add( lineObject );
...
}
}
User should wrap printable data to printing framework printable objects,
PPrintText, PPrintLine, PPrintTable, PPrintImage. Then printable documents
should be added to the printable document. Objects are printed in same order
as they are added to the document. User can also add header and footer on
the each printed page. Default header contains just page number between two
lines.
Printable data pagination is made automatically by printing framework.
User should just add all printable data to the printable document and then
printable objects are automatically located to pages.
Printing framework contains Print Dialog where user can modify print settings.
Dialog is opened always when printing framework is launched. User can set
printer and same settings as number of copies, printing range, orientation,
marginals, paper source and size. Pagination is made always according those
user selections and printable page count is shown to user.
Printing framework is independent component and it doesn't require other
components to be taken in use.
Customizing:
Framework can be customised in a couple of ways. User can define different type of
printable objects. Those should extended the PPrintableObject -class.
The new printable object can be added to the printable document.
User can define other PPrintTable cell printers. Default implementation
contains just text printer. User must create new PImageCellPrinter,
if he wants to print images in table. New cell printer must
implement PTableCellPrinter -interface and user must register it to
the PPrintTable -class with setCellPrinter -method.