Page 1 of 1

Auto calculate reporter height

Posted: Wed Aug 22, 2007 2:25 am
by pdcuser
I am using the TRVReportHelper component to paint RVF text to a Canvas. Given a canvas of x width, I want to determine the height the canvas has to be in order to see the wordwrapped text. The problem I am having is the last word on the line seems to disappear occasionally, instead of wordwrapping.

Assuming there is only one paragraph (no carriage returns), and only one text style being used, I have tried:

Code: Select all

function TMyControl.GetPlainText: WideString;
begin
  Convert RVF to widestring...
end;

function TMyControl.GetFontHeight: Integer;
begin
  Get the current font height...
end;

procedure TMyControl.BeforeDraw;
var
  PlainText: string;
  TextWidth, TextHeight: Integer;
begin
  Canvas.Font.Assign(Font);
  PlainText := RVU_GetRawUnicode(GetPlainText);
  TextHeight := GetFontHeight;
  TextWidth := RVU_TextWidth(PlainText, Canvas, [rvioUnicode]);

  //
  // Set the canvas height
  //
  Height := TextHeight * Ceil(TextWidth / Width);
end;
How can I determine the correct height to ensure all text is displayed on the canvas?

Thanks in advance,
Brandon

Posted: Wed Aug 22, 2007 3:55 pm
by Sergey Tkachenko
For the last page, you can use RVReportHelper.GetLastPageHeight.

Posted: Wed Aug 22, 2007 6:16 pm
by pdcuser
That did it. Thanks again!