内容.. NET pdf到映像不能在windows azure上工作

本文关键字:windows azure 工作 不能 NET pdf 映像 内容 | 更新日期: 2023-09-27 18:07:11

我正在尝试使用Ghostscript将pdf第一页转换为图像。. NET在本地IIS上工作正常,但在Azure web应用程序上失败,出现以下错误:

[GhostscriptException:导出函数的委托不能是。为符号'gsapi_revision']创建
Ghostscript.NET.GhostscriptLibrary.Initialize () + 865
Ghostscript.NET.GhostscriptLibrary . .男星(GhostscriptVersionInfo版本,Boolean fromMemory) +178
Ghostscript.NET.Interpreter.GhostscriptInterpreter . .男星(GhostscriptVersionInfoversion, Boolean fromMemory) +48
Ghostscript.NET.Viewer.GhostscriptViewer。打开(String路径,GhostscriptVersionInfo versionInfo, Boolean dllFromMemory) +75
Ghostscript.NET.Viewer.GhostscriptViewer。Open(流流,GhostscriptVersionInfo versionInfo, Boolean dllFromMemory) +59
Ghostscript.NET.Rasterizer.GhostscriptRasterizer。Open(流流,GhostscriptVersionInfo versionInfo, Boolean dllFromMemory) +40
VirtualWindow.Dropzone.Pages.Home。btnUpload_Click(对象发送者,EventArgs e) +270
System.Web.UI.WebControls.Button。OnClick(EventArgs e) +116
System.Web.UI.WebControls.Button.RaisePostBackEvent(字符串eventArgument) + 108
System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(字符串eventArgument) + 12
System.Web.UI.Page.RaisePostBackEvent (IPostBackEventHandlersourceControl, String eventArgument) +15
System.Web.UI.Page。RaisePostBackEvent (NameValueCollection postData)+ 31 System.Web.UI.Page。ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)+ 3582

我的代码在 下面
protected void btnUpload_Click(object sender, EventArgs e)
{
    if (fileUpload.HasFile)
    {
        string ghostDllPath = HttpContext.Current.Server.MapPath("~/bin/External");
        GhostscriptRasterizer rasterizer = null;
        GhostscriptVersionInfo vesion = null;
        if (Environment.Is64BitProcess)
            vesion = new Ghostscript.NET.GhostscriptVersionInfo(new Version(0, 0, 0), ghostDllPath + @"'gsdll64.dll", string.Empty, Ghostscript.NET.GhostscriptLicense.GPL);
        else
            vesion = new Ghostscript.NET.GhostscriptVersionInfo(new Version(0, 0, 0), ghostDllPath + @"'gsdll32.dll", string.Empty, Ghostscript.NET.GhostscriptLicense.GPL);
        using (rasterizer = new Ghostscript.NET.Rasterizer.GhostscriptRasterizer())
        {
            rasterizer.Open(fileUpload.PostedFile.InputStream, vesion, false);
            if (rasterizer.PageCount > 0)
            {
                  int dpi = 90;
                  System.Drawing.Image img = rasterizer.GetPage(dpi, dpi, 1);
                  using (MemoryStream ms = new MemoryStream())
                  {
                       string file = Guid.NewGuid().ToString() + ".png";
                       img.Save(ms, ImageFormat.Png);
                       Response.ContentType = "image/png";
                       byte[] data = ms.ToArray();
                       Response.OutputStream.Write(data, 0, data.Length);
                       Response.AddHeader("Content-Disposition", "attachment;filename=" + file);
                       Response.Flush();
                   }
            }
            rasterizer.Close();
        }   
    }
}

我做错了什么?

内容.. NET pdf到映像不能在windows azure上工作

找到问题了。包括路径在内的所有内容都正确设置。我的站点托管在免费计划上,因此它被配置为32位环境。我的本地环境是64位的。所以我重新下载了gsdll32.dll。更新了azure,它也开始在azure上工作。

问题是错误的gsdll32.dll