【发布时间】:2014-03-08 01:11:15
【问题描述】:
我编写了一个创建 PDF 文档的程序。创建后,PDF 必须打开才能打印。
我有以下代码,但它仅在我从 netbeans 启动时才有效。谁能给我一些指点?
public void openPDF()
{
try {
System.out.println("Opening PDF");
File file = new File(pdfPath+pdfName);
String absolutePDFpath = file.getAbsolutePath().replace(""+(char)92,""+(char)92+(char)9);
System.out.println("Path = "+absolutePDFpath);
Runtime.getRuntime().exec("rundll32 url.dll,FileProtocolHandler " + absolutePDFpath);
}
catch (IOException ex)
{
JOptionPane.showMessageDialog(null, "Er is een fout opgetreden tijdens het openen van het PDF"
+ " document\nFoutcode: 0xFF05");
Logger.getLogger(PrintJob.class.getName()).log(Level.SEVERE, null, ex);
}
【问题讨论】:
-
你用什么其他方式来启动程序?在这种情况下你会遇到什么错误?
-
请提供有关从外部 netbeans 运行时看到的异常的详细信息。
标签: java pdf file-io runtime exec