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

TppArchiveReader.ArchivePageCount

edited July 2001 in General
I have a small application that will import archives into a database. One
of the columns (fields) of the table is Page Count. I'd like to determine
the page count of the archived report during the import process. But I
can't figure out how. I'm using RB 5.55.

The TppArchiveReader.ArchivePageCount property is only populated after
TppArchiveReader.Print. More precisely, it is populated in ReadHeader,
which is called by ReadFirstPage, which is called by InitializePrinterSetup,
which is called by Print. Unfortunately, Print is the only one of those
methods that is public. I'd rather not modify the ReportBuilder source, but
I'm not sure how else to accomplish my task.

I'm even content with having the preview form flash open and close during
the import process. But I can't find a way to automatically close the
preview form without generating an Access Violation.

If I modify the source, I'd likely override SetArchiveFileName like so:

TppArchiveReader.SetArchiveFileName(aFileName: String);
begin
inherited;
OpenFile;
ReadHeader;
CloseFile;
end;

I'd close the file because a future call to IntializePrinterSetup will close
the file anyway (OpenFile closes it if it is already open). But oddly
enough, FArchivePageCount is not reset in the process.

Also, I can't call ReadFirstPage because that will prevent
InitializePrinterSetup from working (if ReadFirstPage has already been
called, it returns False which prevents InitizlizePrinterSetup from doing
it's job).

Any thoughts or suggestions?

Comments

  • edited July 2001
    The header is only read when print is called. There has to be a better way
    than flashing the previewer. What about creating a local TppDevice and print
    one page to it. No previewer would be instantiated, but it should cause the
    archive reader to execute such that it would retrieve the pagecount from the
    header. Set ShowModalPreview to false and the below code worked for an
    example I created.

    uses
    ppDevice, ppTypes;

    procedure TForm1.Button1Click(Sender: TObject);
    var
    lDevice: TppDevice;
    begin

    lDevice := TppDevice.Create(Self);
    lDevice.PageSetting := psFirstPage;
    lDevice.Publisher := ppArchiveReader1.Publisher;

    ppArchiveReader1.ArchiveFileName := 'Booklet.raf';
    ppArchiveReader1.PrintToDevices;

    ShowMessage(IntToStr(ppArchiveReader1.ArchivePageCount));

    lDevice.Free;

    end;



    Cheers,

    Jim Bennett
    Digital Metaphors


This discussion has been closed.