Use ImmutableDocument for memory efficiency
masterThe ImmutableDocument class provides an immutable, memory-efficient representation of a document. Use this when you need to ensure document data remains unchanged after processing. You can convert between mutable and immutable states using ToImmutable() and ToMutable().
// Convert to ImmutableDocument
ImmutableDocument immutableDoc = doc.ToImmutable();
// Convert back to mutable Document
Document mutableDoc = immutableDoc.ToMutable();