title: Unable to load library 'gs' with Ghost4J
body: <p>I am trying to use Ghost4J in order to turn a PDF into a PNG. I am aware that people have asked this before, but not with OS X 10 and with the latest release of Ghost4J.</p>
  
  <p>I have followed the instructions listed in zippy1978's answer from here: <a href="https://stackoverflow.com/questions/4886042/pdf-to-image-using-java">PDF to image using Java</a></p>
  
  <p>I have followed everything from the <a href="http://www.ghost4j.org" rel="nofollow noreferrer">Ghost4J page</a></p>
  
  <p>I also have tried both answers from here: <a href="https://stackoverflow.com/questions/20823756/how-can-i-use-ghost4j-on-os-x-10-9">How can i use ghost4j on OS X 10.9</a></p>
  
  <p>And I have installed Ghostscript with <a href="https://www.macports.org" rel="nofollow noreferrer">Port</a> and have tried from <a href="http://pages.uoregon.edu/koch/" rel="nofollow noreferrer">Richard Koch's website</a>.</p>
  
  <p>I continue to get this error:</p>
  
  <pre><code>Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Handler processing failed; nested exception is java.lang.UnsatisfiedLinkError: Unable to load library 'gs': dlopen(libgs.dylib, 9): image not found] with root cause
  
  java.lang.UnsatisfiedLinkError: Unable to load library 'gs': dlopen(libgs.dylib, 9): image not found
      at com.sun.jna.NativeLibrary.loadLibrary(NativeLibrary.java:166)
      at com.sun.jna.NativeLibrary.getInstance(NativeLibrary.java:239)
      at com.sun.jna.Library$Handler.&lt;init&gt;(Library.java:140)
      at com.sun.jna.Native.loadLibrary(Native.java:393)
      at com.sun.jna.Native.loadLibrary(Native.java:378)
      at org.ghost4j.GhostscriptLibraryLoader.loadLibrary(GhostscriptLibraryLoader.java:39)
      at org.ghost4j.GhostscriptLibrary.&lt;clinit&gt;(GhostscriptLibrary.java:34)
      at org.ghost4j.Ghostscript.initialize(Ghostscript.java:323)
      at org.ghost4j.renderer.SimpleRenderer.run(SimpleRenderer.java:105)
      at org.ghost4j.renderer.AbstractRemoteRenderer.render(AbstractRemoteRenderer.java:86)
      at org.ghost4j.renderer.AbstractRemoteRenderer.render(AbstractRemoteRenderer.java:70)
      at com.xxxx.yyyy.controller.rest.yyyyyController.zzzz(yyyyyController.java:182)
  </code></pre>
  
  <p>What am I missing here?</p>
  
  <p>The code from my Controller that is crashing is this (I marked the line):</p>
  
  <pre><code>// imgSrc is the PDF in Base 64 and output file is a File
  
  byte[] imageByte;
  BASE64Decoder decoder = new BASE64Decoder();
  imageByte = decoder.decodeBuffer(imgSrc);
  outputfile = new File("image.pdf");
  OutputStream fop = new FileOutputStream(outputfile);
  fop.write(imageByte);
  fop.flush();
  fop.close();
  PDFDocument document = new PDFDocument();
  document.load(outputfile);
  SimpleRenderer renderer = new SimpleRenderer();
  renderer.setResolution(300);
  List images = renderer.render(document);       //CRASH TAKES PLACE HERE ***
  outputfile = new File("image.png");
  ImageIO.write((RenderedImage) images.get(0), "png", outputfile);
  </code></pre>