Is there any way to have a code where it can be used to open PDF file in Java application but do not side to any platform. I mean using batch file in Windows could do that. Can it be any other way to have platform independent code to open PDF on fly.
+5
A:
I'd try Desktop.open(File)
, which:
Launches the associated application to open the file.
So this code should do the trick:
if (Desktop.isSupported()) {
try {
File myFile = new File("/path/to/file.pdf");
Desktop.getDesktop().open(myFile);
} catch (IOException ex) {
// no application registered for PDFs
}
}
Michael Myers
2010-03-30 16:49:18
A:
You can use Runtime to execute and script and there are also several Java PDF viewers out there (ie Icepdf, JPedal, PDFRenderer).
mark stephens
2010-03-31 08:23:14
Thanks for the suggestions...;)
Mr CooL
2010-03-31 12:46:09