## wxPrintout

This class encapsulates the functionality of printing out an application document. A new class must be derived and members overridden to respond to calls such as OnPrintPage and HasPage. Instances of this class are passed to wxPrinter::Print or a wxPrintPreview object to initiate printing or previewing.

Derived from

wxObject

Include files

<wx/print.h>

See also

Printing framework overview, wxPrinterDC, wxPrintDialog, wxPrinter, wxPrintPreview

Members

wxPrintout::wxPrintout
wxPrintout::~wxPrintout
wxPrintout::GetDC
wxPrintout::GetPageInfo
wxPrintout::GetPageSizeMM
wxPrintout::GetPageSizePixels
wxPrintout::GetPPIPrinter
wxPrintout::GetPPIScreen
wxPrintout::GetTitle
wxPrintout::HasPage
wxPrintout::IsPreview
wxPrintout::OnBeginDocument
wxPrintout::OnEndDocument
wxPrintout::OnBeginPrinting
wxPrintout::OnEndPrinting
wxPrintout::OnPreparePrinting
wxPrintout::OnPrintPage

### wxPrintout::wxPrintout

wxPrintout(const wxString& title = "Printout")

Constructor. Pass an optional title argument - the current filename would be a good idea. This will appear in the printing list (at least in MSW)

### wxPrintout::~wxPrintout

~wxPrintout()

Destructor.

### wxPrintout::GetDC

wxDC * GetDC()

Returns the device context associated with the printout (given to the printout at start of printing or previewing). This will be a wxPrinterDC if printing under Windows, a wxPostScriptDC if printing on other platforms, and a wxMemoryDC if previewing.

### wxPrintout::GetPageInfo

void GetPageInfo(int *minPage, int *maxPage, int *pageFrom, int *pageTo)

Called by the framework to obtain information from the application about minimum and maximum page values that the user can select, and the required page range to be printed. By default this returns 1, 32000 for the page minimum and maximum values, and 1, 1 for the required page range.

If minPage is zero, the page number controls in the print dialog will be disabled.

wxPython note: When this method is implemented in a derived Python class, it should be designed to take no parameters (other than the self reference) and to return a tuple of four integers.

wxPerl note: When this method is overridden in a derived class, it must not take any parameters, an return a 4-element list.

### wxPrintout::GetPageSizeMM

void GetPageSizeMM(int *w, int *h)

Returns the size of the printer page in millimetres.

wxPython note: This method returns the output-only parameters as a tuple.

wxPerl note: In wxPerl this method takes no arguments and returns a 2-element list `( w, h )`

### wxPrintout::GetPageSizePixels

void GetPageSizePixels(int *w, int *h)

Returns the size of the printer page in pixels. These may not be the same as the values returned from wxDC::GetSize if the printout is being used for previewing, since in this case, a memory device context is used, using a bitmap size reflecting the current preview zoom. The application must take this discrepancy into account if previewing is to be supported.

wxPython note: This method returns the output-only parameters as a tuple.

wxPerl note: In wxPerl this method takes no arguments and returns a 2-element list `( w, h )`

### wxPrintout::GetPPIPrinter

void GetPPIPrinter(int *w, int *h)

Returns the number of pixels per logical inch of the printer device context. Dividing the printer PPI by the screen PPI can give a suitable scaling factor for drawing text onto the printer. Remember to multiply this by a scaling factor to take the preview DC size into account.

wxPython note: This method returns the output-only parameters as a tuple.

wxPerl note: In wxPerl this method takes no arguments and returns a 2-element list `( w, h )`

### wxPrintout::GetPPIScreen

void GetPPIScreen(int *w, int *h)

Returns the number of pixels per logical inch of the screen device context. Dividing the printer PPI by the screen PPI can give a suitable scaling factor for drawing text onto the printer. Remember to multiply this by a scaling factor to take the preview DC size into account.

### wxPrintout::GetTitle

wxString GetTitle()

Returns the title of the printout

wxPython note: This method returns the output-only parameters as a tuple.

wxPerl note: In wxPerl this method takes no arguments and returns a 2-element list `( w, h )`

### wxPrintout::HasPage

bool HasPage(int pageNum)

Should be overridden to return TRUE if the document has this page, or FALSE if not. Returning FALSE signifies the end of the document. By default, HasPage behaves as if the document has only one page.

### wxPrintout::IsPreview

bool IsPreview()

Returns TRUE if the printout is currently being used for previewing.

### wxPrintout::OnBeginDocument

bool OnBeginDocument(int startPage, int endPage)

Called by the framework at the start of document printing. Return FALSE from this function cancels the print job. OnBeginDocument is called once for every copy printed.

The base wxPrintout::OnBeginDocument must be called (and the return value checked) from within the overridden function, since it calls wxDC::StartDoc.

wxPython note: If this method is overridden in a Python class then the base class version can be called by using the method `base_OnBeginDocument(startPage, endPage)`.

### wxPrintout::OnEndDocument

void OnEndDocument()

Called by the framework at the end of document printing. OnEndDocument is called once for every copy printed.

The base wxPrintout::OnEndDocument must be called from within the overridden function, since it calls wxDC::EndDoc.

### wxPrintout::OnBeginPrinting

void OnBeginPrinting()

Called by the framework at the start of printing. OnBeginPrinting is called once for every print job (regardless of how many copies are being printed).

### wxPrintout::OnEndPrinting

void OnEndPrinting()

Called by the framework at the end of printing. OnEndPrinting is called once for every print job (regardless of how many copies are being printed).

### wxPrintout::OnPreparePrinting

void OnPreparePrinting()

Called once by the framework to allow the application to perform general preparation tasks.

In wxWindows 2.4, this function is called after GetPageInfo is called, which is not ideal. In wxWindows 2.5, the function is correctly called before GetPageInfo is called. Please see Patch 781346 on SourceForge for a backport of this fix. Unfortunately we cannot apply it to 2.4, for binary compatibility reasons.

### wxPrintout::OnPrintPage

bool OnPrintPage(int pageNum)

Called by the framework when a page should be printed. Returning FALSE cancels the print job. The application can use wxPrintout::GetDC to obtain a device context to draw on.