Working with Containers

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 →

Container-aware parsing lets you open archive-like formats (ZIP, RAR, 7z, TAR), Outlook stores (PST/OST), PDF portfolios, and email attachments, then process their contents using the same parser API.

Iterate nested items safely

from groupdocs.parser import Parser
from groupdocs.parser.exceptions import UnsupportedDocumentFormatException

def print_text(item_path, parser):
    reader = parser.get_text()
    text = reader.read_to_end() if reader is not None else None
    print(f"{item_path}: {text if text else '[no text]'}")

with Parser("portfolio.pdf") as parser:
    container = parser.get_container()
    if container is None:
        print("Container extraction isn't supported for this format.")
    else:
        for item in container:
            try:
                with item.open_parser() as inner_parser:
                    print_text(item.file_path, inner_parser)
            except UnsupportedDocumentFormatException:
                print(f"{item.file_path}: format is not supported.")

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

invoice-HLP-2025-0412.pdf:                                                                                            INVOICE


   FROM                                                                     Invoice Number      HLP-2025-0412
   Northwind Coffee Roasters                                                Invoice Date        4 November 2025
   4 Roastery Lane, Millbrook                                               Due Date            4 December 2025
   alex.chen@northwindroasters.e
[TRUNCATED]

Download full output

Tips

  • Containers can be nested; call open_parser() recursively when needed.
  • Use item.detect_file_type() and item.metadata (when available) to decide how to process each attachment.
  • If get_container() returns None, the format does not expose attachments; continue with other extraction methods.