Version

About WinFormattedTextWordWriter

WinFormattedTextWordWriter™, like WinGridWordWriter™, is a component with exporting functionality that enables the contents of WinFormattedTextEditor™ or WinFormattedLinkLabel™ to write to a new Word document. This functionality is based on the WordDocumentWriter object in the Infragistics.Documents.IO assembly.

The Export method implements the basic exporting functionality. You can export the entire text including font styles, font size, text alignment, images, hyperlinks, special characters and other formatted text features supported by the WinFormattedTextEditor and WinFormattedLinkLabel controls. There are also several events that you may take advantage of to customize the export to your liking, such as:

The following code listing demonstrates the basic implementation required for the export process. To begin, drag and drop an UltraFormattedTextWordWriter component and an UltraFormattedTextEditor control onto the form and set the Value property of the UltraFormattedTextEditor control to some formatted text.

Note
Note

A reference to the Infragistics3.Documents.IO assembly is required for the following code.

In C#:

using Infragistics.Documents.Word;
// Create a new instance of the WordDocumentWriter class
// using the static 'Create' method.
// After writing content, this instance must be closed.
WordDocumentWriter wordWriter = WordDocumentWriter.Create("C:\\WordDocuments\\FormattedTextInWord.docx");
wordWriter.StartDocument();
// Export formatted text to Word
this.ultraFormattedTextWordWriter1.Export(this.ultraFormattedTextEditor1, wordWriter);
wordWriter.EndDocument();
// Close the writer
wordWriter.Close();

In Visual Basic:

Imports Infragistics.Documents.Word
' Create a new instance of the WordDocumentWriter class
' using the static 'Create' method.
' After writing content, this instance must be closed.
Dim wordWriter As WordDocumentWriter = WordDocumentWriter.Create("C:\WordDocuments\FormattedTextInWord.docx")
wordWriter.StartDocument()
' Export formatted text to Word
Me.ultraFormattedTextWordWriter1.Export(Me.ultraFormattedTextEditor1, wordWriter)
wordWriter.EndDocument()
' Close the writer
wordWriter.Close()