gjq1126-web
private static void pdfToWord() {
    File file = new File("F:/使用Acrobat制作PDF模板说明.pdf");
    PDDocument doc = null;
    try {
        doc = PDDocument.load(file);
    } catch (IOException e) {
        e.printStackTrace();
    }
    int pagenumber=doc.getNumberOfPages();//获取总页数
    FileOutputStream fos = null;
    try {
        fos = new FileOutputStream("F:/使用Acrobat制作PDF模板说明.doc");
    } catch (FileNotFoundException e) {
        e.printStackTrace();
    }
    Writer writer = null;
    try {
        writer = new OutputStreamWriter(fos,"UTF-8");
    } catch (UnsupportedEncodingException e) {
        e.printStackTrace();
    }
    PDFTextStripper stripper = null;
    try {
        stripper = new PDFTextStripper();
    } catch (IOException e) {
        e.printStackTrace();
    }
    stripper.setSortByPosition(true);//排序
    stripper.setStartPage(1);//设置转换的开始页
    stripper.setEndPage(pagenumber);//设置转换的结束页
    try {
        stripper.writeText(doc,writer);
    } catch (IOException e) {
        e.printStackTrace();
    }
    try {
        writer.close();
        doc.close();
    } catch (IOException e) {
        e.printStackTrace();
    }
}

 

分类:

技术点:

相关文章:

  • 2022-12-23
  • 2021-09-29
  • 2022-12-23
  • 2022-12-23
  • 2021-05-08
  • 2022-12-23
  • 2021-11-11
猜你喜欢
  • 2021-11-26
  • 2021-11-07
  • 2021-11-16
  • 2021-06-28
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案