Rupanu Ranjaneswar wrote:
> hello,
> I want to know how can I get the list of font names used in a word document.
> Please suggest me a way if anyone knows it.
>  Thanks and regards
> ranjaneswar

Hello Ranjaneswar,

a first attempt resulted in this code:

---8<-----------------
import java.io.FileInputStream;
import java.io.IOException;

import org.apache.poi.hwpf.HWPFDocument;
import org.apache.poi.hwpf.model.Ffn;
import org.apache.poi.hwpf.model.FontTable;

public class TestFont {
  public static void main(String[] args) {
    try {
      HWPFDocument doc = new HWPFDocument(
        new FileInputStream("fontlist.doc"));
      FontTable ft = doc.getFontTable();
      Ffn [] f = ft.getFontNames();
      for (int i=0; i<f.length; i++) {
        Ffn ffn = f[i];
        System.out.println(ffn.getMainFontName());
      }
    } catch (IOException e) {
      e.printStackTrace();
    }
  }
}
---8<-----------------

It worked with a simple test document containing a couple of lines with
different fonts.

Best wishes,
Rainer
-- 
Rainer SCHWARZE (Mr.)

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to