2

请,我想知道从 pdf 中提取的字体是否嵌入,我该如何使用 PDFBox 来做到这一点?

4

2 回答 2

1

也许你在这里找到答案

或者

要获取所有字体,您必须遍历 pdf 页面并提取字体,如下所示:

PDDocument  doc = PDDocument.load("C:/test.pdf");
List<PDPage> pages = doc.getDocumentCatalog().getAllPages();
for(PDPage page:pages){
    Map<String,PDFont> pageFonts=page.getResources().getFonts();
}
于 2013-08-28T13:58:02.053 回答
1

在 PDFBox2 中,您将获得字体及其嵌入状态,如下所示:

PDResources resources = page.getResources();
Iterator<COSName> ite = resources.getFontNames();
while (ite.hasNext()) {
    COSName name = ite.next();
    PDFont font = resources.getFont(name);
    boolean isEmbedded = font.isEmbedded();
    // ... do something with the results ...
}

但是,我没有办法找出字体的哪些字符是嵌入的,哪些不是。

于 2016-10-04T10:45:28.547 回答