You can read more at: Convert HTML Webpage to Word File (DOCX/DOC) using C#
Created
January 18, 2021 21:34
-
-
Save aspose-com-gists/88f36d6711b5b9d4dfa67ea1c55af409 to your computer and use it in GitHub Desktop.
Convert HTML Webpage to Word File (DOCX/DOC) using C#
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Prepare an HTML code and save it to the file. | |
var code = @"<span>Hello World!!</span>"; | |
System.IO.File.WriteAllText("document.html", code); | |
// Initialize an HTML document from the file | |
using (var document = new HTMLDocument("document.html")) | |
{ | |
// Initialize DocSaveOptions | |
var options = new Aspose.Html.Saving.DocSaveOptions(); | |
// Convert HTML webpage to DOCX | |
Aspose.Html.Converters.Converter.ConvertHTML(document, options, "output.docx"); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Prepare an HTML code and save it to the file | |
var code = @"<span>Hello World!!</span>"; | |
System.IO.File.WriteAllText("document.html", code); | |
// Set A5 as a page-size | |
var options = new Aspose.Html.Saving.DocSaveOptions | |
{ | |
PageSetup = | |
{ | |
AnyPage = new Aspose.Html.Drawing.Page() | |
{ | |
Size = new Aspose.Html.Drawing.Size(Aspose.Html.Drawing.Length.FromInches(8.3f), Aspose.Html.Drawing.Length.FromInches(5.8f)) | |
} | |
} | |
}; | |
// Convert HTML document to DOCX | |
Aspose.Html.Converters.Converter.ConvertHTML("document.html", options, "output.docx"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment