api-issue-tracker icon indicating copy to clipboard operation
api-issue-tracker copied to clipboard

[Request] [Layout API] More options to organize tables

Open Fredosixx opened this issue 1 year ago • 2 comments

Unless I am wrong, there seems to be nothing for basic formatting of table:

  • cell margins - currently text is too close to the cell borders - workaround: create thin columns and lines and hide their borders
  • cell justifying - currently, no options - just Top Left - no easy workaround
  • text wrapping and cell height adjustment - currently nothing - workaround: I have to compute it myself and adjust the height of lines

A large part of the problem could be resolved if there was an extra method for FormattedText, where you could:

  • Specify a bounding box and an anchor type (to justify and wrap)
  • Get the actual height of the formatted text (after setting the style)

Currently:

bb = Geom::Bounds2d.new 1, 1, wid, hgt
ftext = Layout::FormattedText.new(some long text, bb)   # the text is wrapped but no way to justify it in the box
height = ftext.bounds.height    # return the SAME height as <bb> regardless of the text, not the actual height

What is requested:

bb = Geom::Bounds2d.new 1, 1, wid, hgt
ftext = Layout::FormattedText.new(some long text, bb, anchor_type)   # the text is wrapped and justified
real_height = ftext.bounds.height    # should return the actual height of the text

Fredosixx avatar Jan 04 '25 17:01 Fredosixx

@ackarkka - are we missing all of this?

thomthom avatar Jan 06 '25 14:01 thomthom

It is indeed not very straightforward to format tables properly. Some of the above is possibly, but in a somewhat convoluted way.

A FormattedText object can be converted to an Entity object using LOFormattedTextToEntity.

Using LOSetEntityStyle a style can be applied to the Entity. It is important to note that the style should be applied after calling LOFormattedTextSetPlainText (for example when reusing the FormattedText object).

Using the Style object you can set things like alignment, color and font size.

As far as I can tell, it is not possible to use margins, which would be really useful on formatting a table nicely.

mderond avatar Mar 11 '25 16:03 mderond