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

Change cell height #197

Open
zaqpiotr opened this issue Jan 20, 2020 · 6 comments
Open

Change cell height #197

zaqpiotr opened this issue Jan 20, 2020 · 6 comments
Labels

Comments

@zaqpiotr
Copy link
Contributor

Hello Everyone,

I have created BaseTable according to example from https://github.com/dhorions/boxable/wiki


    float margin = 50;
    float yStartNewPage = myPage.getMediaBox().getHeight() - (2 * margin);
    float tableWidth = myPage.getMediaBox().getWidth() - (2 * margin);

    boolean drawContent = true;
    float yStart = yStartNewPage;
    float bottomMargin = 70;

    float yPosition = 550;

    BaseTable table = new BaseTable(yPosition, yStartNewPage, bottomMargin, tableWidth, margin, mainDocument, myPage, true, drawContent);


    Row<PDPage> headerRow = table.createRow(15f);
    Cell<PDPage> cell = headerRow.createCell(100, "Header");
    table.addHeaderRow(headerRow);


    Row<PDPage> row = table.createRow(12);
    cell = row.createCell(30, "Data 1");
    cell = row.createCell(70, "Some value");

    table.draw();


    contentStream.close();
    mainDocument.addPage(myPage);
    mainDocument.save("testfile.pdf");
    mainDocument.close();

Table looks fine

image

but when I want change cell height like this

cell.setHeight(5f);

Content is not drawn in cell

image

I was trying with changing row height, font size change, but it didn't help.

Do You know how to fix it?

@Frulenzo
Copy link
Collaborator

Frulenzo commented Oct 6, 2020

Are you sure that your text size are not bigger than your cell height? You should always ask yourself that. Thanks for the code snippet ! I take this and make quick tests ..

@Frulenzo
Copy link
Collaborator

Frulenzo commented Oct 6, 2020

ohhh, it's a bug. I tried making bigger cell height where I am certain that the text would fit in but also didn't have better result.

setCellHeight.pdf

Definetly a bug.

@Frulenzo Frulenzo added the bug label Oct 6, 2020
@zaqpiotr
Copy link
Contributor Author

zaqpiotr commented Oct 6, 2020

What I did to make cell higher
cell.setHeight(cell.getTextHeight() + 12.0f);

@Frulenzo Frulenzo pinned this issue Oct 6, 2020
@Frulenzo
Copy link
Collaborator

Frulenzo commented Oct 6, 2020

oh wow. That is very good. At least taking the text height and then increasing the cell height. Pretty clever 👍 When we go in other direction (making the cell height smaller), we need to reduce the font size first, possibly the cell paddings also and then setting the height lower than former cell's text height.

@stefanm96
Copy link

Hey, is there any news about this issue?
I need fixed row sizes (height & width) in my project, so this issue is directly effecting me.
Thanks a lot!

@jsail
Copy link

jsail commented Apr 3, 2022

Hello, I also should work with lower Cell-hight or padding. Do you know a workaround to get a compact table?
Thank you for helping!
Joseph

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

4 participants