1

I am running PostScript to PDF conversion service for my application in Linux Server. I have ghostscript version 8.70 installed. I was testing the code in Windows with gsdll64.dll , ghostscript 9.26 and it worked fine. I have added jna 4.1.0 and ghost4j 1.0.1 dependencies in my pom file.

When I run the program, I get following error :

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)

My code looks like this :

    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);
    }
computatma
  • 71
  • 5

2 Answers2

0

So, you aren't using Ghostscript as such, you are using Ghost4j. Your first step should be to initialise Ghostscript itself from the command line; just execute 'gs' and see what happens.

Error -100 just means 'something fatal happened', I'm not familiar with Ghost4j but presumably there is some way to see what happened on stdout and stderr, what messages were sent back on those channels ?

KenS
  • 30,202
  • 3
  • 34
  • 51
0

I was able to solve it by upgrading the version of Ghostscript. It worked when I installed Ghostscript version above 9.

computatma
  • 71
  • 5