java - File opens before printing? -
hi m using program print files bt opens file before printing?i want remove that.any suggestions?
import java.awt.desktop; import java.io.file; import java.io.ioexception; public class printfile { public static void filetoprint(file fis) { try { desktop desktop = null; if (desktop.isdesktopsupported()) { desktop = desktop.getdesktop(); } desktop.print(fis); system.out.print("printing document"); } catch (ioexception ioe) { ioe.printstacktrace(); } } }
the desktop api in awt uses native functionality of system (in case windows.) jvm invoking shellexecute/shellexecuteex on file "print" command. way windows handles command search registry file type's print command, , run that. file types, result in application handles opening, , executing print command automatically.
in short, don't think you'll able use desktop api without having applications open. need printing (which, of course, difficult.)
Comments
Post a Comment