我试图从PDF中给定的两个坐标指定的特定矩形区域中提取数据。是否可以在PDF中执行此操作,或者我是否必须将其转换为图像并使用OCR?如果有,PDFBox或iText是否包含通过光学字符识别来分析图像的方法?谢谢!
发布于 2017-12-26 10:58:03
如果区域是文本。使用pdfbox,
PDDocument document = PDDocument.load(new File("target.pdf"));
PDFTextStripperByArea stripper = new PDFTextStripperByArea();
stripper.setSortByPosition(true);
Rectangle rect = new Rectangle(35, 375, 340, 204);
stripper.addRegion("class1", rect);
stripper.extractRegions(document.getPage(1));
System.out.println(stripper.getTextForRegion("class1")
https://stackoverflow.com/questions/47972904
复制相似问题