## wxHtmlEasyPrinting

This class provides very simple interface to printing architecture. It allows you to print HTML documents using only a few commands.

Note

Do not create this class on the stack only. You should create an instance on app startup and use this instance for all printing operations. The reason is that this class stores various settings in it.

Derived from

wxObject

Include files

<wx/html/htmprint.h>

Members

wxHtmlEasyPrinting::wxHtmlEasyPrinting
wxHtmlEasyPrinting::GetParentWindow
wxHtmlEasyPrinting::GetPrintData
wxHtmlEasyPrinting::GetPageSetupData
wxHtmlEasyPrinting::PreviewFile
wxHtmlEasyPrinting::PreviewText
wxHtmlEasyPrinting::PrintFile
wxHtmlEasyPrinting::PrintText
wxHtmlEasyPrinting::PageSetup
wxHtmlEasyPrinting::SetFonts
wxHtmlEasyPrinting::SetHeader
wxHtmlEasyPrinting::SetFooter
wxHtmlEasyPrinting::SetParentWindow

### wxHtmlEasyPrinting::wxHtmlEasyPrinting

wxHtmlEasyPrinting(const wxString& name = "Printing", wxWindow* parentWindow = NULL)

Constructor.

Parameters

name

Name of the printing object. Used by preview frames and setup dialogs.

parentWindow

pointer to the window that will own the preview frame and setup dialogs. May be NULL.

### wxHtmlEasyPrinting::GetParentWindow

wxWindow* GetParentWindow() const

Gets the parent window for dialogs.

### wxHtmlEasyPrinting::GetPrintData

wxPrintData* GetPrintData()

Returns pointer to wxPrintData instance used by this class. You can set its parameters (via SetXXXX methods).

### wxHtmlEasyPrinting::GetPageSetupData

wxPageSetupDialogData* GetPageSetupData()

Returns a pointer to wxPageSetupDialogData instance used by this class. You can set its parameters (via SetXXXX methods).

### wxHtmlEasyPrinting::PreviewFile

bool PreviewFile(const wxString& htmlfile)

Preview HTML file.

Returns false in case of error -- call wxPrinter::GetLastError to get detailed information about the kind of the error.

### wxHtmlEasyPrinting::PreviewText

bool PreviewText(const wxString& htmltext, const wxString& basepath = wxEmptyString)

Preview HTML text (not file!).

Returns false in case of error -- call wxPrinter::GetLastError to get detailed information about the kind of the error.

Parameters

htmltext

HTML text.

basepath

base directory (html string would be stored there if it was in file). It is used to determine path for loading images, for example.

### wxHtmlEasyPrinting::PrintFile

bool PrintFile(const wxString& htmlfile)

Print HTML file.

Returns false in case of error -- call wxPrinter::GetLastError to get detailed information about the kind of the error.

### wxHtmlEasyPrinting::PrintText

bool PrintText(const wxString& htmltext, const wxString& basepath = wxEmptyString)

Print HTML text (not file!).

Returns false in case of error -- call wxPrinter::GetLastError to get detailed information about the kind of the error.

Parameters

htmltext

HTML text.

basepath

base directory (html string would be stored there if it was in file). It is used to determine path for loading images, for example.

### wxHtmlEasyPrinting::PageSetup

void PageSetup()

Display page setup dialog and allows the user to modify settings.

### wxHtmlEasyPrinting::SetFonts

void SetFonts(const wxString& normal_face, const wxString& fixed_face, const int *sizes = NULL)

Sets fonts. See wxHtmlWindow::SetFonts for detailed description.

### wxHtmlEasyPrinting::SetHeader

void SetHeader(const wxString& header, int pg = wxPAGE_ALL)

Set page header. The following macros can be used inside it:

- @DATE@ is replaced by the current date in default format
- @PAGENUM@ is replaced by page number
- @PAGESCNT@ is replaced by total number of pages
- @TIME@ is replaced by the current time in default format
- @TITLE@ is replaced with the title of the document

Parameters

header

HTML text to be used as header.

pg

one of wxPAGE_ODD, wxPAGE_EVEN and wxPAGE_ALL constants.

### wxHtmlEasyPrinting::SetFooter

void SetFooter(const wxString& footer, int pg = wxPAGE_ALL)

Set page footer. The following macros can be used inside it:

- @DATE@ is replaced by the current date in default format
- @PAGENUM@ is replaced by page number
- @PAGESCNT@ is replaced by total number of pages
- @TIME@ is replaced by the current time in default format
- @TITLE@ is replaced with the title of the document

Parameters

footer

HTML text to be used as footer.

pg

one of wxPAGE_ODD, wxPAGE_EVEN and wxPAGE_ALL constants.

### wxHtmlEasyPrinting::SetParentWindow

void SetParentWindow(wxWindow* window)

Sets the parent window for dialogs.