Working with Word for WPF / Advanced Level Working / Adding Text Flow
Adding Text Flow

You can use text flow in a word document. Using Word for WPF, you can flow text into columns and pages of a document.

Note that a class named WordUtils is used in the code given below. It is available in the product sample located at the following location on your system:
Documents\ComponentOne Samples\WPF\WordCreator
You can use these classes in your application from the mentioned location.

The following code shows how the text flow feature can be used in Word for WPF:

' load long string from resource file
Dim text As String = "Resource not found..."
Using sr = New StreamReader(DataAccess.GetStream("flow.txt"))
        text = sr.ReadToEnd()
End Using
text = text.Replace(vbTab, "   ")

' create pdf document
word.Info.Title = "Text Flow"
word.LineBreak()

' add title
Dim titleFont As New Font("Tahoma", 24, RtfFontStyle.Bold)
Dim bodyFont As New Font("Tahoma", 9)
Dim rcPage As Rect = WordUtils.PageRectangle(word)
Dim paragraph = New RtfParagraph()
Dim title = New RtfString(word.Info.Title, titleFont, RtfUnderlineStyle.Dotted)
paragraph.Add(title)
word.Add(paragraph)
word.LineBreak()
word.LineBreak()

' render string spanning columns and pages
For Each s As var In text.Split(New String() {Environment.NewLine}, StringSplitOptions.None)
        word.AddParagraph(s, bodyFont, Colors.Black, RtfHorizontalAlignment.Justify)
Next

The output of the above code will look similar to the image given below: