Functions for wxPrintPreview class

Objects of this class manage the print preview process. The object is passed a wxPrintout object, and the wxPrintPreview object itself is passed to a wxPreviewFrame object. Previewing is started by initializing and showing the preview frame. Unlike wxPrinter:print/4, flow of control returns to the application immediately after the frame is shown.

Note: The preview shown is only exact on Windows. On other platforms, the wxDC used for preview is different from what is used for printing and the results may be significantly different, depending on how is the output created. In particular, printing code relying on wxDC:getTextExtent/3 heavily (for example, wxHtmlEasyPrinting and other wxHTML classes do) is affected. It is recommended to use native preview functionality on platforms that offer it (macOS, GTK+).

See: Overview printing, wxPrinterDC (not implemented in wx), wxPrintDialog, wxPrintout, wxPrinter, wxPreviewCanvas, wxPreviewControlBar, wxPreviewFrame

wxWidgets docs: wxPrintPreview


Option =
    {printoutForPrinting, wxPrintout:wxPrintout()} |
    {data, wxPrintDialogData:wxPrintDialogData()}


Pass a printout object, an optional printout object to be used for actual printing, and the address of an optional block of printer data, which will be copied to the print preview object's print data.

If printoutForPrinting is non-NULL, a "Print..." button will be placed on the preview frame so that the user can print directly from the preview interface.

Remark: Do not explicitly delete the printout objects once this constructor has been called, since they will be deleted in the wxPrintPreview destructor. The same does not apply to the data argument.

Use isOk/1 to check whether the wxPrintPreview object was created correctly.


Deletes both print preview objects, so do not destroy these objects in your application.


Gets the printout object to be used for printing from within the preview interface, or NULL if none exists.


Returns true if the wxPrintPreview is valid, false otherwise.

It could return false if there was a problem initializing the printer device context (current printer not set, for example).

This refreshes the preview window with the preview image.

It must be called from the preview window's OnPaint member.

The implementation simply blits the preview bitmap onto the canvas, creating a new preview bitmap if none exists.


Sets the frame to be used for displaying the print preview canvas and control bar.


Percent = integer()

Sets the percentage preview zoom, and refreshes the preview canvas accordingly.