java pdfbox2 中文乱码,如何从PDFBox 2.0.2中的PDDocument提取字体
生活随笔
收集整理的這篇文章主要介紹了
java pdfbox2 中文乱码,如何从PDFBox 2.0.2中的PDDocument提取字体
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
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
}
}
總結
以上是生活随笔為你收集整理的java pdfbox2 中文乱码,如何从PDFBox 2.0.2中的PDDocument提取字体的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: java hashmap遍历顺序_Jav
- 下一篇: java c 语言之父_Java之父评价