Use container extraction to open archive-like formats (ZIP, RAR, TAR), Outlook stores (PST/OST), PDF portfolios, and email attachments, then parse their contents.
Extract and parse attachments
fromgroupdocs.parserimportParserfromgroupdocs.parser.exceptionsimportUnsupportedDocumentFormatExceptionwithParser("./archive.zip")asparser:attachments=parser.get_container()ifattachmentsisNone:print("Container extraction isn't supported for this format.")else:foriteminattachments:print(item.file_path)try:withitem.open_parser()asattachment_parser:reader=attachment_parser.get_text()print(reader.read_to_end()ifreaderisnotNoneelse"No text available.")exceptUnsupportedDocumentFormatException:print("Item format is not supported.")
The following sample file is used in this example: archive.zip
finance/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@northwindroa
[TRUNCATED]
Call get_container() to list ContainerItem entries.
For each item, use open_parser() to create a Parser over the embedded content and reuse standard extraction methods (get_text, get_images, get_metadata, etc.).
Handle unsupported formats with UnsupportedDocumentFormatException.
For working with attachments in complex scenarios (nested containers, load options), see the advanced containers guide.
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.
On this page
Ask AI
Ask anything about this page — the answer is based on its content.
Searching the docs and writing an answer…
Something went wrong while getting an answer. Please try again in a moment.