Extract to String

How to extract content from a file to a string.

The Extractor class provides a straightforward way to extract text content from files into a string, with built-in support for maximum length configuration and error handling.

from extractous import Extractor

def extract_content():
    # Initialize extractor with configuration
    extractor = Extractor()
    extractor.set_extract_string_max_length(1000)
    
    # Extract content
    content = extractor.extract_file_to_string("path/to/document.pdf")
    return content

# Error handling example
try:
    content = extract_content()
    print(content)
except Exception as e:
    print(f"Error extracting content: {e}")