CD_PRINTER - Printer Driver (cdprint.h)

This driver provides access to a System Default Printer.

The driver works only with the GDI, GDI+ and Cairo base drivers, but it is possible to use it in other platforms without the risk of compilation error. If you attempt to create a canvas in another platform, the function cdCreateCanvas will return NULL.


The canvas is created by calling function cdCreateCanvas(CD_PRINTER, Data), after which other CD functions can be called as usual. The Data string has the following format:

"name [-d]"    or in C style "%s -d"

name is an optional document name that will appear in the printer queue. Optionally, -d displays the system pre-defined printer dialog before starting to print, allowing you to configure the printer's parameters. When using this parameter and the return canvas is NULL, one must assume that the print was canceled by the user.

Any amount of such canvases may exist simultaneously. It is important to note that a call to function cdKillCanvas is required to properly send the data to the printer.

Pages - Use Flush to change to a new page. You can draw first on page 1, then on page 2 and so forth.

Behavior of Functions

This driver is very platform-dependent and depends on the base driver used.

For further detail, see the Behavior of Functions in each base driver: GDI. To use this driver with a context plus base driver is necessary to call cdUseContextPlus(1) before creating the canvas, see the GDI+ and Cairo base drivers. This driver is NOT available for the other base drivers.

Notice that a printer created in Windows has the same limitations as the EMF driver.



Exclusive Attributes



Usually when printing regions filled with patterns you have to compensate for the printer high resolution or the pattern will come out very small. If you don't want to create a high resolution version of your pattern, then the simplest way is to use wdCanvasPattern to resize the pattern to an expected millimeter size. This will increase the pattern raster size so it will be more visible in the printer.

But on some printers the result were not what we expect: