@RequestMapping(value = "/order/upload", method = RequestMethod.POST)
public String index(@RequestParam(value = "multipartFile") MultipartFile multipartFile) throws IOException {
//multipartFile为multipartFile文件类型,将文件转化为文件流被PDDocument加载
PDDocument document = PDDocument.load(multipartFile.getInputStream());
document.getClass();
//使用PDFTextStripper 工具
PDFTextStripper tStripper = new PDFTextStripper();
//设置文本排序,有规则输出
tStripper.setSortByPosition(true);
//获取所有文字信息
String info = tStripper.getText(document);
return info;
}
Springboot实现识别pdf信息
最新推荐文章于 2024-03-13 16:37:12 发布