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

Cut Text like "overflow:hidden" in css #34

Closed
terrason opened this issue Jan 23, 2024 · 6 comments
Closed

Cut Text like "overflow:hidden" in css #34

terrason opened this issue Jan 23, 2024 · 6 comments
Assignees
Labels

Comments

@terrason
Copy link

terrason commented Jan 23, 2024

Hello,
I need my table cell hide overflow text, like set "overflow:hidden" style in css
Is there any way to do this?

I am now figuring the max words in a cell by:

        // my cell's width is WidthSpec.perc(30)
        double area=0.3*pages.getAvailableWidth() * this.tableCellHeight-(2*Constants.POINTS_PER_MM*Constants.POINTS_PER_MM);
        double areaPerFont=(fontSize + LINE_SPACING*Constants.POINTS_PER_MM)*fontSize;
        this.tableCellWordsLimit=(int)(area / areaPerFont);

Unfortunately this is not work, the result tableCellWordsLimit is higher than seen.

@phax phax self-assigned this Jan 23, 2024
@phax
Copy link
Owner

phax commented Jan 23, 2024

Try setting a "maxWidth" and/or "maxHeight" of an object to reproduce this effect. I try to create an example snippet

@phax phax added question and removed enhancement labels Jan 23, 2024
@terrason
Copy link
Author

Try setting a "maxWidth" and/or "maxHeight" of an object to reproduce this effect. I try to create an example snippet

Thank you for repling. setMaxHeight on Table cell seams not working
image

@phax
Copy link
Owner

phax commented Jan 23, 2024

Yeah - its overflow:visible

phax added a commit that referenced this issue Jan 23, 2024
@phax
Copy link
Owner

phax commented Jan 23, 2024

I found a way to do this and added it into the latest 7.3.1-SNAPSHOT version. The class AbstractPLBox received a method setClipContent (boolean) which you can use to clip content to the display area. This therefore works for PLBox and PLTableCell. See the example code I created that outputs this PDF:
issue34.pdf

If that suits your needs, I will build a release.

@terrason
Copy link
Author

Yes, this suits my job. Wonderful

@phax
Copy link
Owner

phax commented Jan 24, 2024

Part of the 7.3.1 release

@phax phax closed this as completed Jan 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants