从各个博客 CV 出来的,不好意思

pom

	<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
<version>4.1.2</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.poi/poi-ooxml -->
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>4.1.2</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.poi/poi-ooxml-schemas -->
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml-schemas</artifactId>
<version>4.1.2</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>ooxml-schemas</artifactId>
<version>1.4</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.poi/poi-scratchpad -->
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-scratchpad</artifactId>
<version>4.1.2</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-compress</artifactId>
<version>1.21</version>
</dependency>
<!--读取pdf信息-->
<dependency>
<groupId>org.apache.pdfbox</groupId>
<artifactId>pdfbox</artifactId>
<version>2.0.12</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.pdfbox/fontbox -->
<dependency>
<groupId>org.apache.pdfbox</groupId>
<artifactId>fontbox</artifactId>
<version>2.0.12</version>
</dependency>

按段落 读取 docx

    @SneakyThrows
private void readDocx(MultipartFile file) {
InputStream inputStream = file.getInputStream();
XWPFDocument document = new XWPFDocument(inputStream);
// 读取段落
List<XWPFParagraph> paragraphs = document.getParagraphs();
List<WordFileInfo> infos = new ArrayList<>();
for (XWPFParagraph paragraph : paragraphs) {
String text = paragraph.getParagraphText();
} }

按段落 读取 doc

    @SneakyThrows
private void readDoc(MultipartFile file) {
InputStream inputStream = file.getInputStream();
HWPFDocument document = new HWPFDocument(inputStream);
Range range = document.getRange();
List<WordFileInfo> infos = new ArrayList<>();
for (int i = 0; i < range.numParagraphs(); i++) {
Paragraph paragraph = range.getParagraph(i);
String text = paragraph.text();
}
}

读取 pdf

/**
* 读取 pdf 文件内容
*
* @param inputStream
* @return
*/
private String readPDF(InputStream inputStream) {
StringBuilder content = new StringBuilder();
try {
RandomAccessBuffer buffer = new RandomAccessBuffer(inputStream);
PDFParser pdfParser = new PDFParser(buffer);
pdfParser.parse();
PDDocument document = pdfParser.getPDDocument();
// 获取页码
int pages = document.getNumberOfPages();
PDFTextStripper stripper = new PDFTextStripper();
// 设置按顺序输出
stripper.setSortByPosition(true);
stripper.setStartPage(1);
stripper.setEndPage(pages);
content.append(stripper.getText(document));
} catch (Exception e) {
e.printStackTrace();
}
return content.toString(); }

