Saturday, May 26, 2012

ReportDocument.PrintToPrinter Method

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

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

C#
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);
} 

No comments:

Post a Comment