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

AbsolutePageCount

edited October 2003 in General
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?

Comments

  • edited October 2003
    Hey Jeff!

    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.
  • edited October 2003
    Thanks Chunk.

    That seems overly complicated just to get a page count! Hopefully the first
    method will work for me.

    Thanks


  • edited October 2003
    I had to go the second way because I am printing to a modal window so the
    ArchivePageCount wasn't available until after the preview window was closed,
    which obviously was nout much use. Worked a treat though.

    Thanks
This discussion has been closed.