Skip to content

API to get the height of elements and the height of the current page content #1213

@douglasmatheus

Description

@douglasmatheus

What problem does this feature solve?

Hello, I needed to implement two methods to get the height of elements and internal content.

The usage scenario was as follows: I have a set of elements that will be added in stages, which can be text, tables, lists, etc. Let's assume they are only tables, and the content of these tables varies greatly (it's loaded from a database). I'll add the tables one after the other while the page has enough space. If the remaining space is insufficient, I'll add a page break, and I'll insert the next tables on the remaining pages.

Page with table with broken content
Image

Page with page break
Image

What does the proposed API look like?

After adding each table, I calculate the height of the next table. I also need to know the size of the remaining space on the page to check whether the table to be inserted will fit on the current page. If the table is larger than the remaining space on the page, I'll insert a page break and add the table to the next page.

This way, I can control whether parts of the content are cut off and are displayed in their entirety. Of course, if a table is larger than a page, I'll let it "cut" because there's nothing else to do.

I'd like to know if the author might find these implementations useful for the project. It's not quite a paragraph control, but it allows the developer to control the display of their content if desired. There are two methods implemented, both with approximately 30 lines each: getHeightElementList(elementList: IElement[]) and getInternalHeightsPages(rowList?: IRow[]). I copied parts of the computePageList() and computeRowList() methods for this.

Would you like me to submit a PR for review?

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions