Share via


ReportDocument.PrintToPrinter Method

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.

Namespace CrystalDecisions.CrystalReports.Engine Assembly CrystalDecisions.CrystalReports.Engine (CrystalDecisions.CrystalReports.Engine.dll)

Syntax

'Declaration
Public Overrideable 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
)

Parameters

  • nCopies
    Indicates the number of copies to print.
  • collated
    Indicates whether to collate the pages.
  • startPageN
    Indicates the first page to print.
  • endPageN
    Indicates the last page to print.

Remarks

To print all pages, set the startPageN and endPageN parameters to zero.

Example

This example sets the report's page margins, selects the printer, and prints the report.

'Declaration

      Private Sub PrintReport(ByVal printerName As String)
         Dim margins As PageMargins

         margins = myReportDocument.PrintOptions.PageMargins
         margins.bottomMargin = 350
         margins.leftMargin = 350
         margins.rightMargin = 350
         margins.topMargin = 350
         myReportDocument.PrintOptions.ApplyPageMargins(margins)

         myReportDocument.PrintOptions.PrinterName = printerName

         myReportDocument.PrintToPrinter(1, False, 0, 0)
      End Sub
      
      void PrintReport(String* printerName)
      {
         PageMargins margins;

         margins = reportDocument->PrintOptions->PageMargins;
         margins.bottomMargin = 350;
         margins.leftMargin = 350;
         margins.rightMargin = 350;
         margins.topMargin = 350;
         reportDocument->PrintOptions->ApplyPageMargins(margins);

         reportDocument->PrintOptions->PrinterName = printerName;

         reportDocument->PrintToPrinter(1, false,0,0);
      };
      
      private void PrintReport(string printerName)
      {
         PageMargins margins;

         margins = reportDocument.PrintOptions.PageMargins;
         margins.bottomMargin = 350;
         margins.leftMargin = 350;
         margins.rightMargin = 350;
         margins.topMargin = 350;
         reportDocument.PrintOptions.ApplyPageMargins(margins);

         reportDocument.PrintOptions.PrinterName = printerName;

         reportDocument.PrintToPrinter(1, false,0,0);
      }
      

Version Information

Crystal Reports Basic for Visual Studio 2008

Supported since: Crystal Reports for Visual Studio .NET 2002

See Also

Reference

ReportDocument Class
ReportDocument Members
CrystalDecisions.CrystalReports.Engine Namespace