2012-03-20 81 views
0

我正在使用PDFBox來提取pdf文件的內容。我能夠提取文本,但我也需要獲取文本的字體屬性。所以任何人都可以幫助我提取字體屬性?使用pdfbox獲取pdf文本的字體屬性

我在正確提取某些字符時也有問題。 PDFBox給'?'當它無法識別人物時。所以也給了我一些建議,如果能夠解決這個問題..提前

謝謝..

回答

0
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(); 
     } 
    } 


}