|
||
Printing is similar to drawing graphics and text to a graphics context, with the printer represented by a graphics device. The picture is complicated by several factors:
A print job may consist of one or more pages: the order of pages, and their headings and footings, is important.
Even a single page cannot be printed in a single operation on
most printers: this would require too much memory. Pages are printed in bands.
Each band is a region of a page. The fundamental class involved in printing is
therefore MPageRegionPrinter
, an interface class whose
PrintBandL()
function is used to print a band.
Print jobs may take a long time, and users appreciate both
notification of progress, and the opportunity to interrupt the job. These
requirements are represented by the MPrintProcessObserver
mixin.
Printing uses an active object which allows other processing to be interleaved with it, on the same thread.
It is vital that text and graphics are the correct size in pixels when printed. All draw operations to a graphics context are specified in pixels. However, the size of a pixel is device-dependent. The absolute, device-independent unit of size supported by the GDI, is the twip — 1/20th of a point, or 1/1440th of an inch. In order to achieve device-independence, a program which supports printing should store its internal model in twips, and convert it into pixels whenever it draws to either a screen-based graphics context, or a printer.
Users like to be able to preview their print jobs before committing them to paper: a print preview facility is therefore provided.
The fonts available on the target printer may be different from those available on the screen. This makes text printing significantly more complex than graphics printing. Much of the complexity is encapsulated by the text layout engine.
There are various models of printers, size of paper, margin specifications etc: an integral part of printing involves setting up these parameters.
The treatment of printing as a graphics-only operation means that printing to text-only printers is not supported (except by direct output to a printer port).
UI variants may provide stock printing dialogs for users to initiate and control print jobs. It is normal for applications that provide printing to supply print job setup (from the Print Framework API) and their printing implementation to use these dialogs.