1

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?

Tilman Hausherr
  • 17,731
  • 7
  • 58
  • 97
Piotr Żak
  • 2,083
  • 6
  • 29
  • 42

1 Answers1

0

After some debugging I've noticed that the cell height can be changed like this:

cell.setHeight(cell.getTextHeight() + 0.5f);

It's important to pick cell.getTextHeight() and then add Your value, if You only put some number like 12f it won't work

Piotr Żak
  • 2,083
  • 6
  • 29
  • 42