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

Reading multiple reports from archive and printing in one batch.

edited April 2002 in General
I have a procedure that generated a number of reports that are stored as
archives. I'm reading them with a tppArchiveReader
and want to store the pages to a cache... I try to genereate the pages using
printtodevices, and then store them in a Tlist as a
TppPage. When I try to store the page in the Tlist I receive a "List Index
Out of Bound". I'm using the following code:

while not t_ord_id.eof do
begin
a_reader.ArchiveFileName:=ExtractFilePath(ParamStr(0)) +'temp\ ' +
t_ord_id.FieldByName('ord_id').AsString + '.raf';
a_reader.PrintToDevices;
lPublisher:=a_reader.Publisher;
indice_paginas:=0;
while indice_paginas < a_reader.ArchivePageCount do
begin
lPage := lPublisher.Pages[indice_paginas];
lista_paginas.add(lpage);
end;
end;

where:

t_ord_id= A tabla with numbers that I use to generate the names of the
archives.
lPublisher= TppPublisher
lPage=TppPage
indice_paginas=Integer
ista_paginas= Tlist

What I'm doing wrong? Thanks.

Comments

  • edited April 2002
    You must explicitly tell the publisher to cache pages instead of just
    passing them through to the device. Here's the final code that will run a
    number of different archives, collect the pages from the publisher, and
    print them by creating a TppPrinterDevice;

    var
    lPublisher: TppPublisher;
    liIndex: Integer;
    liFIndex: Integer;
    lPage: TppPage;
    lPDevice: TppPrinterDevice;
    begin

    lPublisher := FReader.Publisher;
    lPublisher.CachePages := True;

    for liFIndex := 0 to 2 do
    begin

    FReader.ArchiveFileName := path + files[liFIndex];

    FReader.PrintToDevices;

    for liIndex := 0 to lPublisher.PageCount - 1 do
    begin
    lPage := TppPage.Create(nil);
    lPage.Assign(lPublisher.Pages[liIndex]);
    plist.Add(lPage)
    end;

    end;

    ShowMessage(IntToStr(plist.Count));
    ShowMessage(IntToStr(lPublisher.PageCount));

    lPDevice := TppPrinterDevice.Create(nil);
    lPDevice.Publisher := lPublisher;

    lPDevice.StartJob;

    for liIndex := 0 to plist.Count - 1 do
    begin
    lPDevice.Printer.PrinterSetup := TppPage(plist[0]).PrinterSetup;
    lPDevice.ReceivePage(plist[liIndex]);
    end;

    lPDevice.EndJob;

    end;

    --
    Cheers,

    Alexander Kramnik
    Digital Metaphors

This discussion has been closed.