wxRuby Documentation Home

# Wx::Printer

This class represents the Windows or PostScript printer, and is the vehicle through
which printing may be launched by an application. Printing can also
be achieved through using of lower functions and classes, but
this and associated classes provide a more convenient and general
method of printing.

## Derived from

Object

## See also

Printing framework overview, PrinterDC, PrintDialog, Printout, PrintPreview.

## Methods

- Printer.new
- Printer#create_abort_window
- Printer#get_abort
- Printer#get_last_error
- Printer#get_print_dialog_data
- Printer#print
- Printer#print_dialog
- Printer#report_error
- Printer#setup

### Printer.new

Printer.new(%(arg-type)PrintDialogData% data = nil)

Constructor. Pass an optional pointer to a block of print
dialog data, which will be copied to the printer object’s local data.

#### See also

PrintDialogData,
PrintData

### Printer#create_abort_window

create_abort_window(%(arg-type)Window% parent, Printout printout)

Creates the default printing abort window, with a cancel button.

### Printer#get_abort

Boolean get_abort()

Returns true if the user has aborted the print job.

### Printer#get_last_error

PrinterError get_last_error()

Return last error. Valid after calling Print,
print_dialog or
PrintPreview#print. These functions
set last error to PRINTER_NO_ERROR if no error happened.

Returned value is one of the following:

PRINTER_NO_ERROR | No error happened.
PRINTER_CANCELLED | The user cancelled printing.
PRINTER_ERROR | There was an error during printing.

### Printer#get_print_dialog_data

PrintDialogData get_print_dialog_data()

Returns the print data associated with the printer object.

### Printer#print

Boolean print(%(arg-type)Window% parent, Printout printout, Boolean prompt=true)

Starts the printing process. Provide a parent window, a user-defined Printout object which controls
the printing of a document, and whether the print dialog should be invoked first.

Print could return false if there was a problem initializing the printer device context
(current printer not set, for example) or the user cancelled printing. Call
Printer#get_last_error to get detailed
information about the kind of the error.

### Printer#print_dialog

DC print_dialog(%(arg-type)Window% parent)

Invokes the print dialog. If successful (the user did not press Cancel
and no error occurred), a suitable device context will be returned
(otherwise NULL is returned — call
Printer#get_last_error to get detailed
information about the kind of the error).

The application must delete this device context to avoid a memory leak.

### Printer#report_error

report_error(%(arg-type)Window% parent, Printout printout, String message)

Default error-reporting function.

### Printer#setup

Boolean setup(%(arg-type)Window% parent)

Invokes the print setup dialog. Note that the setup dialog is obsolete from
Windows 95, though retained for backward compatibility.

[This page automatically generated from the Textile source at 2023-06-09 00:45:35 +0000]