IT行业爆品采购节来啦!整合所有格式的Aspose.Total永久授权正在火热促销中,乐享85折起!联系客服立马1分钟了解全部咨询!

使用C#VB.NET以编程方式将Word DOC或DOCX转换为HTML 页
使用C#或VB.NET在.NET应用程序中以编程方式将Word文档(DOC / DOCX)有效地转换为HTML 页。您需要按照以下步骤进行转换:
- 加载输入的DOCX Word文档。
- 初始化HtmlSaveOptions的实例。
- 保存输出的HTML文件。
下面的代码段遵循这些步骤,并显示如何使用C#或VB.NET将DOC / DOCX转换为HTML:
// Load the document from disk.Document doc = new Document(dataDir + "Test File.docx");// Set HtmlSaveOptionsHtmlSaveOptions options = new HtmlSaveOptions();options.SaveFormat = SaveFormat.Html;// Save the document into HTMLdoc.Save(dataDir + "Document.html", options);
使用C#中的往返信息将Word DOC或DOCX转换为HTML
将Word转换为HTML时会保存一些其他信息。它被称为往返信息,对于将转换后的HTML文件再次呈现为word文档的情况很有用。您可以按照以下步骤使用C#将DOC / DOCX转换为HTML:
- 加载输入的word文档。
- 将ExportRoundtripInformation设置为true。
- 保存输出的HTML文件。
下面的代码段说明了如何使用C#或VB.NET将Word DOC / DOCX文件与往返信息转换为HTML:
// Load the document from disk.Document doc = new Document(dataDir + "Test File (doc).docx");HtmlSaveOptions options = new HtmlSaveOptions();// HtmlSaveOptions.ExportRoundtripInformation property specifies// Whether to write the roundtrip information when saving to HTML, MHTML or EPUB.// Default value is true for HTML and false for MHTML and EPUB.options.ExportRoundtripInformation = true; doc.Save(dataDir + "ExportRoundtripInformation_out.html", options);
在C#VB.NET中将Word DOC或DOCX转换为MHTML
当需要带有嵌入式图像和字体的单个HTML文件时,MHTML文件格式值得一提。您可以按照以下步骤将Word文档(DOC / DOCX)转换为MHTML:
- 加载源DOC / DOCX文件。
- 将SaveFormat设置为MHTML。
下面的代码段显示了如何使用C#或VB.NET将Word文档(DOC / DOCX)转换为MHML:
// Load the document from disk.Document doc = new Document(dataDir + "Test File.docx");// Set HtmlSaveOptionsHtmlSaveOptions options = new HtmlSaveOptions();options.SaveFormat = SaveFormat.Mhtml;// Save the document into MHTMLdoc.Save(dataDir + "Document.mhtml", options);
还想要更多吗可以点击阅读【2020 · Aspose最新资源整合】,查找需要的教程资源。如果您有任何疑问或需求,请随时加入Aspose技术交流群(),我们很高兴为您提供查询和咨询。

标签:
声明:本站部分文章及图片源自用户投稿,如本站任何资料有侵权请您尽早请联系jinwei@zod.com.cn进行处理,非常感谢!