2015-08-10 2 views
6

Я пытаюсь конвертировать 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(); 
     } 
    } 
} 

Что я делаю неправильно?

+0

Включен ли ваш gsdll64.dll в пакет? Щелкните правой кнопкой мыши-> свойства на dll, должен быть BuildAction = None, Copy to output directory = Copy Always. –

+0

Да, это так. Infact моя локальная среда также 64-битная. Но есть 32-битная и 64-битная версии. – adil

+0

И путь: если вы публикуете в Visual Studio, проверьте вывод сборки после публикации. Найдите выход сборки для gsdll64.dll, будет раздел о скопированных файлах и должен показать ... PackageTmp \ bin \ External \ gsdll64.dll –

ответ

3

ОК нашел проблему. Каждая вещь, включая пути, была правильно настроена. Мой сайт был размещен на бесплатном плане, и поэтому он был настроен на 32-разрядную среду. Моя локальная среда была 64 бит, которая работала. Поэтому я загрузил gsdll32.dll. Обновлен лазурь, и он начал работать на лазурном тоже.

Проблема была с неправильным gsdll32.dll.

Спасибо за ваше время.

+0

, откуда вы взяли gsdll32.dll и gsdll64.dll? – pmeyer

Смежные вопросы