软航Office文档控件 就有这个功能 具体的你可以看看 二次开发文档。

解决方案 »

  1.   


    很多office插件都有这个功能
      

  2.   

    office插件我也用过。   最好的方法是用  adobe acrobat 来转换。  楼主可以搜搜
      

  3.   

    用openoffice ,之前写过services ,就是用这个来弄点额,你自己找找,还行
      

  4.   

    问题已解决,小弟在此谢过了。小弟用jaboc实现了word转换为pdf的功能
      

  5.   

    要用到tm-extractors.jar,bcproy-jdk16-145.jar,iText.jar,iTextAsian.jar从word中读取内容public static String getWord(String path) {
    System.out.println("==============================");
    System.out.println("Extract word start:===========");
    File file = new File(path);
    String returnString = "";
    InputStream is;
    try {
    is = new FileInputStream(file);
    WordExtractor extractor = new WordExtractor();
    returnString = extractor.extractText(is);
    System.out.println("Extract word end:===========");
    } catch (FileNotFoundException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
    } catch (IOException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
    } catch (Exception e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
    }
    return returnString;
    }
    将内容写入到pdf中public static void write(String content, String filePath) throws IOException{
    System.out.println("==============================");
    System.out.println("Write to pdf start:===========");
    final int margin = 10;
    // create the file
    File file = new File(filePath);
    if(!file.exists()){
    Document doc = null;
    FileOutputStream fos = null;
    PdfWriter pdfWriter = null;
    try {
    BaseFont bFont = BaseFont.createFont("STSongStd-Light", "UniGB-UCS2-H", false);
    Font font = new Font(bFont);
    font.setSize(8);
    doc = new Document(PageSize.A4, margin, margin, margin, margin);
    fos = new FileOutputStream(file);
    pdfWriter = PdfWriter.getInstance(doc, fos);

    doc.open();
    doc.addTitle(filePath.replace("D:\\", ""));
    doc.add(new Paragraph(content, font));

    System.out.println("Write to pdf end:===========");
    } catch (FileNotFoundException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
    } catch (DocumentException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
    } finally{
    if(doc != null){
    doc.close();
    }

    if(pdfWriter != null){
    pdfWriter.close();
    }

    if(fos != null){
    fos.close();
    }

    }
    }
    }
    希望对你有用哈,我也是以前做测试的时候写的了……
      

  6.   

    jacob不好,只能处理简单的文档,要是里面有表格,图片什么的,转换会出问题,所以推荐jcom.jar,小鬼子,怎么说,做的东西是比国内的好些,不得不学习
      

  7.   


    这个也不兼容吧,而且要在win下面,还要安装注册adobe
      

  8.   

    6楼请问,这个PdfWriter是什么类?
      

  9.   

    有没有这种小的demo啊,灰常感谢的哦