Я пытаюсь конвертировать PDF-файл первой страницы изображения с помощью Ghostscript.NET она отлично работает на локальном IIS, но не на веб-приложение Azure со следующей ошибкой:Ghostscript.NET PDF, чтобы изображение не работает на Windows Azure
[GhostscriptException: Delegate of an exported function couldn't be created for symbol '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();
}
}
}
Что я делаю неправильно?
Включен ли ваш gsdll64.dll в пакет? Щелкните правой кнопкой мыши-> свойства на dll, должен быть BuildAction = None, Copy to output directory = Copy Always. –
Да, это так. Infact моя локальная среда также 64-битная. Но есть 32-битная и 64-битная версии. – adil
И путь: если вы публикуете в Visual Studio, проверьте вывод сборки после публикации. Найдите выход сборки для gsdll64.dll, будет раздел о скопированных файлах и должен показать ... PackageTmp \ bin \ External \ gsdll64.dll –