MainClass.java Source code

Java tutorial

Introduction

Here is the source code for MainClass.java

Source

import java.io.FileOutputStream;

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

public class MainClass {
    public static void main(String[] args) throws Exception {
        Document document = new Document();
        PdfWriter.getInstance(document, new FileOutputStream("2.pdf"));

        document.open();
        BaseFont bf = BaseFont.createFont("esl_gothic_shavian.otf", "Cp1252", BaseFont.EMBEDDED);
        System.err.println(bf.getClass().getName());
        Font font = new Font(bf, 12);
        document.add(new Paragraph("abced"));
        document.add(new Paragraph("this is a test", font));
        document.close();
    }
}