Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How am I supposed to determine table row/col from a layout callback? #2766

Open
duhmojo opened this issue Aug 13, 2024 · 1 comment
Open

Comments

@duhmojo
Copy link

duhmojo commented Aug 13, 2024

Hi. I'm using pdfmake 0.2 and I'm finding it impossible to set the padding/margins of a nested table (a parent table with a cell that has a table in it). No matter what layout/styling I use, the nested table has a 5 or so of white space around it.

That is unless I set a custom padding callback and just return 0. Then the nested table's padding is eliminated but all the other cells in the parent table lose their natural padding.

So I seeked to figure out how to detect which cell the callback is firing on. The index is the table row (I believe) and the node is the doc object the layout is calling from. BUT I don't know what to do about finding that 4th row, 3rd cell so I can return 0 or whatever the default style is:

const zeroPadding = (rowIdx, node) => {
    return 0
}

It's frustrating because the documentation itself doesn't explain what (i, node) is supposed to be used for. The examples seem completely without context. They compare i against table row length and table widths length.

I would have assumed that the callback would include both the row and cell idx. How am I supposed to determine which call the callback is being used for?

@fe-cj
Copy link
Contributor

fe-cj commented Sep 29, 2024

I'd say padding is just allowed at row level and it is not possible to define the padding of a single cell.

As an alternative, you could try to set negative margins on your nested table to undo the padding of the parent. Or you could set the padding of the row to 0 and play with positive margins in the cells that don't contain the nested table.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants