簡體   English   中英

Ghostscript.NET pdf圖像無法在windows azure上工作

[英]Ghostscript.NET pdf to image not working on windows azure

我試圖使用Ghostscript.NET將pdf第一頁轉換為圖像它在本地IIS上正常工作但在Azure Web應用程序上失敗並出現以下錯誤:

[GhostscriptException:無法為符號'gsapi_revision'創建導出函數的委托
Ghostscript.NET.GhostscriptLibrary.Initialize()+ 865
Ghostscript.NET.GhostscriptLibrary..ctor(GhostscriptVersionInfo version,Boolean fromMemory)+178
Ghostscript.NET.Interpreter.GhostscriptInterpreter..ctor(GhostscriptVersionInfo version,Boolean fromMemory)+48
Ghostscript.NET.Viewer.GhostscriptViewer.Open(String path,GhostscriptVersionInfo versionInfo,Boolean dllFromMemory)+75
Ghostscript.NET.Viewer.GhostscriptViewer.Open(Stream stream,GhostscriptVersionInfo versionInfo,Boolean dllFromMemory)+59
Ghostscript.NET.Rasterizer.GhostscriptRasterizer.Open(Stream stream,GhostscriptVersionInfo versionInfo,Boolean dllFromMemory)+40
VirtualWindow.Dropzone.Pages.Home.btnUpload_Click(Object sender,EventArgs e)+270
System.Web.UI.WebControls.Button.OnClick(EventArgs e)+116
System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument)+108
System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument)+12
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl,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();
        }   
    }
}

我做錯了什么?

好的發現了這個問題。 包括路徑在內的所有內容都已正確設置。 我的網站托管在免費計划上,因此它被配置為32位環境。 我的本地環境是64位工作。 所以我gsdll32.dllgsdll32.dll 更新了azure,它也開始在azure上工作了。

問題是錯誤的gsdll32.dll

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM