Load Text from a String

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.Comparison MCP server lets your agent work with files on your machine; they are never uploaded. It needs the .NET 10 SDK or Docker.

claude mcp add groupdocs-comparison -- dnx GroupDocs.Comparison.Mcp --yes
Folders, licensing and more →

GroupDocs.Comparison for Python via .NET can compare values from str variables directly — useful when the text never lives on disk (CLI input, REST request bodies, in-memory diffs).

Set LoadOptions.load_text to True to tell Comparer that the first argument is a literal string, not a file path. Read the merged result back via get_result_string().

Example: Compare two strings

from groupdocs.comparison import Comparer
from groupdocs.comparison.options import LoadOptions

def load_text_from_string():
    load_options = LoadOptions()
    load_options.load_text = True

    with Comparer("source text", load_options) as comparer:
        comparer.add("target text", load_options)
        comparer.compare("./result.docx")
        print("Result string:")
        print(comparer.get_result_string())

if __name__ == "__main__":
    load_text_from_string()
result.docx (107 bytes)
result.html (479 bytes)

Download full output