Template class
Leave feedback
On this page
Provides the document page template consisting of TemplateItem objects that represent items such as text fields and table definitions.
Learn more:
The Template type exposes the following members:
| Constructor | Description |
|---|---|
| init | Initializes a new Template. |
| init | Initializes a new instance of the Template class with template options. |
| Method | Description |
|---|---|
| get | |
| get_enumerator | Returns an enumerator for template items. |
| get_int32 | |
| load | Loads a template from a file. |
| load | Loads a template from a stream. |
| load_file | |
| load_stream | |
| load_streams | |
| load_string | |
| save | Saves a template to a file. |
| save | Saves a template to a stream. |
| save_file | |
| save_stream | |
| save_streams | |
| save_string |
| Property | Description |
|---|---|
| count | The total number of template items. |
| is_ocr_compatible | The value indicating whether the template is compatible with OCR. |
| options | The template options. |
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:
print(data.get_fields_by_name("InvoiceNumber")[0].text)
- 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.