AbsolutePageCount
I am doing my own customised print preview. I am opening an archived report
and viewing it. Now I can use ppViewer1.AbsolutePageNo to get the current
page number, but I don't seem to be able to use ppViewer1.AbsolutePageCount.
How can I get the total number of pages?
and viewing it. Now I can use ppViewer1.AbsolutePageNo to get the current
page number, but I don't seem to be able to use ppViewer1.AbsolutePageCount.
How can I get the total number of pages?
This discussion has been closed.
Comments
I am assuming that you are using the TppArchiveReader for the archive
report. The TppArchiveReader has an ArchivePageCount property that will
show you the total page count but only AFTER you call the print method.
If that doesn't work for you, you can use the following code.
//put this record definition in your interface section
rPageEntryRecEntry = record
Position : LongInt;
AbsolutePageNo : LongInt;
end; {record, TppPageEntry}
// declare these somewhere (local to the procedure or global)
var
tempFileStream : TFileStream;
wMode : Word;
iHeaderSize : LongInt;
iArchivePageCount : LongInt;
iPageEntrySize : LongInt;
//do this code somewhere
procedure GetTotalPageCount;
begin
iHeaderSize := 0;
iPageEntrySize := SizeOf(rPageEntryRecEntry);
wMode := fmOpenRead or fmShareDenyWrite;
//put a try..except around this to handle any exceptions
tempFileStream := TFileStream.create(ppArchiveReader.ArchiveFileName,
wMode);
tempFileStream.Read(iHeaderSize, SizeOf(Longint));
iArchivePageCount := (iHeaderSize - SizeOf(Longint)) div iPageEntrySize;
tempFileStream.Free;
end;
Regards,
Chuck Van Acker
Alogent Corp.
That seems overly complicated just to get a page count! Hopefully the first
method will work for me.
Thanks
ArchivePageCount wasn't available until after the preview window was closed,
which obviously was nout much use. Worked a treat though.
Thanks