Auto calculate reporter height
Posted: Wed Aug 22, 2007 2:25 am
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:
How can I determine the correct height to ensure all text is displayed on the canvas?
Thanks in advance,
Brandon
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;
Thanks in advance,
Brandon