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

Add dynamic column width support #867

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

Hummel37
Copy link

Add support for dynamic column width. #517
This currently only works for cells that don't use row or column spans.

@Hummel37 Hummel37 force-pushed the add-dynamic-column-width-support branch from 694e03f to f84be4d Compare April 30, 2024 12:15
@Hummel37
Copy link
Author

I have made here a repository which generates random user data and creates a pdf with the data.
Here are both pdf's so you can see the difference.
Before.pdf
After.pdf

@Hummel37
Copy link
Author

Hummel37 commented Apr 30, 2024

I have noticed that the width of the columns differs on the different sheets. This is due to the "ShowOnce" element. On page 2, the sizes of the cells from page 1 are not calculated because they are already rendered.
I don't know exactly what the element is for. But wouldn't it theoretically be enough to calculate the width of the columns once per table instead of doing it once for each page? Or can the width of the columns on the individual sheets in the same table be different?

@MarcinZiabek
Copy link
Member

I don't know exactly what the element is for. But wouldn't it theoretically be enough to calculate the width of the columns once per table instead of doing it once for each page? Or can the width of the columns on the individual sheets in the same table be different?

It is expected that elements may have different sizes across pages. ShowOnce is only one potential root cause.

I understand the desired behavior is that shrank/grown columns should have identical widths across all pages. In such a case, determining all widths will be genuinely challenging, as changing width also potentially changes displayed content, creating a feedback loop.

@Hummel37
Copy link
Author

Hummel37 commented May 3, 2024

Personally, I don't care if the columns are the same width on each sheet. For me it fits as it is after the PR.
I tested it locally without ShowOnce and noticed that the width was the same on all pages. Of course, if the elements can have different widths on different pages (although I don't understand how this is possible), it can stay that way.

@Hummel37
Copy link
Author

I have updated the pr to fix the different columns width per page.
Now, after the first time UpdateColumnsWidth is called the width of all columns are stored.
If the method is called again the stored values are used. I hope this is okay so...

@Hummel37 Hummel37 marked this pull request as ready for review May 11, 2024 20:54
@Hummel37
Copy link
Author

@MarcinZiabek Could you look at this pr again? It could really help me 😅

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

Successfully merging this pull request may close these issues.

None yet

2 participants