How to print a range of pages from code

edited October 2009 in Devices
I need to print a document splitting it in pages ranges, for example:

Original document : 500 pages

Splitted documents
Number 1 - page 1 to 200
Number 2 - page 201 to 400
Number 3 - pate 401 to the end 500

lPrinterDevice := TppPrinterDevice.Create(self);
lPrinterDevice.Publisher := ppRptDocuments.Publisher;
lPrinterDevice.PageSetting := psPageRange;
ppRptFichaArticulos.PrintToDevices;

The problem is that I don?t know how to define the page ranges. I searched
over all the forums and documentation but I was unable to find a valid
method.
Could you assist me on that?

I?m using Delphi 2006 and Report Builder 10



__________ Informaci?n de ESET NOD32 Antivirus, versi?n de la base de firmas de virus 4527 (20091020) __________

ESET NOD32 Antivirus ha comprobado este mensaje.

http://www.eset.com

Comments

  • edited October 2009
    Hi Joaquin,

    Take a look at demo 124 located in the \Demos\1. Reports\... directory.
    This shows how to print a list of pages. The Page Range entry in the
    printer dialog essentially takes the information and uses it to create a
    page list just like the demo.

    --
    Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com

    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited October 2009
    Hi Nico,
    Thanks for your quick answer. I saw this demo and I considered the
    possibility to select the concrete number of pages to be sent but this is
    not what I?m looking for at all.

    I thought that the property psPageRange was implemented and that was
    possible to indicate the start page and the end page to send. In my case I?m
    working with reports that contain 600 pages or more so to select the first
    200 pages indicating the page number for every one of them I think is not
    the best approach.

    My problem is that I was unable to find how to indicate only the startpage
    and the endpage to use the psPageRange property, but maybe this is not
    possible and the only way is to use the psPageList property. Could you
    confirm me it?

    In the mean time I will try to look for a workaroung using the example you
    indicated me.

    Many many thanks in advance.



  • edited October 2009
    Hi Joaquin,

    When you define a page range in the print dialog, ReportBuilder essentially
    creates a page list as you describe below. Take a look at the
    ppTextToPageList routine located in the ppUtils.pas file. This is what the
    PrintDialog calls to process the page range.

    You can use the routine yourself if you would like to simplify the process
    of creating a page list based on a range. Once the page list is created,
    you can use the same technique used in the example.

    --
    Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com

    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited October 2009

    Reviewing the Print Dialog code is a good way to learn how the Page Range
    feature works.

    Note that the Print Dialog supports two notations for specifying a page
    range. You can specify each page, such as 1,3,10 or you can specify a range
    such as 1-200. Or you can specify a mix of the two. 1, 3, 10-200;

    As an example, you can modify demo 124 as follows...

    ppTextToPageList('1, 5-10', Report.PrinterDevice.PageList, True);

    Which will print page 1 followed by pages 5 thru 10.


    --
    Nard Moseley
    Digital Metaphors
    www.digital-metaphors.com

    Best regards,

    Nard Moseley
    Digital Metaphors
    www.digital-metaphors.com
  • edited October 2009
    Hello Nard and Nico,

    You saved my live. Following your indications I was able to send the pages
    that I wanted without problem. It works very fast and provides me the
    flexibility I needed.

    Thanks for your assistance.

    Cheers.

This discussion has been closed.