I have seen how to do this in previous versions like below:
But I think the getFonts() method has been removed now. I want to retrieve a map of texts to fonts (Map) in the new version of PDFBox but I have no idea how.
Thanks
Kabeer
解决方案
Do this:
PDDocument doc = PDDocument.load("C:/mydoc3.pdf");
for (int i = 0; i < doc.getNumberOfPages(); ++i)
{
PDPage page = doc.getPage(i);
PDResources res = page.getResources();
for (COSName fontName : res.getFontNames())
{
PDFont font = res.getFont(fontName);
// do stuff with the font
}
}