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

Request for Auto Trim Feature in PdfPCell #1119

Open
HemaSudha1498 opened this issue Mar 29, 2024 · 2 comments
Open

Request for Auto Trim Feature in PdfPCell #1119

HemaSudha1498 opened this issue Mar 29, 2024 · 2 comments

Comments

@HemaSudha1498
Copy link

HemaSudha1498 commented Mar 29, 2024

I propose the addition of an auto trim feature to the PdfPCell class in OpenPDF. Currently, text content exceeding cell width leads to overlap issues with neighboring cells when setNoWrap(true). Kindly Add an option to automatically trim text within a cell to fit its width. This would prevent overflow and improve table layout readability.

If this feature already exists, please let me know how to implement it.

Issue:
Screenshot from 2024-03-29 14-59-05

Expected Solution:
Screenshot from 2024-03-29 15-13-19

Additionally, could someone assist me in determining the formula for calculating the number of characters that fit within a specified width when the font size is known?

Thank you

@asturio
Copy link
Member

asturio commented Mar 30, 2024

Hi. this would be a nice feature.

@asturio
Copy link
Member

asturio commented May 27, 2024

One possibility would be to set a "trimSize" on the cell or on the column. And if that is set, all cell content could be trimmed by that number of characters. This as a simple solution.

Depending on the used font, you can't determine how many chars fit in a cell, as a 5 char String has different width depending on the content. "iiiii" is much shorter than "VVVVV".

Another approach could be to "cut" the content, and checking the necessary width. And try to find the sweet spot, there the cut will be "perfect".

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

No branches or pull requests

2 participants