Java Mailing List Archive

http://www.junlu.com/

Home » Home (12/2007) » iText »

[iText-questions] read fonts used in a pdf file

selvi

2006-07-19

Replies:

hi,
iam using the below listed code to read the fonts used in a pdf file.
how can i read the font property of a particular page of a pdf file.if possible
send me a sample code.

import java.io.IOException;
import java.util.ArrayList;
import java.util.Iterator;

import com.lowagie.text.pdf.PdfDictionary;
import com.lowagie.text.pdf.PdfName;
import com.lowagie.text.pdf.PdfReader;


public class FindFontName4 {
 
 public static void main(String[] args) {

    try {
      PdfReader reader = new PdfReader("pdfmarkReference.pdf");
     
       PdfDictionary dic2 = (PdfDictionary)reader.getPdfObject(1);
       ArrayList list= reader.getXrefObj();
       Iterator itr = list.iterator();
       while(itr.hasNext()){
         
         try{
           PdfDictionary obj = (PdfDictionary)itr.next();
           if(obj.get(PdfName.BASEFONT)!=null){
           System.out.println("Font Name   : "+obj.get(PdfName.BASEFONT));
           System.out.println("Font Encoding : "+obj.get(PdfName.ENCODING));
           System.out.println("Type     : "+obj.get(PdfName.SUBTYPE));
           System.out.println("Actual Font Name: "+obj.get(PdfName.FONTDESCRIPTOR));
           System.out.println("Actual Type : "+obj.get(PdfName.SUBTYPE));
           }
           
         }catch(Throwable th){
           
         }
       }
     } catch (IOException ioe) {
       System.err.println(ioe.getMessage());
     }
   }
}



Thanks and Regards
K.Selvi



-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
iText-questions mailing list
iText-questions@(protected)
https://lists.sourceforge.net/lists/listinfo/itext-questions
©2008 junlu.com - Jax Systems, LLC, U.S.A.