NodeToString(SaveOptions) Method

Exports the content of the node into a string using the specified save options.

Namespace:  Aspose.Words
Assembly:  Aspose.Words (in Aspose.Words.dll) Version: 20.8.0

Syntax

public string ToString(
	SaveOptions saveOptions
)

Parameters

saveOptions
Type: Aspose.Words.SavingSaveOptions
Specifies the options that control how the node is saved.

Return Value

Type: String
The content of the node in the specified format.

Examples

Exports the content of a node to String in HTML format.
Document doc = new Document(MyDir + "Document.docx");

// Extract the last paragraph in the document to convert to HTML
Node node = doc.LastSection.Body.LastParagraph;

// When ToString is called using the html SaveFormat overload then the node is converted directly to html
Assert.AreEqual("<p style=\"margin-top:0pt; margin-bottom:8pt; line-height:108%; font-size:12pt\">" +
                "<span style=\"font-family:'Times New Roman'\">Hello World!</span>" +
                "</p>", node.ToString(SaveFormat.Html));

// We can also modify the result of this conversion using a SaveOptions object
HtmlSaveOptions saveOptions = new HtmlSaveOptions();
saveOptions.ExportRelativeFontSize = true;

Assert.AreEqual("<p style=\"margin-top:0pt; margin-bottom:8pt; line-height:108%\">" +
                "<span style=\"font-family:'Times New Roman'\">Hello World!</span>" +
                "</p>", node.ToString(saveOptions));

See Also