java - 如何使用 PDFBox 获取输入字段的标题
问题描述
我想从 pdf 文件中获取所有字段并获取所有必需的数据:字段类型、id、默认值、标题、弹出文本等。除了标题,我几乎可以获得所有数据。如果我做对了,我可以在 pdf 内容章节中找到正确的字段标题,但是如何将它们与字段匹配?我使用此代码来获取字段信息。
try(PDDocument document = Loader.loadPDF(pdfFileBinary)) {
PDAcroForm acroForm = document.getDocumentCatalog().getAcroForm();
if (acroForm == null) {
return Collections.emptyList();
}
return acroForm.getFields()
.stream()
.flatMap(unfoldFunction)
.map(PdfFieldImpl::new)
.collect(Collectors.toList());
} catch (IOException e) {
throw new RuntimeException("Can't parse pdf document");
}
如果有人知道解决方案但使用不同的库,那也很棒。对不起,如果这对你来说太愚蠢了:)
解决方案
推荐阅读
- mysql - 左加入“选择”
- java - 使用流进行从数组到列表的空安全转换
- python - ValueError:形状(259,2)和(1,33)未对齐:2(dim 1)!= 1(dim 0)
- python - 找不到从终端运行的 Python 模块
- ruby-on-rails - 以一种方式加入,但不是另一种
- visual-studio - 无法使用 MSBuild 的 UnZip 任务解压缩包含文件夹的 zip 文件
- cypress - 比较 datetime 函数 cypress
- python - scikit learn Pipeline 是否将 StandardScaler 应用于 y?
- android - Android 架构蓝图 [todo-mvp-dagger] @ActivityScoped, @FragmentScoped
- typescript - 如何在没有框架的情况下使用 Typescript?