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