Я использую службу преобразования PostScript в PDF для моего приложения в Linux Server.У меня установлена версия 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);
}