Home Devices
New Blog Posts: Merging Reports - Part 1 and Part 2

Print Dialog: Page Range, first page

edited February 2007 in Devices
How can I get the page number of the first page to be printed when an user
select the Page Range option on the print dialog?

I found a property call FromPage, that is part of the delphi Tprintdialog,
but I cant found anything like that on the ReportBuilder PrintDialog (I
guess is a TppCustomPrintDialog).

I need to know because of this:

The user must be able to select a certain number of copies on the form, each
copy with a diferent label to be print (the whole report is the same except
for this label).
This functionality was implemented this way:

varFCopy : Integer;
strListaCopias : TStringList;

procedure ReporteBeforePrint(Sender: TObject);
begin
varFCopy := 0;
end;

procedure ReportStartPage(Sender: TObject);
begin
if Report.SecondPass and (Report.AbsolutePage = 1) then
Inc(varFCopy);
end;

procedure lbCopiaPrint(Sender: TObject);
begin
if varFCopy > 0 then
if varFCopy <= strListaCopias.Count then
lbCopia.Caption := strListaCopias.Strings[varFCopy - 1];
end;

And, before calling Report.Print the stringlist strListaCopias is filled
with the proper captions the user select on the form, and then this code is
used:

Report.PrinterSetup.Copies := strListaCopias.Count;

This works fine... almost.
The problem is when the user select to print only certain pages on the
print dialog, then the Report.AbsolutePage = 1 condition (on the
Report.StartPage event) doesnt work and the varFCopy is never incremented...
so the label dont get the proper caption.

I'm thinking of change this condition using the page number of the first
page to be printed on the range, but I cant find this property on the
ReportBuilder PrintDialog.

Any idea?

Thanks a lot in advance.

Comments

  • edited February 2007
    Hi Eugenio,

    In this case, instead of checking the Report.AbsolutPageNo = 1, try
    comparing it to the first value in the page list of the printer device.
    This will accomidate for the possibility that your users might enter a page
    range. Something like the following...

    if ppReport1.PrinterDevice <> nil then
    if ppReport1.SecondPass and (ppReport1.AbsolutePageNo =
    StrToInt(ppReport1.PrinterDevice.PageList[0]))
    Inc(varFCopy);


    --
    Regards,

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

    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
This discussion has been closed.