Reputation: 690
I want to compress a scanned PDF useing ghost4j. While doing that I get following Error First, I am doing some tests if the Files and Directories are available, then starting Initializing Ghost4J:
Output:
input.pdf is available
C:/gs/gs9.15/lib is available C:/gs/gs9.15/bin is available DIRS: -I"C:/gs/gs9.15/lib;C:/gs/gs9.15/bin" 2014-10-07 14:47:11 [ERROR] (Ghostscript):72 - GPL Ghostscript 8.61: Can't find initialization file gs_init.ps. ERROR: Cannot initialize Ghostscript interpreter. Error code is -100 org.ghost4j.GhostscriptException: Cannot initialize Ghostscript interpreter. Error code is -100 at org.ghost4j.Ghostscript.initialize(Ghostscript.java:365)
at kompressPDF.KompressPDF.main(KompressPDF.java:61)
Code:
File inputFile = new File("input.pdf");
Ghostscript gs = Ghostscript.getInstance();
gs.getRevision();
String[] gsArgs = new String[7];
gsArgs[0] = "dirs";
gsArgs[1] = "-dPDFSETTINGS=/screen";
gsArgs[2] = "-sDEVICE=pdfwrite";
gsArgs[3] = "-dNOPAUSE";
gsArgs[4] = "-dBATCH";
gsArgs[5] = "-sOutputFile=output.pdf";
gsArgs[6] = inputFile.getAbsolutePath();
try {
gs.initialize(gsArgs);
gs.exit();
} catch (GhostscriptException e) {
// TODO Auto-generated catch block
e.printStackTrace();
System.out.println("ERROR: " + e.getMessage());
}
Where Variable "dirs" = -I"C:/gs/gs9.15/lib;C:/gs/gs9.15/bin" Does anybody know, how I can solve the problem?
Thanks GGK
Upvotes: 2
Views: 1651