Auto calculate reporter height

General TRichView support forum. Please post your questions here
Post Reply
pdcuser
Posts: 17
Joined: Tue Jan 17, 2006 9:00 pm

Auto calculate reporter height

Post 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
Sergey Tkachenko
Site Admin
Posts: 17557
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

For the last page, you can use RVReportHelper.GetLastPageHeight.
pdcuser
Posts: 17
Joined: Tue Jan 17, 2006 9:00 pm

Post by pdcuser »

That did it. Thanks again!
Post Reply