您的位置:首页 > 编程语言

水晶报表打印知识---编程控制打印

2006-06-01 16:00 507 查看
水晶报表查看器CrystalReportViewer自带打印功能,调用当前系统默认打印机进行打印,但.NET里的水晶版本不支持Web打印,需要水晶报表10以上的版本才支持。另外由于其他原因,我们大多需要自己写代码进行打印,这就牵扯到如何写代码、如何设置打印参数的问题,以下是一些基本知识:

打印的基本代码:

CrystalReport1 report = new CrystalReport1(); //Report为你自己的报表名
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 = "////局域网机器名//打印机名(例如HP 2100)"; //本地打印机直接指定名称
Report.PrintOptions.PrinterName = printerName; //指定打印机名称
Report.PrintOptions.PaperSize = PaperSize.PaperA4; //指定纸张尺寸

report.PrintToPrinter(1, true, 1, 4);

本文由xwdd129编写,转载请注明出处,谢谢!

下面简单就打印中的参数进行说明:

PrintOptions类,提供用于设置报表打印选项的属性和方法。

PrintOptions成员:
PageContentHeight---Int32,获取页面内容的高度
PageContentWidth---Int32,获取页面内容的宽度
PageMargins---获取报表的边距
PageOrientation---获取或设置打印机纸张方向
Pagesize---获取或设置当前打印机纸张的大小
PrinterName---字符串,获取或设置报表所使用的打印机名称

ReportDocument.PrintToPrinter方法
public virtual void PrintToPrinter( int nCopies, bool collated, int startPageN, int endPageN )
nCopies 指明要打印的分数
collated 指明是否逐份打印
startPageN 指明要打印的第一页
endPageN 指明要打印的最后一页
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: