MainClass.java Source code

Java tutorial

Introduction

Here is the source code for MainClass.java

Source

import java.awt.Point;
import java.io.FileOutputStream;

import com.lowagie.text.Document;
import com.lowagie.text.Element;
import com.lowagie.text.Paragraph;
import com.lowagie.text.Table;
import com.lowagie.text.pdf.PdfContentByte;
import com.lowagie.text.pdf.PdfPTable;
import com.lowagie.text.pdf.PdfWriter;

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

        Table table = new Table(2, 2);
        table.setAlignment(Element.ALIGN_LEFT);
        table.setAutoFillEmptyCells(true);
        table.addCell("0.0");
        table.addColumns(2);
        float[] f = { 2f, 1f, 1f, 1f };
        table.setWidths(f);
        table.addCell("2.2", new Point(2, 2));
        table.deleteColumn(2);
        table.setConvert2pdfptable(true);
        document.add(table);
        document.close();
    }
}