How to extract font styles of text contents using pdfbox?

11,688

This is not the right way to extract font. To read font one has to iterate through pdf pages and extract font as below:

PDDocument  doc = PDDocument.load("C:/mydoc3.pdf");
List<PDPage> pages = doc.getDocumentCatalog().getAllPages();
for(PDPage page:pages){
    Map<String,PDFont> pageFonts=page.getResources().getFonts();
}
Share:
11,688
Master Stroke
Author by

Master Stroke

Objective C, iOS , Android, iPhone,C#,Sqlite,Sqlserver 2008

Updated on July 21, 2022

Comments

  • Master Stroke
    Master Stroke almost 2 years

    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.

  • lazydevpro
    lazydevpro over 2 years
    How can I set fetched font for my android textview?