TMS FMX UI Pack / PDF Lib: problems on Mac

Hi,

I'm using TTMSFMXPDFLib.Graphics.CalculateText to calculate whether I need to vertically expand a bounding rectangle on some text. Works fine on Windows, on Mac it Never returns a rectangle larger than the one submitted, no matter How long the text is.

Thanks,
Pete

Did you pass a large enough height for the text to be fitted into?

The code sample below has no issues in both Windows and macOS it automatically calculates the height based on a rectangle max width of 100:



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,

No, I pass it a fixed bounding box and the Windows version will return a rectangle that expands the height required if needed (which is what I want) but the Mac version doesn't, it never returns a rectangle that has a height greater than the box provided, even if all the text won't fit inside.

Thanks,
Pete

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.


Thanks,
Pete

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,

Pete