Java PS到PDF的转换。重影脚本异常-无法初始化重影脚本解释器。错误代码是-100

Java PS到PDF的转换。重影脚本异常-无法初始化重影脚本解释器。错误代码是-100,java,ghostscript,ghost4j,Java,Ghostscript,Ghost4j,我正在Linux服务器上为我的应用程序运行PostScript到PDF转换服务。我已经安装了ghostscript版本8.70。我在Windows中用gsdll64.dll和ghostscript 9.26测试代码,效果很好。 我在pom文件中添加了jna 4.1.0和ghost4j 1.0.1依赖项 当我运行程序时,出现以下错误: Caused by: org.ghost4j.GhostscriptException: Cannot initialize Ghostscript interpr

我正在Linux服务器上为我的应用程序运行PostScript到PDF转换服务。我已经安装了ghostscript版本8.70。我在Windows中用gsdll64.dll和ghostscript 9.26测试代码,效果很好。 我在pom文件中添加了jna 4.1.0和ghost4j 1.0.1依赖项

当我运行程序时,出现以下错误:

Caused by: org.ghost4j.GhostscriptException: Cannot initialize Ghostscript interpreter. Error code is -100
    at org.ghost4j.Ghostscript.initialize(Ghostscript.java:365)
    at org.ghost4j.converter.PDFConverter.run(PDFConverter.java:231)
我的代码如下所示:

    InputStream iis = null;
    ByteArrayOutputStream bos = null;
    try {
        //load the bytes data into the inputstream
        iis = new ByteArrayInputStream(psBytes);
        //create the byte array output stream
        bos = new ByteArrayOutputStream();

        //load PostScript bytes through input stream
        PSDocument document = new PSDocument();
        document.load(iis);

        //create converter
        PDFConverter converter = new PDFConverter();
        //set options
        converter.setPDFSettings(PDFConverter.OPTION_PDFSETTINGS_PREPRESS);
        converter.convert(document, bos);
        return bos.toByteArray();
    }catch (org.ghost4j.document.DocumentException de){
        String[] errArg = {de.getMessage()};
        throw new ApplicationException(ErrorCode.XXXXX, errArg);
    }

所以,您并不是在使用Ghostscript,而是在使用Ghost4j。第一步应该是从命令行初始化Ghostscript本身;只需执行“gs”,看看会发生什么


错误-100只是表示“发生了致命的事情”,我对Ghost4j不太熟悉,但可能有某种方法可以查看在stdout和stderr上发生了什么,在这些频道上发送了什么消息?

所以,您并不是在使用Ghostscript,而是在使用Ghost4j。第一步应该是从命令行初始化Ghostscript本身;只需执行“gs”,看看会发生什么


错误-100只是表示“发生了致命的事情”,我不熟悉Ghost4j,但可能有某种方法可以查看在stdout和stderr上发生了什么,在这些频道上发送了什么消息?

我通过升级Ghostscript版本解决了这个问题。当我安装Ghostscript版本高于9时,它就工作了

我可以通过升级Ghostscript版本来解决这个问题。当我安装Ghostscript版本高于9时,它就工作了