C1 Community
ComponentOne Community is a free source for developers and help authors to collaborate and communicate.

Page count before generate

rated by 0 users
This post has 1 Reply | 1 Follower

Not Ranked
Posts 8
viztopiaman Posted: Fri, Jun 26 2009 10:46 AM

My application writes data to a C1PrintDocument and it needs to know the page number where the data starts and and the page number where the data ends. This is used by a complex indexing system that is required by the application. Is there anyway to determine the current page number before doing a final c1PrintDocument.Generate? I know that I can implement an interim Generate and then retrieve the page number as I go along but this appears to slow down the overall print process and, at the same time, create a nasty screen flicker.

Top 10 Contributor
Posts 1,394
C1_Dima replied on Fri, Jul 10 2009 9:18 AM

First, regarding the flicker: I'm assuming your document is attached to a preview. To reduce the flicker, you may attach it only after the first (preliminary) document generation is over.

But more importantly, you should be able to approach this differently. When you generate your document,  you can mark the objects your app creates (e.g. using the RenderObject.UserData property, which can store arbitrary data). Then, after the document has been generated, you can index your document by looping over the document's pages (C1PrintDocument.Pages collection), and for each page going through its Fragments collection. Each fragment is a representation of the render object that produced it, and contains the reference to it, so you can check the UserData and know which object that is. And, because you're looping through the pages collection, you know the page number the object's on. This approach should provide much better performance, and is generally more correct. Hope this helps.

Cheers, Dima.
Page 1 of 1 (2 items) | RSS
Contact ComponentOne: 1.800.858.2739 ©1987-2010 ComponentOne LLC All Rights Reserved.