我正在尝试使用 RedMon 将打印机的 .PS 文件重定向到我的 Java 代码。
RedMon 端口配置:
重定向到程序:C:\Program Files\Java\jre1.8.0_111\bin\java.exe
参数:-jar c:\dist\JavaApplication5.jar --stdin
和Java代码:
public class JavaAplication5 {
public static void main(String[] args) throws FileNotFoundException {
BasicConfigurator.configure(); //log4j
System.setProperty("jna.library.path", "C:\\dist\\"); //fix path to gsdll
FileInputStream file = new FileInputStream(args[0]);
Ghostscript gs = Ghostscript.getInstance();
String[] gsArgs = new String[10];
gsArgs[0] = "-ps2pdf";
gsArgs[1] = "-dNOPAUSE";
gsArgs[2] = "-dBATCH";
gsArgs[3] = "-dSAFER";
gsArgs[4] = "-sDEVICE=pdfwrite";
gsArgs[5] = "-sOutputFile=output.pdf";
gsArgs[6] = "-c";
gsArgs[7] = ".setpdfwrite";
gsArgs[8] = "-f";
gsArgs[9] = String.format(" %s ", file) ;
try {
gs.initialize(gsArgs);
gs.exit();
} catch (GhostscriptException e) {
JOptionPane.showMessageDialog(null, "ERROR: " + e.getMessage());
}
}
}
我怎样才能让它工作?