TemplateTable class

TemplateTable class

Provides the template table.

There are two ways to define a table:

The TemplateTable type exposes the following members:

Constructors

Constructor Description
init Initializes a new TemplateTable with the specified layout and name.
init Initializes a TemplateTable with the given layout, name (in upper case), and page width.
init Initializes a new TemplateTable.
init Initializes a new TemplateTable.
init Initializes a new TemplateTable.
init Initializes a new TemplateTable instance.

Methods

Method Description
scale Scales the template item by a given factor.
scale_double

Properties

Property Description
layout The table layout.
parameters The parameters used to detect the table in automatic mode. Returns an instance of TemplateTableParameters or None if not set.
name The name of the template item. Uppercase string value representing the template item’s name. (inherited from TemplateItem)
page_width The width of the page in pixels; None if the page width is unknown. (inherited from TemplateItem)
use_upper_case_name The property returns a boolean value that indicates whether a Name was converted to UPPER CASE. (inherited from TemplateItem)

Example

from groupdocs.parser import Parser
from groupdocs.parser.data import Rectangle, Point, Size
from groupdocs.parser.templates import (
    Template,
    TemplateTable,
    TemplateTableParameters,
)

table_area = Rectangle(Point(175.0, 350.0), Size(400.0, 200.0))
columns = [185.0, 370.0, 425.0, 485.0, 545.0]

table = TemplateTable(
    parameters=TemplateTableParameters(table_area, columns),
    name="Details",
)

template = Template([table])

with Parser("./invoice.pdf") as parser:
    data = parser.parse_by_template(template)
    if data:
        fields = data.get_fields_by_name("Details")
        if fields:
            details = fields[0].page_area
            print(f"Rows extracted: {details.row_count}")

See Also