adi*_*dil 5 c# pdf asp.net azure ghostscript.net
我正在尝试使用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();
}
}
}
Run Code Online (Sandbox Code Playgroud)
我做错了什么?
好的找到问题了。包括路径在内的所有内容均已正确设置。我的网站采用免费计划托管,因此配置为 32 位环境。我的本地环境是 64 位,可以正常工作。于是我重新下载了gsdll32.dll. 更新了 azure,它也开始在 azure 上运行。
问题是错误的gsdll32.dll。