in

C1 Community

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

Pages collection

Last post 03-31-2008 8:44 AM by Shaila Shah. 5 replies.
Page 1 of 1 (6 items)
Sort Posts: Previous Next
  • 03-27-2008 3:21 PM

    Pages collection

    Hi, Is there any way to loop through all the pages for c1printdocument and find out what is the content on the page after the document is generated?

    I would like to print only specific pages for c1printdocument that has specific content printed? I have more than one services on the document. If the service printed on the page-document is Everyday Economics than I want to send that page to the printer.

     

    Thanks,

    Shaila

    Filed under:
  • 03-28-2008 12:28 AM In reply to

    Re: Pages collection

    When you generate your document, you need to mark the render objects that you want to find later, somehow. Two good options are to use RenderObject.Name or RenderObject.UserData properties for that. Then when the document has been generated, you need to iterate through the document's Pages collection, for each page you need to go through the page's Fragments collection, and recurse over all fragments (each fragment contains the nested fragments in the Children collection). For each fragment, you need to check whether it's RenderObject.Name (or RenderObject.UserData) matches those you're interested in, and if so you may process that page somehow. It is really simpler than it sounds, attached is the sample I posted previously, but modified to allow to select certain "services" and preview the document formed by a subset of pages containing those services - there is very little extra code, just a few lines really. Hope this helps.

    Cheers,
    Dima.
  • 03-28-2008 12:06 PM In reply to

    Re: Pages collection

    Thanks Dima for prompt reply, It worked like a charm.

    Now I can get page indexes for the services I want to print. but I want to send those pages to the physical printer without user clicking on the printer button on printpreview control. Is it possible?

    Thanks,

    Shaila

  • 03-28-2008 12:39 PM In reply to

    Re: Pages collection

    Hi Dima,

    I used the previewpane.print method to send the document with selected pages to the printer dynamically. But it pops up the print dialog to select the printer. Is there any way to get rid of that dialog and prints the document directly?

  • 03-28-2008 4:05 PM In reply to

    Re: Pages collection

    The following code will print to the default printer without any dialogs:

                    C1.C1Preview.C1PrintManager pm = new C1PrintManager();
                    pm.Document = matches;
                    pm.Print(new System.Drawing.Printing.PrinterSettings());

    There are a number of hopefully self-explaining options on PrintManager that you can adjust to you liking. 

    I attached the modified sample. Hope this helps.

    Cheers,
    Dima.
  • 03-31-2008 8:44 AM In reply to

    Re: Pages collection

    Thanks a lot....

Page 1 of 1 (6 items)
Contact ComponentOne: 1.800.858.2739 ©1987-2008 ComponentOne LLC All Rights Reserved.