

import java.io.FileOutputStream;

import com.lowagie.text.*;
import com.lowagie.text.pdf.PdfWriter;
import com.lowagie.text.pdf.PdfContentByte;
import com.lowagie.text.pdf.PdfPCell;
import com.lowagie.text.pdf.PdfPTable;

public class TablesMiddle
{

  public TablesMiddle()
  {
  }
  public static void main(String[] args)
  {
    TablesMiddle t = new TablesMiddle();
    t.create();
  }

  private void create()
  {
      com.lowagie.text.Document document = new com.lowagie.text.Document();

      try
      {
	PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("VerticalAlignment.pdf"));
	PdfContentByte cb = writer.getDirectContent();

	// step 3: we open the document
	document.open();

        table(cb);

	document.close();
      }
      catch (Exception e)
      {
	e.printStackTrace();
      }

  }

  private void table(PdfContentByte cb)
  {
    PdfPTable table;
    PdfPCell c;

    table = new PdfPTable(1);

    c = new PdfPCell(new Phrase("SUPPLIER"));
    c.setHorizontalAlignment(Element.ALIGN_CENTER);
    c.setVerticalAlignment(Element.ALIGN_MIDDLE);
    table.addCell(c);

    c = new PdfPCell(new Phrase("SUPPLIER"));
    c.setHorizontalAlignment(Element.ALIGN_CENTER);
    c.setVerticalAlignment(Element.ALIGN_MIDDLE);
    c.setFixedHeight(30);
    table.addCell(c);
    table.setTotalWidth(80);
    table.writeSelectedRows(0, -1, 100, 300, cb);
  }

}