Using Font Factory : FontFactory « PDF RTF « Java






Using Font Factory

Using Font Factory
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.Iterator;
import java.util.TreeSet;

import com.lowagie.text.Document;
import com.lowagie.text.DocumentException;
import com.lowagie.text.FontFactory;
import com.lowagie.text.Paragraph;
import com.lowagie.text.pdf.BaseFont;
import com.lowagie.text.pdf.PdfWriter;

public class UsingFontFactoryPDF {
  public static void main(String[] args) {
    Document document = new Document();
    try {
      PdfWriter.getInstance(document,  new FileOutputStream("UsingFontFactoryPDF.pdf"));
      document.open();

      Paragraph p = new Paragraph("Font Families", FontFactory.getFont(FontFactory.HELVETICA, 16f));
      document.add(p);
      FontFactory.registerDirectories();
      TreeSet families = new TreeSet(FontFactory.getRegisteredFamilies());

      for (Iterator i = families.iterator(); i.hasNext(); ) {
        p = new Paragraph((String) i.next());
        document.add(p);
      }
    } catch (Exception e) {
      System.err.println(e.getMessage());
    }

    document.close();
  }
}
           
       








itext.zip( 1,748 k)

Related examples in the same category

1.Using Font Factory to Get all Registered Families
2.Using FontFactory to construct fontsUsing FontFactory to construct fonts
3.Font Factory Styles: BoldFont Factory Styles: Bold
4.Font Factory Styles ExampleFont Factory Styles Example
5.Using Registered FontUsing Registered Font