Reading multiple reports from archive and printing in one batch.
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.
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.
This discussion has been closed.
Comments
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
http://www.digital-metaphors.com
info@digital-metaphors.com