OpenPDF
                                
                                
                                
                                    OpenPDF copied to clipboard
                            
                            
                            
                        Request for Auto Trim Feature in PdfPCell
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:
Expected Solution:
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
Hi. this would be a nice feature.
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".