PDFBox 2.0:如何在此处检测粗体文本

PDFBox 2.0: how to detect bold text here

我知道有很多方法可以在 PDF 中加粗文本,最常见的是 TextPosition.getFont() 中的 "bold" 关键字。但是,在附件中我无法找到为什么粗体文本实际上是粗体:

pdf 的捕获

视觉上看起来每个字符都重复了两次,但是,我在 TextStripper.writeString 中看不到 还有什么可以使文字加粗吗? 提前致谢!

您的文件使用 text rendering mode 2(填充和描边,又名 RenderingMode.FILL_STROKE)。这模拟粗体。您可以通过在扩展剥离器的 class 中调用 getGraphicsState().getTextState().getRenderingMode() 来获取当前模式。