Java poi 读取 word 、 pdf的更多相关文章

  1. Java POI 读取word文件

    Apache POI是Apache软件基金会的开放源码函式库,POI提供API给Java程序对Microsoft Office格式档案读和写的功能. 1.读取word 2003及word 2007需要 ...

  2. java使用poi读取word(简单,简约,直观)

    java使用poi读取word(简单,简约,直观) 说明 其实poi的官网上面都是有接口和样例的,只是都是英文 例如网址:http://poi.apache.org/spreadsheet/quick ...

  3. POI 读取word (word 2003 和 word 2007) (转)

    最近在给客户做系统的时候,用户提出需求,要能够导入 word 文件,现在 microsoft word 有好几个版本 97.2003.2007的,这三个版本存储数据的格式上都有相当大的差别,而现在 9 ...

  4. POI 读取word (word 2003 和 word 2007)(转,好用)

    POI 读取word (word 2003 和 word 2007)(转,好用) 转做的操作: 将作者文中失效的链接的正确链接放在失效链接的下面. 最近在给客户做系统的时候,用户提出需求,要能够导入 ...

  5. Java poi读取,写入Excel2003

    Java poi读取,写入Excel2003 相关阅读:poi读写Excel2007:http://www.cnblogs.com/gavinYang/p/3576741.htmljxl读写excel ...

  6. Java poi读取,写入Excel2007

    Java poi读取,写入Excel2007 相关阅读:poi读写Excel2003:http://www.cnblogs.com/gavinYang/p/3576739.htmljxl读写excel ...

  7. java 使用poi读取word文档存入数据库

    使用的poi jar包需要自己下载 读取的word文档中含有多个图片,所以分为两个部分,一个部分读取各个表格中内容,一个是将所有图片截取出来: /** * 遍历段落内容 * docxReadPath ...

  8. Java POI 解析word文档

    实现步骤: 1.poi实现word转html 2.模型化解析html 3.html转Map数组 Map数组(数组的操作处理不做说明) 1.导jar包. 2.代码实现 package com.web.o ...

  9. poi读取word的内容

    pache POI是Apache软件基金会的开放源码函式库,POI提供API给Java程序对Microsoft Office格式档案读和写的功能. 1.读取word 2003及word 2007需要的 ...

  10. java中读取word文档里的内容

    package com.cn.peitest.excel.word; import java.io.FileInputStream; import java.io.FileOutputStream; ...

随机推荐

  1. 涨见识了!脱离vue项目竟然也可以使用响应式API

    前言 vue3的响应式API大家应该都特别熟悉,比如ref.watch.watchEffect等.平时大家都是在vue-cli或者vite创建的vue项目里面使用的这些响应式API,今天欧阳给大家带来 ...

  2. 【DataBase】MySQL 13 分组查询

    视频参考自:P59 - P68 https://www.bilibili.com/video/BV1xW411u7ax 分组查询 GROUP BY -- group by 子句 -- 要注意!grou ...

  3. 【SpringBoot】10 Web开发 Part1 静态资源

    使用SpringBoot创建工程的方式: 1.在IDEA集成的Boot官网选项中点选可能需要的框架环境即可 2.SpringBoot已经设置好了这些场景,只需要配置文件中指定少量配置就可以运行起来 3 ...

  4. NVIDIA人形机器人AI套件:NVIDIA Isaac Manipulator 和 NVIDIA Isaac Perceptor

    IsaacManipulator 为机械臂提供了卓越的灵活性和模块化AI功能,并提供了一系列强大的基础模型和GPU加速库.它提供了高达80倍的路径规划加速,零样本感知提高了效率和吞吐量,使开发者能够实 ...

  5. Jax的加速层的伪代码/中间层代码的生成和查看

    地址: https://jax.readthedocs.io/en/latest/notebooks/thinking_in_jax.html#jit-mechanics-tracing-and-st ...

  6. 所在单位近日购入Dell poweredge T640型号服务器,安装Ubuntu18.04.5 server操作系统,服务器万兆网卡,网线连接到千兆交换机上,不能识别网卡——解决方案

    如题目所说: 所在单位近日购入Dell poweredge T640型号服务器,安装Ubuntu18.04.5 server操作系统,服务器万兆网卡,网线连接到千兆交换机上,不能识别网卡. 服务器  ...

  7. 新购的HP品牌台式机(暗影精灵,自带windows10系统,显卡为RTX2080,CPU为i7-10700)安装双系统(Ubuntu系统),不识别显卡,不识别硬盘 —— 解决方案

    事件起因是实验室的师弟要弄深度学习,实验室为其新购一台台式机(HP台式机,暗影精灵,自带windows10系统,显卡为RTX2080,CPU为i7-10700),师弟是满心喜悦的在windows系统上 ...

  8. 如何将python的pip源设置为阿里云

    为python的pip源设置为阿里云,pip源的设置操作: pip config set global.index-url https://mirrors.cloud.aliyuncs.com/pyp ...

  9. mpi4py和cupy的联合应用(anaconda环境):GPU-aware MPI + Python GPU arrays

    Demo代码: from mpi4py import MPI import cupy as cp comm = MPI.COMM_WORLD size = comm.Get_size() rank = ...

  10. 宝塔环境安装redis

    参考: http://www.bt.cn/Help/Find?id=92 步骤: 1. 在安装宝塔时 PHP 版本选 7.0: 2. 安装 redis:wget http://125.88.182.1 ...