FontFactoryFontsPDF.java Source code

Java tutorial

Introduction

Here is the source code for FontFactoryFontsPDF.java

Source

import java.io.FileOutputStream;

import com.lowagie.text.Document;
import com.lowagie.text.Font;
import com.lowagie.text.FontFactory;
import com.lowagie.text.Paragraph;
import com.lowagie.text.pdf.PdfWriter;

public class FontFactoryFontsPDF {

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

            document.add(new Paragraph("FontFactory.getFont(FontFactory.COURIER, Font.DEFAULTSIZE, Font.NORMAL)",
                    FontFactory.getFont(FontFactory.COURIER, Font.DEFAULTSIZE, Font.NORMAL)));
            document.add(new Paragraph("FontFactory.getFont(FontFactory.COURIER, Font.DEFAULTSIZE, Font.ITALIC)",
                    FontFactory.getFont(FontFactory.COURIER, Font.DEFAULTSIZE, Font.ITALIC)));
            document.add(new Paragraph("FontFactory.getFont(FontFactory.COURIER, Font.DEFAULTSIZE, Font.BOLD)",
                    FontFactory.getFont(FontFactory.COURIER, Font.DEFAULTSIZE, Font.BOLD)));
            document.add(new Paragraph(
                    "FontFactory.getFont(FontFactory.COURIER, Font.DEFAULTSIZE, Font.BOLD | Font.ITALIC)",
                    FontFactory.getFont(FontFactory.COURIER, Font.DEFAULTSIZE, Font.BOLD | Font.ITALIC)));
            document.add(new Paragraph("FontFactory.getFont(FontFactory.HELVETICA, Font.DEFAULTSIZE, Font.NORMAL)",
                    FontFactory.getFont(FontFactory.HELVETICA, Font.DEFAULTSIZE, Font.NORMAL)));
            document.add(new Paragraph("FontFactory.getFont(FontFactory.HELVETICA, Font.DEFAULTSIZE, Font.ITALIC)",
                    FontFactory.getFont(FontFactory.HELVETICA, Font.DEFAULTSIZE, Font.ITALIC)));
            document.add(new Paragraph("FontFactory.getFont(FontFactory.HELVETICA, Font.DEFAULTSIZE, Font.BOLD)",
                    FontFactory.getFont(FontFactory.HELVETICA, Font.DEFAULTSIZE, Font.BOLD)));
            document.add(
                    new Paragraph("FontFactory.getFont(FontFactory.HELVETICA, Font.DEFAULTSIZE, Font.BOLDITALIC)",
                            FontFactory.getFont(FontFactory.HELVETICA, Font.DEFAULTSIZE, Font.BOLDITALIC)));
            document.add(
                    new Paragraph("FontFactory.getFont(FontFactory.TIMES_ROMAN, Font.DEFAULTSIZE, Font.NORMAL)",
                            FontFactory.getFont(FontFactory.TIMES_ROMAN, Font.DEFAULTSIZE, Font.NORMAL)));
            document.add(
                    new Paragraph("FontFactory.getFont(FontFactory.TIMES_ROMAN, Font.DEFAULTSIZE, Font.ITALIC)",
                            FontFactory.getFont(FontFactory.TIMES_ROMAN, Font.DEFAULTSIZE, Font.ITALIC)));
            document.add(new Paragraph("FontFactory.getFont(FontFactory.TIMES_ROMAN, Font.DEFAULTSIZE, Font.BOLD)",
                    FontFactory.getFont(FontFactory.TIMES_ROMAN, Font.DEFAULTSIZE, Font.BOLD)));
            document.add(
                    new Paragraph("FontFactory.getFont(FontFactory.TIMES_ROMAN, Font.DEFAULTSIZE, Font.BOLDITALIC)",
                            FontFactory.getFont(FontFactory.TIMES_ROMAN, Font.DEFAULTSIZE, Font.BOLDITALIC)));
            document.add(new Paragraph("FontFactory.getFont(FontFactory.SYMBOL, Font.DEFAULTSIZE, Font.NORMAL)",
                    FontFactory.getFont(FontFactory.SYMBOL, Font.DEFAULTSIZE, Font.NORMAL)));
            document.add(
                    new Paragraph("FontFactory.getFont(FontFactory.ZAPFDINGBATS, Font.DEFAULTSIZE, Font.NORMAL)",
                            FontFactory.getFont(FontFactory.ZAPFDINGBATS, Font.DEFAULTSIZE, Font.NORMAL)));
        } catch (Exception e) {
            System.err.println(e.getMessage());
        }
        document.close();
    }
}