Get row/cell height and cell width

Hi team,

I am creating a table which could have dynamic number of rows and dynamic amount of content within the cells.

The requirement is to have a textboxfield in the last column cell of each row.
I need the textboxfield to be as big as the cell it sits in.
So, the height should be equal to the height of the cell it sits in, or it could be the height of the row as well (both would be equal I assume) and the width should be equal to the width of the cell.

The page has a fixed size and the columns have fixed ratios as well so I can calculate and hardcode the width if this cannot be calculated programmatically (worst case scenario)
But I still need to set the height.

Please help

Thanks and Regards,
Shaurya

@shaurya.chawla

We have already shared a code snippet in your other forum thread that can be used to add the form fields inside table cells. You can specify the height and width of the form field as well in it. Please use it while generating the PDF from scratch and let us know in case you notice any issues.

The mentioned forum link deals with the intention of adding TextBoxField to an existing PDF. That is only possible when through AbsorbedTable.
In this thread, I’m talking about creating a pdf document from scratch and creating a Table instance on it.

This is the code I am using -

private static void addTextboxFields(Row row) {
        Cell lastCell = row.getCells().get_Item(row.getCells().getCount()-1);
//        lastCell.setBackgroundColor(Color.getRed());
        TextBoxField field = new TextBoxField(); // editable
        field.setValue("Something Something");
        field.setWidth(lastCell.getWidth());
        field.setHeight(row.getFixedRowHeight());
        field.setMultiline(true);
        row.getCells().add().getParagraphs().add(field);

    }

lastCell.getWidth() returns 0.0
0.0 is returned for the second last cell as well (cell to the left of the one where I need the textboxfield)
row.getFixedRowHeight() returns 0.0 and row.getMinRowHeight() also returns 0.0

arena.zip (3.1 KB)
Here is the complete code I’m using for your reference.

Thanks
Shaurya

@shaurya.chawla

As per our understanding, you are creating a PDF from scratch and adding table inside it dynamically. Now you want to add form field in the last column and for that you need to have height/width values of the cell. Please confirm if we are getting it right so that we can proceed with logging a ticket and share the ID with you.

hey @asad.ali
yes that’s correct - if by form field you mean textboxfield.

@shaurya.chawla

We have logged an investigation ticket as PDFNET-53360 in our issue tracking system for further analysis. We will look into its details and keep you posted with the status of its correction. Please be patient and spare us some time.

We are sorry for the inconvenience.

Hello,

Happy New Year!
Is there an update on this yet?

@shaurya.chawla

The ticket has recently been logged in our issue tracking system and it will be investigated and resolved on a first come first serve basis. We will surely inform you once we make some progress towards its resolution. Please be patient and spare us some time.

We are sorry for the inconvenience.

Hey guys, any updates so far?

@shaurya.chawla

We are afraid that no updates are available at the moment about ticket resolution. We will notify you via this forum thread as soon as we have some updates about ticket resolution. We apologize for the inconvenience.