TPPDF icon indicating copy to clipboard operation
TPPDF copied to clipboard

Individual table column and row padding

Open jem5519 opened this issue 5 years ago • 3 comments

When using a table to lay out a report I would like to reduce the spacing between cell rows without effecting the spacing between cell columns. I understand that this may be achieved by changing the top and bottom padding of cells independent of the padding on the sides, but I don't see any way to do this in the current exposed commands.

jem5519 avatar Jul 19 '19 17:07 jem5519

Yes, currently there is only one padding and one margin value to set these values for all directions.

We could add individual values per side, but these would be horizontal values per column, and vertical values per row and not for individual cells.

philprime avatar Jul 24 '19 09:07 philprime

Hi Phillip,

Thank you for responding. That behavior is exactly what I would want: the setting would affect the whole row.

  • Jim

jem5519 avatar Jul 24 '19 14:07 jem5519

Hello !

Just in case it could help someone looking for a solution, I bypassed the current limitation by adding a minimum line height to an attributed string.

Of course, it'll only work with text components, and for the vertical padding, but it's a solution in case you really need the padding ^^

So for instance:

let font = UIFont.boldSystemFont(ofSize: 12)
let pStyle = NSMutableParagraphStyle()
pStyle.minimumLineHeight = ceil(font.lineHeight * 1.7)

NSAttributedString(string: "My text", attributes: [
  .font: font,
  .foregroundColor: UIColor.black,
  .paragraphStyle: pStyle
])

(by the way, thanks a lot for the lib!)

Vinzius avatar Apr 14 '21 20:04 Vinzius