[]
        
(Showing Draft Content)

GrapeCity.ActiveReports.Viewer.Win.Viewer.Print

Print Method

Print(bool)

Initiates the printing process for the currently opened document, either a section or a page report, with the option to display or bypass the print dialog.

Declaration
public bool Print(bool showPrintDialog)
Parameters
Type Name Description
bool showPrintDialog

Specifies whether to display the print dialog before printing. Setting this to true shows the print dialog, allowing the user to select printer settings. Setting this to false bypasses the print dialog and uses the default printer settings.

Returns
Type Description
bool

Returns true if the printing process is initiated successfully; otherwise, returns false. Note that a return value of true does not guarantee the completion of the printing process, but rather the successful initiation of the print job.

Remarks

This overload of the Print method uses default settings for showing the print progress dialog and using a printing thread. To customize these settings, consider using the overload that accepts these parameters explicitly.

Examples
// Assuming 'viewer' is an instance of the Viewer class
// This will print to the default printer without showing the print dialog
bool printSuccess = viewer.Print(showPrintDialog: false);
if (printSuccess)
    MessageBox.Show("Printing initiated successfully.");
else
    MessageBox.Show("Printing failed.");

Print(bool, bool)

Initiates the printing process for the currently opened document, allowing for the display of the print dialog and the print progress dialog based on the provided parameters.

Declaration
public bool Print(bool showPrintDialog, bool showPrintProgressDialog)
Parameters
Type Name Description
bool showPrintDialog

If set to true, the print dialog is displayed, enabling the user to modify printer settings before printing. If set to false, the document is sent directly to the default printer without displaying the print dialog.

bool showPrintProgressDialog

If set to true, a print progress dialog is displayed during the printing process, providing feedback on the print job status. If set to false, the printing process occurs without displaying the progress dialog.

Returns
Type Description
bool

Returns true if the printing process is successfully initiated; otherwise, returns false. Note that a return value of true indicates successful initiation of the print job but does not guarantee its completion.

Remarks

This method offers flexibility in the printing process by allowing the user to choose whether to display the print dialog and the print progress dialog. It is useful for scenarios where either direct printing with default settings is desired or user intervention is required to select specific printer settings.

Examples
// Assuming 'viewer' is an instance of the Viewer class
// This will print the document silently without showing the print dialog or the print progress dialog
bool printSuccess = viewer.Print(showPrintDialog: false, showPrintProgressDialog: false);
if (printSuccess)
    MessageBox.Show("Printing initiated successfully.");
else
    MessageBox.Show("Printing failed.");

Print(bool, bool, bool)

Initiates the printing process for the currently opened document, with options to display the print dialog, the print progress dialog, and to use a separate printing thread.

Declaration
public bool Print(bool showPrintDialog, bool showPrintProgressDialog, bool usePrintingThread)
Parameters
Type Name Description
bool showPrintDialog

If set to true, the print dialog is displayed, allowing the user to select printer settings before printing. If set to false, the document is printed using the default printer settings without displaying the print dialog.

bool showPrintProgressDialog

If set to true, a print progress dialog is displayed during the printing process, providing the user with feedback on the status of the print job. If set to false, the document is printed without displaying the print progress dialog.

bool usePrintingThread

If set to true, the printing process is executed on a separate thread, allowing the UI to remain responsive during printing. If set to false, the printing process is executed on the current thread, which may temporarily block the UI until the print job is completed.

Returns
Type Description
bool

Returns true if the printing process is successfully initiated; otherwise, returns false. Note that a return value of true indicates successful initiation of the print job but does not guarantee its completion.

Remarks

This method provides comprehensive control over the printing process, including whether to display dialogs and whether to use a separate printing thread. It is designed to accommodate various printing scenarios, from direct printing with default settings to interactive printing with user-selected settings.

Examples
// Assuming 'viewer' is an instance of the Viewer class
// This will show both the print dialog and the print progress dialog to the user, and print on the UI thread
bool printSuccess = viewer.Print(showPrintDialog: true, showPrintProgressDialog: true, usePrintingThread: false);
if (printSuccess)
    MessageBox.Show("Printing initiated successfully.");
else
    MessageBox.Show("Printing failed.");
Exceptions
Type Condition
InvalidOperationException

Thrown if the method is called while the document is not in a completed load state.

Print(PrintingSettings)

Initiates the printing process for the currently opened document, using the specified printing settings.

Declaration
public bool Print(PrintingSettings settings)
Parameters
Type Name Description
PrintingSettings settings

The printing settings to be used for this print job. This includes options for showing the print dialog, the print progress dialog, and whether to use a separate printing thread.

Returns
Type Description
bool

Returns true if the printing process is successfully initiated; otherwise, returns false. Note that a return value of true indicates successful initiation of the print job but does not guarantee its completion.

Remarks

This method allows for a flexible printing process by utilizing a PrintingSettings object to specify the desired printing behavior. It is designed to accommodate various printing scenarios, from direct printing with default settings to interactive printing with user-selected settings.

Examples
// Assuming 'viewer' is an instance of the Viewer class
// Configure printing to show print dialog, print progress dialog, and use a separate printing thread
viewer.Print(PrintingSettings.ShowPrintDialog | PrintingSettings.ShowPrintProgressDialog | PrintingSettings.UsePrintingThread);
Exceptions
Type Condition
InvalidOperationException

Thrown if the method is called while the document is not in a completed load state, indicating that the document is not ready for printing.