Prints the specified pages of the report to the printer selected using the PrintOptions.PrinterName property. If no printer is selected, the default printer specified in the report will be used.
Public Overridable Sub PrintToPrinter(ByVal nCopies As Integer, ByVal collated As Boolean, ByVal startPageN As Integer, ByVal endPageN As Integer)
public virtual void PrintToPrinter(int nCopies, bool collated, int startPageN, int endPageN);
public: virtual void PrintToPrinter(int nCopies, bool collated, int startPageN, int endPageN);
public void PrintToPrinter(int nCopies, boolean collated, int startPageN, int endPageN);
To print all pages, set the startPageN and endPageN parameters to zero.
The following example sets the report's page margins, selects the printer, and prints the report.
Private Sub PrintReport(ByVal printerName As String) Dim margins As PageMargins ' Get the PageMargins structure and set the ' margins for the report. margins = Report.PrintOptions.PageMargins margins.bottomMargin = 350 margins.leftMargin = 350 margins.rightMargin = 350 margins.topMargin = 350 ' Apply the page margins. Report.PrintOptions.ApplyPageMargins(margins) ' Select the printer. Report.PrintOptions.PrinterName = printerName' Print the report. Set the startPageN and endPageN' parameters to 0 to print all pages.Report.PrintToPrinter(1, False, 0, 0)End Sub
private void PrintReport(string printerName)
{
PageMargins margins;
// Get the PageMargins structure and set the
// margins for the report.
margins = Report.PrintOptions.PageMargins;
margins.bottomMargin = 350;
margins.leftMargin = 350;
margins.rightMargin = 350;
margins.topMargin = 350;
// Apply the page margins.
Report.PrintOptions.ApplyPageMargins(margins);
// Select the printer.
Report.PrintOptions.PrinterName = printerName;
// Print the report. Set the startPageN and endPageN
// parameters to 0 to print all pages.
Report.PrintToPrinter(1, false,0,0);
}
void PrintReport(String* printerName)
{
PageMargins margins;
// Get the PageMargins structure and set the
// margins for the report.
margins = Report->PrintOptions->PageMargins;
margins.bottomMargin = 350;
margins.leftMargin = 350;
margins.rightMargin = 350;
margins.topMargin = 350;
// Apply the page margins.
Report->PrintOptions->ApplyPageMargins(margins);
// Select the printer.
Report->PrintOptions->PrinterName = printerName;
// Print the report. Set the startPageN and endPageN
// parameters to 0 to print all pages.
Report->PrintToPrinter(1, false,0,0);
};
private void printReport2( String printerName )
{
PageMargins margins;
// Get the PageMargins structure and set the
// margins for the report.
margins = Report.get_PrintOptions().get_PageMargins();
margins.bottomMargin = 350;
margins.leftMargin = 350;
margins.rightMargin = 350;
margins.topMargin = 350;
// Apply the page margins.
Report.get_PrintOptions().ApplyPageMargins( margins );
// Select the printer.
Report.get_PrintOptions().set_PrinterName( printerName );
// parameters to 0 to print all pages.
// Print the report. Set the startPageN and endPageN
Report.PrintToPrinter( 1, false, 0, 0 );
}
Namespace: CrystalDecisions.CrystalReports.Engine
Platforms: Windows 2000, Windows XP, Windows 2003
ReportDocument Class | ReportDocument Members | CrystalDecisions.CrystalReports.Engine Namespace