C1PrintDocument: StartDoc-EndDoc和Generate的对比

很多时候,用户希望在C1PrintDocument中插入新页,他们不知道该使用StartDoc-EndDoc还是使用Generate方法,或者两者都使用。C1PrintDocument的创建既可以使用StartDoc-EndDoc也使用Generate方法。这两者是相似的,但是在实现上有所区别。在本文中,我们讨论创建documents和插入新页的两种方式。StartDoc()-EndDoc() 方法StartDoc方法标记document 产生的开始,在EndDoc方法标记document产生的结束。如果要用StartDoc-EndDoc 方法,render objects需要被添加到document的块中。例如:使用RenderBlock(), RenderDirect() 和RenderInline() 方法,如下所示:c1PrintDocument1.RenderBlock(renderTable1);Generate() MethodGenerate方法使用RefreshCalculatedValues刷新模式产生document。如果要用Generate方法,需要直接添加render objects到document的body。代码如下所示:this.c1PrintDocument1.Body.Children.Add(new C1.C1Preview.RenderText("Hello, World!"));

发布于 2014/12/06 00:00

ComponentOne Enterprise

很多时候,用户希望在C1PrintDocument中插入新页,他们不知道该使用StartDoc-EndDoc还是使用Generate方法,或者两者都使用。

C1PrintDocument的创建既可以使用StartDoc-EndDoc也使用Generate方法。这两者是相似的,但是在实现上有所区别。

在本文中,我们讨论创建documents和插入新页的两种方式。

StartDoc()-EndDoc() 方法

StartDoc方法标记document 产生的开始,在EndDoc方法标记document产生的结束。如果要用StartDoc-EndDoc 方法,render objects需要被添加到document的块中。例如:使用RenderBlock(), RenderDirect() 和RenderInline() 方法,如下所示:

c1PrintDocument1.RenderBlock(renderTable1);

 

Generate() Method

Generate方法使用RefreshCalculatedValues刷新模式产生document。

如果要用Generate方法,需要直接添加render objects到document的body。代码如下所示:

this.c1PrintDocument1.Body.Children.Add(new C1.C1Preview.RenderText("Hello, World!"));

 

虽然上述两种方法都调用来产生文档,他们不必一起使用。如果使用StartDoc,文档已经准备开始产生,这个时候不可能再去调用Generate方法刷新或是重写产生文档。

 

如何使用这些方法插入新页?

1。比如,你使用Generate()方法产生文档就需要在一个已经添加到文档的Render对象之前或之后插入页。例如,如下代码片断可以在两个Render Tables之间插入新页:

c1PrintDocument1..Body.Children.Add(renderTable1);
rt1.BreakAfter = BreakEnum.Page;
c1PrintDocument1.Body.Children.Add(renderTable2);
c1PrintDocument1.Generate();

 

2。当使用StartDoc-EndDoc方法,可以使用C1PrintDocument的NewPage方法很容易的添加新页。代码参考如下: 

c1PrintDocument1.RenderBlock(renderTable1);
c1PrintDocument1.NewPage();
c1PrintDocument1.RenderBlock(renderTable2);

在Demo中有详细的代码,具体附件如下:

C1PrintDocument_NewPage2.zip (53.44 kb)

C1PrintDocument属于C1Report下的接口。如果你对它感兴趣,请到我们的官网下载最新版本:/developer/componentone-winform/controls/reports

如果你有疑问,可以到GCDN论坛获得技术支持:http://gcdn.grapecity.com.cn/showforum-68.html

 

ComponentOne Enterprise | 下载试用

ComponentOne 是一套专注于企业 .NET开发、支持 .NET Core 平台,并完美集成于 Visual Studio 的第三方控件集,包含 300 多种 .NET开发控件,提供表格数据管理、数据可视化、报表和文档、日程安排、输入和编辑、导航和布局、系统提升工具等七大功能,被誉为“.NET开发的‘瑞士军刀’”。

ComponentOne 为您提供专业的产品咨询服务,并由技术支持工程师为您1对1解答。>> 发帖提问

相关产品
推荐相关案例
关注微信
葡萄城社区二维码

关注“葡萄城社区”

加微信获取技术资讯

加微信获取技术资讯

想了解更多信息,请联系我们, 随时掌握技术资源和产品动态