Parse Data from Documents

View as MarkdownMarkdown

Set up your AI agent

Give your coding agent live access to the GroupDocs documentation and API reference through the GroupDocs Docs MCP server — no install, no API key. Learn more

claude mcp add --transport http groupdocs-docs https://docs.groupdocs.com/mcp

Also process documents locally

The GroupDocs.Parser MCP server lets your agent work with files on your machine; they are never uploaded. It runs in Docker: replace /path/to/documents with the folder it may use.

claude mcp add groupdocs-parser -- docker run --rm -i -v /path/to/documents:/data ghcr.io/groupdocs-parser/parser-net-mcp:latest
Folders, licensing and more →

Use template-based parsing to pull structured values (like invoice numbers, dates, tables) from documents.

Parse data with a template

from groupdocs.parser import Parser
from groupdocs.parser.templates import Template, TemplateField, TemplateFixedPosition
from groupdocs.parser.data import Rectangle, Point, Size

template = Template([
    TemplateField(
        TemplateFixedPosition(Rectangle(Point(35.0, 135.0), Size(100.0, 10.0))),
        "CompanyName",
    ),
    TemplateField(
        TemplateFixedPosition(Rectangle(Point(440.0, 115.0), Size(110.0, 15.0))),
        "InvoiceNumber",
    ),
])

with Parser("./invoice.pdf") as parser:
    data = parser.parse_by_template(template)
    if data is None:
        print("Parsing by template isn't supported for this format.")
    else:
        # DocumentData exposes extracted fields as an indexed collection.
        for i in range(data.count):
            field = data[i]
            print(f"{field.name}: {field.text}")

The following sample file is used in this example: invoice.pdf

COMPANYNAME: Northwind Coffee
INVOICENUMBER: HLP-2025-0412

Download full output

Steps

  1. Build a Template with fields or tables (fixed positions, regex, linked positions, etc.).
  2. Call parser.parse_by_template(template) to receive DocumentData.
  3. Iterate through extracted fields by index (data.count and data[i]) and process each extracted value based on its type (text, table, etc.).

For complex templates (tables, linked fields, regex fields), see the advanced templates guide.