I am using Windows 10, Delphi 7. Trying to make Pdf document with SynPDF using it's canvas directly. I need to draw in the rectangle only that part of the text that corresponds to the length of the rectangle, the rest cut off. I am using DrawText (and DrawTextEx) functions to write text in the given rectangle with alignment (TA_LEFT, TA_RIGHT, TA_CENTER). The problem: these functions draw the text, but do not take into account the given boundaries - they do not clip(crop) this text.
var
R: TRect;
s: String;
begin
R:= Rect(50, 50, 120, 75);
Canvas.Brush.Color:=clYellow;
Canvas.Rectangle(R);
Canvas.Font.Name:='Arial';
Canvas.Font.Size:=10;
Canvas.Font.Style:=[];
Canvas.Brush.Style:= bsClear;
s:='Sample for text clipping';
DrawText(Canvas.Handle, PChar(s), -1, R, TA_LEFT or
{DT_END_ELLIPSIS or }DT_VCENTER or DT_SINGLELINE);
end;
If I add DT_END_ELLIPSIS
it works correctly but adds three dots - I do not need dots. What I am doing wrong? Or I need to use other functions for my task?
Unfortunately, I'm not allowed (by StackOverflow) to add a photo with the result...