python-docx2txt Documentation

repository·master·Indexed 20 days ago

https://github.com/ankushshah89/python-docx2txt

A pure Python utility for extracting text and images from .docx files. It extends python-docx by enabling extraction from headers, footers, and hyperlinks. Provides both a command-line interface (CLI) and a Python API via the docx2txt.process() function.

Tokens
482
Snippets
6
Records
6
Agent score
20%

What's inside python-docx2txt

  1. Extract text and images using docx2txt.process() in Python

    master

    To extract text and save images to a specific directory using the Python API, pass the desired image directory as the second argument to docx2txt.process().

    import docx2txt
    
    # extract text and write images in /tmp/img_dir
    text = docx2txt.process("file.docx", "/tmp/img_dir")
  2. Use the docx2txt CLI to extract text and images

    master

    The docx2txt command-line tool allows you to extract text and images from .docx files. By default, it outputs the extracted text to stdout. You can optionally specify a directory where extracted images will be saved.

    # Basic usage: extract text to stdout
    docx2txt file.docx
    
    # Extract text to stdout and save images to a specific directory
    docx2txt file.docx /tmp/img_dir