Could not load library 'gsdll32'

I am running the following code to create a BMP image from pdf using Ghost4j

I have a commad that runs a GhostScript generator to generate a Bmp page image from pdf. The code:

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();
    }
}
}

I get an exception

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)

Can someone tell me why I get this exception?

+5
source share
3 answers

Do you have Ghostscript installed at all?

  • If so, which version?
  • If so, in which place?
  • Does it include a file gsdll32.dll?

If not, download the Ghostscript installer for Win32 and run it. After installation, there should be a file gsdll32.dllin the directory%your_install_dir%\gs\gs9.05\bin\

+12
source

dll eclipse !

+6

For the SO community, another thing to check for this error is that you are using 32-bit Java. If your Java instance is 64-bit, you will receive the same message:

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

without any further explanation, even if you specify the correct dll.

+2
source

All Articles