Calculating Dynamic Height of Detail Band

TECH TIP: Calculation Dynamic Height of Detail Band

Sometimes you need to know the stretched height of a dynamically sized detail band after it has printer to perform further logic. This can be done by keeping track of where the report engine currently is on the page and where it was right before that. For example:

uses
 ppTypes, ppUtils;
...
  private
    FPos: Integer;
...

procedure TForm1.ppReport1StartPage(Sender: TObject);
begin
  FPos := 0; // reset position to 0 at beginning of every page
end;

...

procedure TForm1.ppDetailBand1AfterPrint(Sender: TObject);
var
  lMMTHeight: Integer;
  lInchHeight: Single;
begin
  // calculate the difference between current position and last position
  lMMTHeight := ppReport1.Engine.PrintPosRect.Top - FPos;

  // the height is in thousands of millimiters so we must convert to inches
  lHeight := ppFromMMThousandths(llMMTHeight, utInches, pprtVertical, nil);


  // save the current position
  FPos := ppReport1.Engine.PrintPosRect.Top;
end;