我编写了一个代码,将演示文稿中的所有幻灯片保存为 jpeg。它在我的系统本地 Visual Studio 中运行良好,但是当我将其部署到 Azure 应用服务上时,出现 500 内部服务器错误。
代码:
using pptd = NetOffice.PowerPointApi;
using NetOffice.PowerPointApi.Enums;
using NetOffice.OfficeApi.Enums;
public void genThumbnails(string originalfileName,string renamedFilename, string dirPath)
{
pptd.Application pptApplication = new pptd.Application();
pptd.Presentation pptPresentation = pptApplication.Presentations.Open(dirPath + renamedFilename, MsoTriState.msoFalse, MsoTriState.msoFalse, MsoTriState.msoFalse);
int i = 0;
foreach (pptd.Slide pptSlide in pptPresentation.Slides)
{
pptSlide.Export(dirPath + originalfileName + "_slide" + i + ".jpg", "jpg", 1280, 720);
i++;
}
pptPresentation.Close();
}
我犯了什么错误? NetOffice 软件包是否也需要像 Office.Interop 一样在服务器上安装 MS Office?
最佳答案
标准 Windows 和 Linux Web 应用程序使用受祝福的操作系统镜像。作为 PaaS 设计的一部分,客户可以运行的内容受到限制,因为不存在 MS Office 互操作,而且 Azure Web Apps 是一个沙箱。
我的建议是创建一个具有您所需的必要依赖项的容器镜像,然后将自定义容器部署到 Azure Web App Container .
关于azure - 在 azure 应用服务上使用 NetOffice.PowerPointApi,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65166995/