.net - 转换 Word 文档时 Azure 云上的图像问题。使用 aspose.words 转换为 html

标签 .net asp.net-mvc azure cloud azure-blob-storage

说明: 在使用aspose Words将word文档转换为html文件时,它从word文档中提取图像并将其存储在当前文件夹中,并传递对html“src”标签的引用,以便图像可以在转换后的html文档中显示。

问题: 当我将转换后的 html 文件上传到 Microsoft Azure 云(即 blob)时,它不显示图像, 原因是要在 html 文件中显示图像,微软限制首先将嵌入的图像上传到 blob,然后将每个图像的 url 传递到 html 文件的“src”标记。

Aspose Words 如何解决这个问题?

我使用 Asp.Net MVC 4 作为开发框架。

最佳答案

Aspose.Words API 提供将Word 文件中的图像导出为HTML 作为Base64 字符串的功能。这样图像就会嵌入到 HTML 文件中,您无需单独上传任何图像文件夹/图像。以下是示例代码:

//Open the Word document
Document doc = new Document("C:\\data\\image.doc");

//instantiate HTML saving options
Aspose.Words.Saving.HtmlSaveOptions option = new Aspose.Words.Saving.HtmlSaveOptions();

//Export the images in doc to Base64 string
option.ExportImagesAsBase64 = true;

//Save format is HTML
option.SaveFormat = Aspose.Words.SaveFormat.Html;

//Save the resultant HTML file
doc.Save("C:\\Data\\Image2.html",option);

希望这有帮助。

关于.net - 转换 Word 文档时 Azure 云上的图像问题。使用 aspose.words 转换为 html,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22488882/

相关文章:

asp.net-mvc - 无法使 Type.GetType(string TypeName) 方法和 MemberInfo.CustomAttributes 属性在 DNX Core 5.0 中可用

azure - ILogger 的 LogWarning、LogInformation 和 LogDebug 使用什么类型的 Azure 警报信号?

c# - ASP.NET MVC Identity - 一起使用内部用户和 Azure AD 身份验证

c# - AutoResetEvent/ManualResetEvent 消耗什么资源?

c# - 将 StackTrace 附加到异常而不在 C#/.NET 中抛出

.net - 确定应用程序是否在azure中运行

.net - 加入和切割 mpeg 2 视频文件

javascript - Mvc完成异步脚本加载

node.js - 调试 Node.js - iisnode 模块无法部署初始化调试器所需的支持文件

c# - 无法在单元测试中加载文件或程序集“System.Web.Mvc”