Converting docx to html with dotnet-mammoth fails at deploy server

二次信任 提交于 2019-12-02 04:29:42
Michael Williamson

The latest version of Mammoth on NuGet no longer uses edge.js, and is now just .NET code, so should work more reliably.

lazy

You can resolve this by getting the exact error when the process is trying to read the file. Below is the code from dotnet-mammoth DocumentConverter.cs. As shown below on call it is trying to read all bytes to be sent to edge

public Result<string> ConvertToHtml(string path)
        {
            var mammothJs = ReadResource("Mammoth.mammoth.browser.js") + ReadResource("Mammoth.mammoth.edge.js");

            var f = Edge.Func(mammothJs);
            var result = f(File.ReadAllBytes(path));
            Task.WaitAll(result);

            return ReadResult(result.Result);
        }

I suppose you are giving absolute path to the input. In that case the absolute path should be accessible by app identity hosting the app pool of the web application.

If the path specified is in web root directory - (not advised) - but if it is then you can use Server.MapPath

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!