是什么原因造成的Ghostscript返回-100错误? [英] What is causing Ghostscript to return an error of -100?

查看:1375
本文介绍了是什么原因造成的Ghostscript返回-100错误?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以,我使用马修以法莲GhostscriptSharp ,这是一个简单的C#包装器在我的ASP.Net MVC项目的非托管的Win32 DLL的Ghostscript。一些背景:

So, I am using Matthew Ephraim's GhostscriptSharp, which is a simple C# wrapper for the unmanaged Win32 Ghostscript DLL in my ASP.Net MVC project. Some background:

我所试图做的是有一个用户上传PDF,然后将其转换文档转换成一个形象,然后我就可以节省扎进我选择的任何目录(以及做一些其他OOP,以配合新的图像我的网站)。

What I am attempting to do is have a user upload a PDF, and then convert that document into an image that I can then save off into whatever directory I choose (as well as do some other OOP to tie that new image to my site).

我决定用莲先生的包装类(GhostscriptSharp),因为它是非常简单易用,它给了我比较干净访问DLL的API。

I decided to use Mr. Ephraim's wrapper class (GhostscriptSharp) because it was simple enough to use, and it gives me relatively clean access to the DLL's API.

要测试它,我创建了一个虚拟的C#控制台应用程序,以确保我能加载DLL,它访问,把它在本地磁盘上的PDF文件,然后把它写一个JPG到相同的本地磁盘。一些学习经验后,我取得了成功。我会交给C:\\ INPUT.pdf,那就交给我C:\\ OUTPUT.jpg。

To test it, I created a dummy C# console application to make sure I could load the DLL, access it, hand it a PDF file on the local disk and then have it write a JPG to the same local disk. After a few learning experiences, I had success. I would hand it C:\INPUT.pdf, it would hand me C:\OUTPUT.jpg.

然而,整合GhostScriptSharp code,我不得不在控制台应用程序到我的ASP.NET MVC项目,我在那里用打电话的P / Invoke,Ghostscript的与INT /错误返回DLL后点code -100 ,这是一个致命的错误(在GhostScript的源$ C ​​$ C名为 E_Fatal )。我得到同样的结果既即通过HTML表单上传的文件,如果我把它完全一样的硬件codeD,我在我工作的控制台应用程序使用的路径。

However, after integrating the GhostScriptSharp code that I had in the console application into my ASP.NET MVC project to the point of where I was calling the DLL with P/invoke, Ghostscript is returning with the int/error code -100, which is a fatal error (is called E_Fatal in the GhostScript source code). I get the same result with both the file that is uploaded through the HTML form, and if I hand it the exact same hard-coded paths that I used in my working console application.

有关引用,引发异常的线路都在93-97 GhostScriptSharp.cs(这是在 CallApi 功能):

For reference, the lines which the exception is thrown are 93-97 in GhostScriptSharp.cs (which is in the CallApi function):

int result = InitAPI(gsInstancePtr, args.Length, args);

if (result < 0) {
  throw new ExternalException("Ghostscript conversion error", result);
}

显然异常被抛出,因为结果 -100

当InitAPI被调用时,该实例PTR是一个有效的 INT (虽然我不知道,如果GS的实例正确与否),ARGS的长度20(是一个的String [] )的有效GhostScript的选项(包括正确转义的路径,我的输入和放大器;输出文件)。

When InitAPI is called, the instance ptr is a valid int (though I don't know if the instance of GS is correct or not), args has a length of 20 (is a string[]) of valid GhostScript options (including the correctly-escaped paths to my input & output files).

长话短说,我究竟做错了什么?错误code -100 似乎是一个包罗万象的,因为没有文件,指出什么可能是错误怎么回事。

Long story short, what am I doing wrong? The error code -100 seems like a catch-all because there is no documentation that states what could possibly be going wrong here.

任何帮助很多AP preciated,提前谢谢你。

Any help is much appreciated, thank you in advance.

推荐答案

所以,最终被认为在这里出轨我在这个特定实例的ID10T错误。

So, ended up being an ID10T error that was derailing me here in this specific instance.

在马太福音莲的GhostscriptSharp code,他用了几个枚举的定义提出了Ghostscript的选项,以及两个特别是在 GhostscriptDevices GhostscriptPageSizes 枚举。问题是,他们写ReSharper的方式(Jetbrains的Visual Studio的插件)的默认规则命名枚举成员。没有想到,我修复了所有这些定义来取悦ReSharper的没有意识到,这些都直接传递到Ghostscript的,这样反而让 A7 -sPAPERSIZE GS是越来越 A7 ,以及 -sDEVICE 当时天色 JPEG 而不是 JPEG

In Matthew Ephraim's GhostscriptSharp code, he uses a couple of enums to define the options set forth for Ghostscript, and two in particular were the GhostscriptDevices and GhostscriptPageSizes enums. Problem is, the way they're written Resharper (Jetbrains Visual Studio plugin) has default rules for naming Enum members. Not thinking, I fixed all of these definitions to please Resharper not realizing that these are passed directly to Ghostscript, so instead of getting a7 for -sPAPERSIZE GS was getting A7, and for -sDEVICE it was getting Jpeg instead of jpeg.

有关暂且权限并不在我这边出了问题,但只是因为我跑在Visual Studio卡西尼web开发测试服务器。

For the time being permissions weren't a problem on my end, but only because I run the Cassini web dev test server in Visual Studio.

由于@MarkRedman和@tvanfosson他们有益的建议!

Thanks to @MarkRedman and @tvanfosson for their helpful suggestions!

这篇关于是什么原因造成的Ghostscript返回-100错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