Please, I want to know which fonts extracted from pdf is embedded or not, how can I do this using PDFBox?
Asked
Active
Viewed 5,993 times
2 Answers
3
In PDFBox2, you would get the fonts and their embedded-status like this:
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 ...
}
I found no way, though, to find out which characters of the font are embedded, and which are not.

Balin
- 81
- 3
-
You merely inspect the immediate resources of the pages, not the resources of xobjects shown on the pages. In particular n-up documents often have all interesting content in xobjects. – mkl Oct 04 '16 at 11:57
2
May be you find an answere here
or
To get all fonts, you have to iterate through pdf pages and extract font as below:
PDDocument doc = PDDocument.load("C:/test.pdf");
List<PDPage> pages = doc.getDocumentCatalog().getAllPages();
for(PDPage page:pages){
Map<String,PDFont> pageFonts=page.getResources().getFonts();
}
-
Thanks for reply but this is not the answer i need, I want to check if the font is empedded or not embedded in pdf?? – Mohammed Mostafa Aug 28 '13 at 14:45