How to extract font styles of text contents using pdfbox?

前端 未结 3 669
青春惊慌失措
青春惊慌失措 2020-12-10 18:03

I am using pdfbox library to extract text contents from pdf file.I would able to extract all the text,but couldn\'t find the method to extract font styles.

3条回答
  •  旧时难觅i
    2020-12-10 18:47

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

提交回复
热议问题