文本分析器
小于 1 分钟高级功能分析器
说明
可解析文本相关信息,包含内容如下:
- pageIndex(页面索引)
- pageWidth(页面宽度)
- pageHeight(页面高度)
- fontName(字体名称)
- fontSize(字体大小)
- textContent(文本内容)
- textBeginPosition(文本起始位置坐标)
- textEndPosition(文本结束位置坐标)
- textTotalWidth(文本总宽度)
示例(文档)
try (
// 加载文档
Document document = PdfHandler.getDocumentHandler().load("E:\\PDF\\pdfbox\\analyzer\\hello-world.pdf");
// 创建文档分析器
DocumentAnalyzer analyzer = new DocumentAnalyzer(document);
) {
// 解析文本信息(文档)
Set<TextInfo> infoSet = analyzer.analyzeText();
// 输出文本信息
infoSet.forEach(System.out::println);
}


示例(页面)
try (
// 加载文档
Document document = PdfHandler.getDocumentHandler().load("E:\\PDF\\pdfbox\\analyzer\\hello-world.pdf");
// 创建文档分析器
DocumentAnalyzer analyzer = new DocumentAnalyzer(document);
) {
// 解析文本信息(指定页面)
Set<TextInfo> infoSet = analyzer.analyzeText(0);
// 输出文本信息
infoSet.forEach(System.out::println);
}

