Programmer Reference : Common Printing : Printing with Common Graphics
Printing with Common Graphics
The drawing process for printing is basically the same as that for drawing on a video display: Obtain a graphics context, and draw graphics and text on a drawable using Common Graphics methods. In the case of a printer shell, the drawable is the printer shell's window.
The major distinction between printed graphics and screen graphics is device resolution. Printers generally have much higher print resolution than video displays, so a pixel on a 300 DPI laser printer is much smaller than a pixel on a 72 DPI video display. Correspondingly, an image drawn on a video display appears much smaller when printed. Because Common Graphics methods are pixel-based, applications that require printing capability must adjust to the resolution of the printing device. Scaling can be done by querying the printer shell resolution and multiplying drawing coordinates by an appropriate factor.
An application requires a graphics context to draw graphics on a printer. A graphics context created for a printer is similar to one created for a video display, with the limitation that a printer graphics context cannot generally be used for a different printer, or even a different print job on the same printer. This is because printer graphics contexts are printer- and print job-specific. For the same reason, a printer graphics context cannot be used for video display play graphics. Also, printer display graphics contexts are reset at the start of each page by the operating system. For this reason, the application must reset any desired graphics context fields in the expose callback before drawing.
Applications should send createGC:values: to a CwPrinterShell window to obtain a graphics context for a printer. It is possible to create more than one graphics context for a print job. default does not return a graphics context suitable for use on a printer.
The font model for printing is the same as that for screen graphics. However, printer fonts generally work only on printers and not on video displays. In addition, video display fonts do not necessarily work on printers, although in practice many do. The application can determine which fonts are supported by both the video and printer displays by comparing the font information returned by listFonts:maxnames: for each display.
Common Printing does not support cursors, because cursors are screen-specific objects. Printed image support (including that for CgIcon) is provided via CgDeviceIndependentImage. Common Printing does not support CgPixmap, because pixmaps are device-specific. Applications must take printer resolution into account when scaling images for the printer.
Last modified date: 01/29/2015