zoukankan      html  css  js  c++  java
  • reportbuilder设置打印页范围技巧_delphi教程

    发布时间:2007-12-27 14:31:11  来源:  作者:  点击:895

    2005-6-23 fh@mail.trisunwyse.com
    技术原理
         通过在TppReport的BeforePrint事件中对TPrinterDevice的PageSetting属性和PageList属性进行赋值
    为何要如此处理?
    根据分析ReportBuilder源码,我们得到如下的调用顺序TppViewer -> TppProducer -> TppPrinterDevice -> TppPageRequest -> TppPublisher,其中 TppPageRequest 封装了打印页范围信息,而TppPrinterDevice 负责将指定的页发送到PrinterCanvas

    实现步骤
      1、在调用单元声明一个类私有变量,用于保存打印页范围
      type
        ...
      private
        sPageRange: string;
        ...
      end;
      2、在调用单元声明一个类私有过程,用于处理TppReport.BeforePrint事件
    procedure TfrmMain.ppReportBeforePrint(Sender: TObject);
    begin
      if Sender is TppReport then
        if (Sender as TppReport).PrinterDevice <> nil then
        begin
          (Sender as TppReport).PrinterDevice.PageSetting := psPageList;
          ppTextToPageList(sPageRange, (Sender as TppReport).PrinterDevice.PageList, True);
        end;
    end;
      3、在打印之前设置打印页范围,将TppReport.BeforePrint引导到自定义过程
      sPageRange := 3-5;
      (ppViewer1.Report as TppReport).BeforePrint := ppReportBeforePrint;
      (ppViewer1.Report as TppReport).ShowPrintDialog := False;
      ppViewer1.Print;

    注意事项
      1,如果找不到TppReport类别,在接口引用单元添加ppReport单元
      2,如果找不到psPageList类别,在接口引用单元添加ppTypes单元
      3,如果找不到ppTextToPageList函数,在接口引用单元添加ppUtils单元
      4,sPageRange可以定义三种类型的页范围
         A:起止页:3-10//连接线分隔
         B:分隔页:3,5,7//逗号分隔
         C:单独页:7

  • 相关阅读:
    ウェブプロジャクトがジャワープロジャクトに参照する方法
    web.xml 中的listener、 filter、servlet 加载顺序及其详解
    财富定律
    jsp文件下载完整方法
    使用Axis开发Web Service程序
    CDH安装指南——酒仙网技术
    linux下 putty 的痛苦编译之路
    博客园
    windows 下 cannal & otter 配置
    Go 1.8 正式发布,编译时间比 Go 1.7 提高约 15%
  • 原文地址:https://www.cnblogs.com/leonkin/p/2469991.html
Copyright © 2011-2022 走看看