哪位用过RB的知道RBuilder打印指定页怎么搞? 哪位用过RB的知道RBuilder打印指定页怎么搞? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 技术原理 通过在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' delphi 异常处理-如何获得异常错误代号 多线程里,各个线程同时访问的一段代码,需要同步,是什么意思? delphi小问题 多个TGraphicControl放在一起导致闪烁的很厉害,为什么? 请问怎样转换为中文的日期! 超菜,超simple的问题,不要笑偶 ,>>>>>>>><<<<<<<<< 请问如何不使用OutLook发送电子邮件? 问一个最近一直迷惑我的问题? Delphi如何控制\使用word文档 这是什么社会,能力至上!!!!!! adoquery.SQL问题 有用Delphi做浏览器开发的吗
通过在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'