How To Print PDF File with Java Do you want to print *.pdf file directly with Java? you should run this code : Desktop desktop = De...
![]() |
How To Print PDF File with Java |
you should run this code :
Desktop desktop = Desktop.getDesktop(); try { desktop.print(new File("myfile.pdf")); } catch (IOException e) { JOptionPane.showMessageDialog(null, e); }
you change "myfile.pdf" with your file name and path for example : desktop.print(new File("D://xxx.pdf")); or define with a variable for example : String filepath="D://xxx.pdf"
Desktop desktop = Desktop.getDesktop(); try { desktop.print(new File(filepath)); } catch (IOException e) { JOptionPane.showMessageDialog(null, e); }