zippy1978 / ghost4j

Java wrapper for Ghostscript C API + PS/PDF document handling API
http://www.ghost4j.org
GNU Lesser General Public License v3.0
64 stars 38 forks source link

Exception when using SimpleRenderer #40

Closed redserpent7 closed 8 years ago

redserpent7 commented 9 years ago

Hi,

I am facing an issue with Ghost4j. I am using JDK 1.8 and Ghost4J 1.0.0. I am getting the following exception when calling this code:

                PDFDocument doc = new PDFDocument();
                doc.load(new File(inFile));

                SimpleRenderer renderer = new SimpleRenderer();
                renderer.setResolution(300);
                List<Image> images = renderer.render(doc, 1, 1);

I get the following exception and trace:

Exception in thread "main" java.lang.AbstractMethodError: com.sun.jna.Structure.getFieldOrder()Ljava/util/List;
    at com.sun.jna.Structure.fieldOrder(Structure.java:884)
    at com.sun.jna.Structure.getFields(Structure.java:910)
    at com.sun.jna.Structure.deriveLayout(Structure.java:1058)
    at com.sun.jna.Structure.calculateSize(Structure.java:982)
    at com.sun.jna.Structure.calculateSize(Structure.java:949)
    at com.sun.jna.Structure.allocateMemory(Structure.java:375)
    at com.sun.jna.Structure.<init>(Structure.java:184)
    at com.sun.jna.Structure.<init>(Structure.java:172)
    at com.sun.jna.Structure.<init>(Structure.java:159)
    at com.sun.jna.Structure.<init>(Structure.java:151)
    at org.ghost4j.GhostscriptLibrary$display_callback_s.<init>(GhostscriptLibrary.java:63)
    at org.ghost4j.Ghostscript.buildNativeDisplayCallback(Ghostscript.java:381)
    at org.ghost4j.Ghostscript.initialize(Ghostscript.java:336)
    at org.ghost4j.renderer.SimpleRenderer.run(SimpleRenderer.java:105)
    at org.ghost4j.renderer.AbstractRemoteRenderer.render(AbstractRemoteRenderer.java:86)
    at com.appstest.documentconverter.PDFManager.GetThumbPDF(PDFManager.java:75)
    at MapTest.TestDocConv(MapTest.java:43)
    at MapTest.main(MapTest.java:34)

And if it helps, I'm running the code on Windows using Ghostscript (gsdll64.dll) v9.16

zippy1978 commented 9 years ago

Hi

It seems JNA lib used with Ghost4J is not compliant with Java 8... I never tested it...

Or maybe this is the Ghostscript version. Which one do you use ?

Regards Gilles

Le 1 sept. 2015 à 16:38, redserpent7 notifications@github.com a écrit :

Hi,

I am facing an issue with Ghost4j. I am using JDK 1.8 and Ghost4J 1.0.0. I am getting the following exception when calling this code:

            PDFDocument doc = new PDFDocument();
            doc.load(new File(inFile));

            SimpleRenderer renderer = new SimpleRenderer();
            renderer.setResolution(300);
            List<Image> images = renderer.render(doc, 1, 1);

I get the following exception and trace:

Exception in thread "main" java.lang.AbstractMethodError: com.sun.jna.Structure.getFieldOrder()Ljava/util/List; at com.sun.jna.Structure.fieldOrder(Structure.java:884) at com.sun.jna.Structure.getFields(Structure.java:910) at com.sun.jna.Structure.deriveLayout(Structure.java:1058) at com.sun.jna.Structure.calculateSize(Structure.java:982) at com.sun.jna.Structure.calculateSize(Structure.java:949) at com.sun.jna.Structure.allocateMemory(Structure.java:375) at com.sun.jna.Structure.(Structure.java:184) at com.sun.jna.Structure.(Structure.java:172) at com.sun.jna.Structure.(Structure.java:159) at com.sun.jna.Structure.(Structure.java:151) at org.ghost4j.GhostscriptLibrary$display_callback_s.(GhostscriptLibrary.java:63) at org.ghost4j.Ghostscript.buildNativeDisplayCallback(Ghostscript.java:381) at org.ghost4j.Ghostscript.initialize(Ghostscript.java:336) at org.ghost4j.renderer.SimpleRenderer.run(SimpleRenderer.java:105) at org.ghost4j.renderer.AbstractRemoteRenderer.render(AbstractRemoteRenderer.java:86) at com.appstest.documentconverter.PDFManager.GetThumbPDF(PDFManager.java:75) at MapTest.TestDocConv(MapTest.java:43) at MapTest.main(MapTest.java:34)

— Reply to this email directly or view it on GitHub.

redserpent7 commented 9 years ago

Well I tried using JDK 1.7 and 1.6 but that did not help. As I said, I'm using 64-bit Ghostscript 9.16 on Windows

zippy1978 commented 9 years ago

Hi,

It seems to be related to a JNA error : http://stackoverflow.com/questions/13096741/jna-capturing-every-window-java-lang-abstractmethoderror

But I did not have time to investigate more...

nguyenq commented 8 years ago

Hi Gilles,

Latest JNA versions require that class extending Structure must override abstract method getFieldOrder. GhostscriptLibrary class has two nested classes that extend Structure.

Regards, Quan

GhostscriptLibrary.java.txt

zippy1978 commented 8 years ago

Hi,

You are right, Ghost4J is not compliant with latests JNA releases.

If the file you joined a fix ?

In this case, could you issue a pull request instead ?

nguyenq commented 8 years ago

Certainly. There's something about GhostscriptTest. If I ran its test cases individually, they would pass. I tested with Ghostscript 9.16 on Windows 10. GS 9.18 would throw exceptions.

zippy1978 commented 8 years ago

OK thank you for the PR, it is merged !

KLBonn commented 8 years ago

Hi Gilles, I seem to suffer from the same error. Do I understand correctly that you have merged the fix in 1.0.1-SNAPSHOT? Can you publish a release 1.0.1, so I can use the fixed version?

Best regards!

nguyenq commented 8 years ago

We certainly can use Release 1.0.1 with current JNA version.

Thank you.

4F2E4A2E commented 8 years ago

Great work guys. We could use it in tess4j. Let's release this, what do you say?