LoadOptions Constructor (LoadFormat, String, String) |
Namespace: Aspose.Words
// The url of the page to load const string url = "http://www.aspose.com/"; // Create a WebClient object to easily extract the HTML from the page WebClient client = new WebClient(); string pageSource = client.DownloadString(url); client.Dispose(); // Get the HTML as bytes for loading into a stream Encoding encoding = client.Encoding; byte[] pageBytes = encoding.GetBytes(pageSource); // Load the HTML into a stream. using (MemoryStream stream = new MemoryStream(pageBytes)) { // The baseUri property should be set to ensure any relative img paths are retrieved correctly LoadOptions options = new LoadOptions(Aspose.Words.LoadFormat.Html, "", url); // Load the HTML document from stream and pass the LoadOptions object Document doc = new Document(stream, options); // Save the document to disk // The extension of the filename can be changed to save the document into other formats. e.g PDF, DOCX, ODT, RTF. doc.Save(ArtifactsDir + "Document.InsertHtmlFromWebPage.doc"); }