2017-10-08 67 views
0

我正在開發ASP.net web api(.NET Framework)並使用「Microsoft Office Document Imaging」v12。 在我的本地系統上,它工作正常。但後來我把它放在我的天藍色的web應用程序,我得到了以下錯誤:使用「Microsoft Office Document Imaging」獲取Azure Web App上的錯誤

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.

我敢肯定,我必須安裝「微軟Office Document Imaging中」。但是,當我僅使用Azure Web App時,我該怎麼做?


編輯:我發現了一個更好的方法來解決我的問題:https://azure.microsoft.com/de-de/services/cognitive-services/computer-vision/

回答

0

據我所知,我們沒有安裝「Microsoft Office文檔圖像」(使用許可Sharepoint安裝包)在天藍色的網絡應用程序。

Azure的web應用程序env作爲sanbox,有幾個嚴格的限制和限制,我們不能將它用作azure虛擬機。更多細節,你可以參考這個article

如果您仍然想使用「Microsoft Office Document Imaging」,我建議您可以考慮使用Azure虛擬機,我們有完全權限來更改env。

此外,我想你會將文檔轉換爲圖像。我建議您可以嘗試使用Aspose.Words for .NET將文檔轉換爲圖像或PDF。

這個包可以安裝在Nuget包中。

更多細節,你可以參考下面的測試演示代碼。

 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); 
     } 

結果:

enter image description here

+0

謝謝您的回答! 我使用MODI從文檔/圖像中提取單詞。Aspose.Words也可以嗎? 我看到也有Aspose.OCR,但它的成本太高,我的需求.. –

+0

我建議你可以考慮使用天藍色的虛擬機。正如我上面的天藍色網絡應用沙箱[鏈接](https://github.com/projectkudu/kudu/wiki/Azure-Web-App-sandbox#unsupported-frameworks)所說,天藍色的網絡應用只支持第三方轉換工具。所以如果你使用sadbox不支持的工具,你將面臨同樣的錯誤。 –

相關問題