Ste*_*ven 4 c# pdf asp.net ghostscript
我正在尝试使用 GhostScript 从 pdf 创建图像。这是我的代码:
GhostscriptWrapper.ConvertToBMP(inputPDFFilePath, outputBMPFilePath);
Run Code Online (Sandbox Code Playgroud)
这是我的GhostscriptWrapper课:
public class GhostscriptWrapper
{
public static void ConvertToBMP(string inputPath, string outputPath)
{
CallAPI(GetArgs(inputPath, outputPath));
}
private static void CallAPI(string[] args)
{
IntPtr ptr;
CreateAPIInstance(out ptr, IntPtr.Zero);
InitAPI(ptr, args.Length, args);
Cleanup(ptr);
}
private static void Cleanup(IntPtr gsInstancePtr)
{
ExitAPI(gsInstancePtr);
DeleteAPIInstance(gsInstancePtr);
}
[DllImport("gsdll32.dll", EntryPoint="gsapi_new_instance")]
private static extern int CreateAPIInstance(out IntPtr pinstance,
IntPtr caller_handle);
[DllImport("gsdll32.dll", EntryPoint="gsapi_delete_instance")]
private static extern void DeleteAPIInstance(IntPtr instance);
[DllImport("gsdll32.dll", EntryPoint="gsapi_exit")]
private static extern int ExitAPI(IntPtr instance);
[DllImport("gsdll32.dll", EntryPoint="gsapi_init_with_args")]
private static extern int InitAPI(IntPtr instance, int argc,
string[] argv);
private static string[] GetArgs(string inputPath, string outputPath)
{
return new string[] { "-dNOPAUSE", "-dBATCH", "-dSAFER",
"-dTextAlphaBits=4", "-dGraphicsAlphaBits=4", "-sDEVICE=bmp16m",
string.Format("-r{0}x{1}", 0x48, 0x48), "-dEPSCrop",
string.Format("-sOutputFile={0}", outputPath), inputPath };
}
}
Run Code Online (Sandbox Code Playgroud)
我的问题是,当我在页面上运行代码时,出现此错误:
无法加载 DLL 'gsdll32.dll':找不到指定的模块。(来自 HRESULT 的异常:0x8007007E)
我有实际的 dll 文件,我想也许我只需要添加对 bin 文件夹的引用,但是当我尝试这样做时,出现此错误:
无法添加对“D:\gsdll32.dll”的引用。在组件中找不到类型库
所以我有点卡住了 - 我有 dll,但我不知道如何引用它。有谁知道我需要做什么?
| 归档时间: |
|
| 查看次数: |
11662 次 |
| 最近记录: |