The crystal report viewer crystalreportviewer comes with the printing function, which calls the default printer of the current system for printing. However, the crystal version in. Net does not support web printing and must be later than 10. For other reasons, most of us need to writeCodePrinting involves how to write code and set print parameters. The following are some basic knowledge:
Print the basic code:
Crystalreport1 report = new crystalreport1 (); // report your own report name
Pagemargins margins;
Margins = report. printoptions. pagemargins;
Margins. bottommargin = 250;
Margins. leftmargin = 350;
Margins. rightmargin = 350;
Margins. topmargin = 350;
// Apply the page margins.
Report. printoptions. applypagemargins (margins );
// Select the printer.
String printername = "\\\\\ LAN machine name \ printer name (for example, HP 2100)"; // specify the name of the local printer directly
Report. printoptions. printername = printername; // specify the printer name
Report. printoptions. papersize = papersize. papera4; // specify the paper size.
Report. printtoprinter (1, true, 1, 4 );
This article is written by xwdd129. For more information, see the source. Thank you!
The following briefly describes the printed parameters:
Printoptions class, which provides attributes and methods for setting the report printing options.
Printoptions members:
Pagecontentheight --- int32, get the height of the page content
Pagecontentwidth --- int32 to get the page content width
Pagemargins --- get the report margins
Pageorientation --- get or set the printer paper direction
Pagesize --- get or set the size of the current printer paper
Printername --- string, used to obtain or set the printer name for the report
ReportDocument. printtoprinter Method
Public Virtual void printtoprinter (INT ncopies, bool collated, int startpagen, int endpagen)
Ncopies indicates the score to be printed
Collated indicates whether to print each copy
Startpagen indicates the first page to be printed
Endpagen indicates the last page to be printed
From: http://blog.csdn.net/xwdd129/archive/2006/06/01/768033.aspx