我已经在以前的版本中看到了如何做到这一点,如下所示:
How to extract font styles of text contents using pdfbox?
但是我认为getFonts()方法现在已经被移除了。我想在新版本的PDFBox中检索一个从文本到字体(Map<String, PDFont>)的映射,但我不知道如何检索。
谢谢
卡比尔
发布于 2016-07-14 17:07:42
对于PDFBox 2.x,您要链接的答案的修订代码是
PDDocument doc = PDDocument.load("C:/mydoc3.pdf");
for(PDPage page : doc.getPages()){
// get the names of the fonts in the resources dictionary
Iterable<COSName> iterable = page.getResources().getFontNames();
// to get the font for each item call
// page.getResources().getFont(COSName name);
}https://stackoverflow.com/questions/38369096
复制相似问题