I am having problem understanding the argument this flowDocument doc in the following method:
public static FormattedText GetFormattedText(this FlowDocument doc)
{
    if (doc == null)
    {
        throw new ArgumentNullException("doc");
    }
    ...
}
The caller does not specify an argument when calling the above method:
myRichTextBox.TextChanged +=
    new TextChangedEventHandler((o, e) => myRichTextBox.Width = 
        myRichTextBox.Document.GetFormattedText().WidthIncludingTrailingWhitespace + 20);
I am positive that the method does not create doc itself.  I have not seen this used in this manner before.
 
     
    