【问题标题】:Get font properties of pdf text with pdfbox使用 pdfbox 获取 pdf 文本的字体属性
【发布时间】:2012-03-20 09:16:39
【问题描述】:

我正在使用 PDFBox 来提取 pdf 文件的内容。我能够提取文本,但我还需要获取文本的字体属性。那么谁能帮我提取字体属性?

而且我在正确提取某些字符时也遇到了问题。 PDFBox 给出“?”当它无法识别字符时。所以如果可能的话,也给我一些解决问题的建议..

提前谢谢..

【问题讨论】:

    标签: java fonts properties pdfbox


    【解决方案1】:
    import org.apache.pdfbox.pdmodel.PDDocument;  
    import org.apache.pdfbox.util.PDFTextStripper;  
    public class pdf2box {  
        public static void main(String args[])
        {
            try
            {
        PDDocument pddDocument=PDDocument.load("table2.pdf");
        PDFTextStripper textStripper=new PDFTextStripper();
        System.out.println(textStripper.getText(pddDocument));
        textStripper.getFonts();
    
    
    
        pddDocument.close();
            }
            catch(Exception ex)
            {
            ex.printStackTrace();
            }
        }
    
    
    }
    

    【讨论】:

      猜你喜欢
      • 2014-10-13
      • 2014-12-21
      • 1970-01-01
      • 2021-01-05
      • 1970-01-01
      • 2013-11-15
      • 1970-01-01
      • 2021-12-22
      • 2015-11-19
      相关资源
      最近更新 更多