Created
March 10, 2017 15:03
-
-
Save sandroqz/3d932b1190de7b375885d98fe7468551 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package br.com.exemplo; | |
import org.ghost4j.Ghostscript; | |
import org.ghost4j.GhostscriptException; | |
public class ComprimePdf { | |
public static void main(String[] args) { | |
Ghostscript gs = Ghostscript.getInstance(); | |
String[] gsArgs = new String[9]; | |
// gsArgs[0] = "-I/usr/local/Cellar/ghostscript/9.20/bin/"; | |
gsArgs[0] = "-gs"; | |
gsArgs[1] = "-sDEVICE=pdfwrite"; | |
gsArgs[2] = "-dCompatibilityLevel=1.4"; | |
gsArgs[3] = "-dPDFSETTINGS=/screen"; // ebook ou screen | |
gsArgs[4] = "-dNOPAUSE"; | |
gsArgs[5] = "-dQUIET"; | |
gsArgs[6] = "-dBATCH"; | |
gsArgs[7] = "-sOutputFile=/Users/sandro/output.pdf"; | |
gsArgs[8] = "/Users/sandro/digitalizar0025.pdf"; | |
try { | |
gs.initialize(gsArgs); | |
gs.exit(); | |
} catch (GhostscriptException e) { | |
// TODO Auto-generated catch block | |
System.out.println("Erro: " + e.getMessage()); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment