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

PageCount incorrect when DeviceType = dtArchive

edited July 2006 in General
Hi,

Before I actually print my report, I create a dtArchive from the original
and from the copy.

// Printbutton is pressed:
// Save a copy of the invoice into archive
lbKopie.Visible := True;
rbFacturenUIT.ShowPrintDialog := False;
rbFacturenUIT.DeviceType := dtArchive;
rbFacturenUIT.ArchiveFileName := BestandNaam;
rbFacturenUIT.PrinterSetup.DocumentName := BestandNaam;
rbFacturenUIT.Print;
// Save a original of the invoice into archive
lbKopie.Visible := False;
rbFacturenUIT.ShowPrintDialog := False;
rbFacturenUIT.DeviceType := dtArchive;
rbFacturenUIT.ArchiveFileName := BestandNaamORG;
rbFacturenUIT.Print;
// Print the original invoice (show on screen first)
PrintOrigineel := True;
rbFacturenUIT.ShowPrintDialog := True;
rbFacturenUIT.DeviceType := dtScreen;
rbFacturenUIT.Print;

In the BeforePrint-event of the rbFacturenUIT (TppReport) I have added following
code:

lbPagina.Visible := (rbFacturenUIT.PageCount > 1);
lbPaginaNummers.Visible := (rbFacturenUIT.PageCount > 1);

The problem is that this PageCount only seems to be determined when deviceType
= dtScreen
How can I determine the pagecount when DeviceType = dtArchive?

Regards,
Stef

Comments

  • edited July 2006
    Hi Stef,

    The only way to determine the PageCount before the report has printed is to
    create a two pass report and check the PageCount on the second pass. I
    think you are getting away with this for the Screen Device because you are
    already generating the archive file before printing to the screen. The
    BeforePrint event of the report will not fire twice for a two pass report.
    I suggest using the Band.BeforePrint event to set the visibility of the two
    objects, first checking for the pass setting. Something like the
    following...

    procedure TForm1.ppHeaderBand1BeforePrint(Sender: TObject);
    begin
    if rbFacturenUIT.SecondPass then
    begin
    lbPagina.Visible := (rbFacturenUIT.PageCount > 1);
    lbPaginaNummers.Visible := (rbFacturenUIT.PageCount > 1);
    end;
    end;

    --
    Regards,

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

    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited July 2006
    Hello Nico,

    Thank you very much, that did the trick.

    Regards,
    Stef
This discussion has been closed.