Search code examples
c#asp.netazuremodi

Getting error on Azure Web App using "Microsoft Office Document Imaging"


I'm developing an ASP.net web api (.NET Framework) and use "Microsoft Office Document Imaging" v12. On my local system, it works fine. But then I pushed it on my azure web app and I got following error:

Could not load file or assembly 'Interop.MODI, Version=12.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified.

I'm sure, I have to install "Microsoft Office Document Imaging". But how can I do this when I'm just using an Azure Web App?


EDIT: I found a much better way to solve my problem: https://azure.microsoft.com/de-de/services/cognitive-services/computer-vision/


Solution

  • As far as I know, we don't have permission to install the "Microsoft Office Document Imaging"(using sharepoint install package) in the azure web app.

    Azure web app env as a sanbox, there are several strict restrictions and limitations, we couldn't use it as azure VM. More details, you could refer to this article.

    If you still want to use "Microsoft Office Document Imaging", I suggest you could consider using azure VM which we have full permission to change the env.

    Besides,I guess you wan to convert the doc to image. I suggest you could try to use Aspose.Words for .NET to convert the doc to image or PDF.

    This package could be installed in the Nuget Package.

    More details, you could refer to below test demo codes.

            string location = Server.MapPath("/exe/");
            Document document = new Document(Server.MapPath("/exe/bbbb.docx"));
            ImageSaveOptions options = new ImageSaveOptions(SaveFormat.Png);
            options.PageCount = 1;
    
            // Save each page of the document as Png.
            for (int i = 0; i < document.PageCount; i++)
            {
                options.PageIndex = i;
                document.Save(string.Format(location+ @"\out_{0}.png", i), options);
            }
    

    Result:

    enter image description here