你可以在www.lowagie.com/iText找到解决这个问题的控件类.很棒的.enjoy !

解决方案 »

  1.   

    /**
     *  打开 PDF 文件
     */
     
    public class OpenPDF {
    public static void main(String[] args) {
    String cmd = "cmd"; 
    if(System.getProperty("os.name").equals("Windows 98")) {
    System.out.println("Your OS is Win98");
    cmd="command";
    }
    String cmdPDF = "\"C:\\Program Files\\Adobe\\Acrobat 5.0\\Reader\\AcroRd32.exe\"";
    String filePDF = "E:\\电子文档\\JBuiler开发人员指南\\01.pdf";
    String filePDF1 = "E:\\电子文档\\C# 教程\\01.pdf";
    try{
      Runtime.getRuntime().exec(cmd + " /c " + cmdPDF + " " + filePDF1);
      System.out.println(cmd + " /c " + cmdPDF + " " + filePDF1);
    System.out.println("OK, Success!");
    }
    catch(Exception e){System.out.println(" Error of Openning File!");}

    }
    }/// end!
      

  2.   

    请教DainelLee,你用的什么IDE? 我用的是Eclipse,上面这段代码运行不了,请帮忙在你的IDE里调试一下,谢谢!
      

  3.   

    Runtime.getRuntime().exec(cmd + " /c " + cmdPDF + " " + filePDF);
    上面这句代码出错
      

  4.   

    我是用的 jdk1.4.2 编译的,在我的机器(win 2000)能正常运行;^_^ 不好意思,我这边没有安装ide环境你是编译都不通过了?报什么错误啊?
      

  5.   

    谢谢DainelLee,已经调试通过了。 :)
    原因在我刚才改了这个代码:equals("Windows 98")--》equals("Windows 2000"), 在WIN2000下打开程序应该还是用 ”cmd “ 命令,现在明白了,多谢!!! :)
      

  6.   

    不好意思,再问一个问题:关于这个路径:C:\\Program Files\\Adobe\\Acrobat 5.0\\Reader\\AcroRd32.exe\在这段代码中是硬编码,怎么自动获得这个值,因为程序要在不同的机器上运行,甚至Mac机器 :)