Hi,
Did you pass a large enough height for the text to be fitted into?
uses
FMX.TMSFNCPDFLib, FMX.TMSFNCPDFCoreLibBase, IOUtils;
procedure TForm90.Button1Click(Sender: TObject);
var
p: TTMSFNCPDFLib;
r: TRectF;
s: string;
begin
p := TTMSFNCPDFLib.Create;
try
p.BeginDocument(TPath.GetDocumentsPath + PathDelim + 'test.pdf');
p.NewPage;
s := 'This is a text for a very wide column that should return a larger rectangle than provided';
r := p.Graphics.CalculateText(s, RectF(0, 0, 100, 10000));
r := RectF(100, 100, 100 + r.Width, 100 + r.Height);
p.Graphics.DrawRectangle(r);
p.Graphics.DrawText(s, r);
p.EndDocument(True);
finally
p.Free;
end;
end;
Hi Pieter,
I'll try your example but it isn't Much different to my code in essence
The calculation with wordwrapping should be compared against the Width of the rectangle, and will return the height needed to match all the text inside. The sample shows a height of 10.000. It seems to be a limitation in macOS that the height needs to be set high enough to make sure the text rectangle is calculated correctly. I'm happy to take a look at your code and see where it can improve or change to have the correct output.
Ok, that might be the way around it, set too high a bounding box then compare the return from CalculateText with my default bounding box and see if it fits. The documentation states that the bounding box height will be expanded if necessary but this only seems to happen on Windows. On Mac it just clips.
I'll take a look at the behaviour for calculating the rectangle on macOS and see if I can incorporate the same behaviour like on Windows.
Thanks,