TemplateTable class
Leave feedback
On this page
Provides the template table.
There are two ways to define a table:
- Using
TemplateTableLayoutclass. In this case the table is defined by its position on the page: rectangular area, columns and rows separators. - Using
TemplateTableParametersclass. In this case the table is detected automatically by algorithms with set parameters. SeeTemplateTableParametersclass for more information.
The TemplateTable type exposes the following members:
| 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. |
| Method | Description |
|---|---|
| scale | Scales the template item by a given factor. |
| scale_double |
| 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) |
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}")
- module
groupdocs.parser.templates
Was this page helpful?
Any additional feedback you'd like to share with us?
Please tell us how we can improve this page.
Thank you for your feedback!
We value your opinion. Your feedback will help us improve our documentation.