public void ConvertNodeToHtmlWithDefaultOptions() { //ExStart //ExFor:Node.ToString(SaveFormat) //ExSummary:Exports the content of a node to string in HTML format using default options. Aspose.Words.Document doc = new Aspose.Words.Document(MyDir + "Document.doc"); // Extract the last paragraph in the document to convert to HTML. Aspose.Words.Node node = doc.LastSection.Body.LastParagraph; // When ToString is called using the SaveFormat overload then conversion is executed using default save options. // When saving to HTML using default options the following settings are set: // ExportImagesAsBase64 = true // CssStyleSheetType = CssStyleSheetType.Inline // ExportFontResources = false string nodeAsHtml = node.ToString(SaveFormat.Html); //ExEnd Assert.AreEqual("<p style=\"margin:0pt\"><span style=\"font-family:'Times New Roman'; font-size:12pt\">Hello World!</span></p>", nodeAsHtml); }
public void ConvertNodeToHtmlWithSaveOptions() { //ExStart //ExFor:Node.ToString(SaveOptions) //ExSummary:Exports the content of a node to string in HTML format using custom specified options. Aspose.Words.Document doc = new Aspose.Words.Document(MyDir + "Document.doc"); // Extract the last paragraph in the document to convert to HTML. Aspose.Words.Node node = doc.LastSection.Body.LastParagraph; // Create an instance of HtmlSaveOptions and set a few options. HtmlSaveOptions saveOptions = new HtmlSaveOptions(); saveOptions.ExportHeadersFootersMode = ExportHeadersFootersMode.PerSection; saveOptions.ExportRelativeFontSize = true; // Convert the document to HTML and return as a string. Pass the instance of HtmlSaveOptions to // to use the specified options during the conversion. string nodeAsHtml = node.ToString(saveOptions); //ExEnd Assert.AreEqual("<p style=\"margin:0pt\"><span style=\"font-family:'Times New Roman'\">Hello World!</span></p>", nodeAsHtml); }