I am creating java process using ProcessBuilder for ghostscript to convert pdf into tiff as below
process = new ProcessBuilder("D:\\ghost-script\\gs\\gs9.02\\bin\\gswin64.exe","-q", "-dNOPAUSE", "-dBATCH", "-dMaxStripSize=8192", "-sDEVICE=tiffg4", "-r300x300", "-dDITHERPPI=200", "-sOutputFile=D:\\ghost-script\\example\\output.tif", "D:\\ghost-script\\example\\input2.pdf", "-c", "quit").start();
Now I have two problems.
- This process open console popup which I don't need as it has to run on server. What parameter I can set to disable that console popup.
- Input file can of any be of any size. How can I know when the process has completed so that I can destroy it. I don't want Thread.sleep(time-to_sleep). Because for different size of input file it is different and if I take upper limit, it will hamper performance for lower size files badly. So what can I do to destroy the process as soon as it get completed?
Any help is much appreciated.