__init__ constructor
Leave feedback
On this page
Initializes a new TemplateField instance.
def __init__(self, position, name):
...
| Parameter | Type | Description |
|---|---|---|
| position | TemplatePosition |
The field position. |
| name | str |
The field name. |
from groupdocs.parser.templates import TemplateField, TemplateRegexPosition
field = TemplateField(
TemplateRegexPosition(r"Invoice Number\s+(?<value>[A-Z0-9\-]+)"),
"InvoiceNumber",
)
Initializes a new TemplateField.
def __init__(self, position, name, page_width):
...
| Parameter | Type | Description |
|---|---|---|
| position | TemplatePosition |
The field position. |
| name | str |
The field name. |
| page_width | Optional[float] |
The width of the page that was used to create the template item. |
from groupdocs.parser.templates import TemplateField, TemplateFixedPosition
from groupdocs.parser.data import Rectangle, Point, Size
field = TemplateField(
TemplateFixedPosition(Rectangle(Point(35.0, 135.0), Size(100.0, 10.0))),
"CompanyName",
)
Initializes a new TemplateField.
def __init__(self, position, name, page_width, use_upper_case_name):
...
| Parameter | Type | Description |
|---|---|---|
| position | TemplatePosition |
The field position. |
| name | str |
The field name. |
| page_width | Optional[float] |
The width of the page that was used to create the template item. |
| use_upper_case_name | bool |
Indicates whether the name is converted to upper case. |
from groupdocs.parser import Parser
from groupdocs.parser.templates import Template, TemplateField, TemplateRegexPosition
template = Template([
TemplateField(
TemplateRegexPosition(r"Invoice Number\s+(?<value>[A-Z0-9\-]+)"),
"InvoiceNumber",
)
])
with Parser("./invoice.pdf") as parser:
data = parser.parse_by_template(template)
if data is not None:
fields = data.get_fields_by_name("InvoiceNumber")
if fields:
print(f"Invoice number: {fields[0].text}")
- class
TemplateField
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.