说明: 在使用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/