Converting PPTX to image does not work on Windows 2012 server

We have a requirement to convert downloaded PPT or PPTX files to image files. We developed this work locally with the following (POC code):

Application pptApplication = new Application();
Microsoft.Office.Interop.PowerPoint.Presentation pptPresentation = pptApplication.Presentations.Open2007(filePath, MsoTriState.msoFalse, MsoTriState.msoFalse, MsoTriState.msoFalse);
List<string> files = new List<string>();
for (int i = 1; i <= pptPresentation.Slides.Count; i++)
{
    pptPresentation.SaveCopyAs(serverPath + randomId, PpSaveAsFileType.ppSaveAsPNG, MsoTriState.msoTrue);
    files.Add(root + "Uploads/Slide" + i + ".PNG");
}
pptPresentation.Close();

Now that this code is deployed to Windows Server 2012 R2, I get the following error:

enter image description here This error looks like a permission issue, and when I googled, I found several solutions that I tried with no luck, here are some of them:

. .

0
1

, , 7 .

  • " " C:\Windows\SysWOW64\config\systemprofile\Desktop (64- ) enter image description here
  • IIS ApplicationPool 'ApplicationPoolIdentity' 'LocalSystem'. enter image description here

.

, :

Application pptApplication = new Application();
Microsoft.Office.Interop.PowerPoint.Presentation pptPresentation = pptApplication.Presentations.Open2007(Server.MapPath("~/tempslides/pptfilename.pptx"), MsoTriState.msoFalse, MsoTriState.msoFalse, MsoTriState.msoFalse);
List<string> files = new List<string>();
for (int i = 1; i <= pptPresentation.Slides.Count; i++)
{
    pptPresentation.SaveCopyAs(serverPath + randomId, PpSaveAsFileType.ppSaveAsPNG, MsoTriState.msoTrue);
    files.Add(Server.MapPath("~/tempslides") + "/slide" + i + ".PNG");
}
pptPresentation.Close();

, interop lib . enter image description here

, .

0

All Articles