【问题标题】:Unable to load library 'gsdll32'无法加载库“gsdll32”
【发布时间】:2012-06-16 07:46:24
【问题描述】:

我正在运行以下代码以使用 Ghost4j 从 pdf 创建 bmp 图像

我有一个命令,它由 GhostScript 生成器执行,用于从 pdf 生成页面的 Bmp 图像。 代码是:

package ghost;

import net.sf.ghost4j.Ghostscript;
import net.sf.ghost4j.GhostscriptException;

public class GhostDemo {
public static void main(String[] a){
    Ghostscript gs = Ghostscript.getInstance(); //create gs instance
    String[] gsArgs = new String[10];/*command string array*/
    gsArgs[0] = "-dUseCropBox";/*use crop box*/
    gsArgs[1] = "-dNOPAUSE";
    gsArgs[2] = "-dBATCH";
    gsArgs[3] = "-dSAFER";
    gsArgs[3] = "-r300";
    gsArgs[4] = "-sDEVICE=bmp16m";
    gsArgs[6] = "-dTextAlphaBits=4";
    gsArgs[5] = "-sOutputFile=C:/PagesWorkspace/1/masterData/1.bmp";/*bmp file location with name*/
    gsArgs[6] = "C:/MasterWorkspace/pipeline.pdf";/*pdf location with name*/

    try {

        gs.initialize(gsArgs);  /*initialise ghost interpreter*/
        gs.exit();

    } catch (GhostscriptException e) {
       e.printStackTrace();
    }
}
}

我遇到了异常

Exception in thread "main" java.lang.UnsatisfiedLinkError: Unable to load library 'gsdll32': The specified module could not be found.

    at com.sun.jna.NativeLibrary.loadLibrary(NativeLibrary.java:145)
    at com.sun.jna.NativeLibrary.getInstance(NativeLibrary.java:188)
    at com.sun.jna.Library$Handler.<init>(Library.java:123)
    at com.sun.jna.Native.loadLibrary(Native.java:255)
    at com.sun.jna.Native.loadLibrary(Native.java:241)
    at net.sf.ghost4j.GhostscriptLibraryLoader.loadLibrary(GhostscriptLibraryLoader.java:36)
    at net.sf.ghost4j.GhostscriptLibrary.<clinit>(GhostscriptLibrary.java:32)
    at net.sf.ghost4j.Ghostscript.initialize(Ghostscript.java:292)
    at ghost.GhostDemo.main(GhostDemo.java:22)

谁能告诉我为什么会出现这个异常?

【问题讨论】:

    标签: java ghostscript


    【解决方案1】:

    您是否安装了 Ghostscript?

    • 如果是,是哪个版本?
    • 如果是,在哪个位置?
    • 是否包含文件gsdll32.dll

    如果没有,请download the Ghostscript installer for Win32 并运行它。安装后在%your_install_dir%\gs\gs9.05\bin\目录下应该有一个文件gsdll32.dll

    【讨论】:

    • 将此 dll 复制到 Windows/system32 文件夹后工作正常
    • 在哪里可以找到 64 位的 .dll
    【解决方案2】:

    在 eclipse 项目中粘贴 dll 文件使我的程序正常工作!

    【讨论】:

      【解决方案3】:

      对于 SO 社区,要检查此错误的另一件事是您使用的是 32 位 Java。如果您的 Java 实例是 64 位,您将收到完全相同的消息:

      Unable to load library 'gsdll32': The specified module could not be found.

      即使您 指向正确的 dll,也无需任何进一步的解释。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2011-06-14
        • 2018-12-01
        • 2013-06-17
        • 2020-06-10
        • 2012-07-30
        相关资源
        最近更新 更多