zoukankan      html  css  js  c++  java
  • 水晶报表打印知识编程控制打印

    (引自http://blog.csdn.net/xwdd129/archive/2006/06/01/768033.aspx)
    水晶报表查看器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);


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

    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 指明要打印的最后一页

  • 相关阅读:
    小作业(# 求1-2+3-4+5 ... 99的所有数的和)
    小作业(3、输出 1-100 内的所有奇数 4、输出 1-100 内的所有偶数)
    小作业(求1-100的所有数的和)
    作业小练习(使用while循环输入 1 2 3 4 5 6 8 9 10)
    keepalived介绍
    nginx日志文件配置
    Nginx配置文件编写实例
    Nginx部署流程
    nginx服务介绍
    http协议原理介绍
  • 原文地址:https://www.cnblogs.com/hustcat/p/1227298.html
Copyright © 2011-2022 走看看