Free Support Forum -

Is it possible to find position information for a table- row or cell?

I am using LayoutEnumerator and LayoutCollector to find the position information for a table, row or cell when the document is printed.

Table table=(Table)tableCollection.get(j);
Row row=table.getRows().get(0);
Cell cell=row.getCells().get(0);
Rectangle2D.Float rect=layoutEnum.getRectangle();

If instead of a row, I try to use table or cell for layoutEnum.setCurrent, it throws an exception.
Also, the reactangle returned for layoutEnum.getRectangle() is returning the wrong information.
The width of the row returned is very small.

I know about this

So is there a way to get position data for table or cell?
Also, why are the dimensions for row incorrect?


Thanks for your inquiry.

Please note that the LayoutCollector.GetEntity method works for only Paragraph nodes, as well as indivisible inline nodes, e.g. BookmarkStart or Shape. However, it doesn’t work for Run, Cell, Row or Table nodes, and nodes within header/footer.

The layout enumerator can move to ‘span’ objects in layout model which is in most cases is just a ‘paragraph break’ character (span can also be a ‘end of a table cell’ or ‘end of a table row’ character). For example, you can move to a Cell in APS (Aspose Page Specification model) by moving to the last/first paragraph in a Cell and then ascend to the parent entity using enumerator. The same approach can be used for Row and Table nodes. Please see the following changes:
Table table=(Table)tableCollection.get(0);
Row row=table.getRows().get(0);
Cell cell=row.getCells().get(0);
Rectangle2D.Float rect=layoutEnum.getRectangle();
I hope, this helps.

Best regards,

A post was split to a new topic: Get layout rectangle for each table row in header