import java.io.File;
import java.io.FileOutputStream;

import com.lowagie.text.Cell;
import com.lowagie.text.Document;
import com.lowagie.text.Table;
import com.lowagie.text.pdf.PdfWriter;
import com.lowagie.tools.Executable;

public class RowSpanProblem {

	public static void main(String [] arg) throws Exception {
		test();
	}
	
	public static void test() throws Exception {
		File output = File.createTempFile("rowSpanProblem","pdf");
		Document document = new Document();
		PdfWriter.getInstance(document, new FileOutputStream(output));
		document.open();
		Table t = new Table(8);
		
		Cell c = new Cell("Time");
		c.setRowspan(6);
		t.addCell(c);
		
		c = new Cell(" . ");
		c.setRowspan(2);
		t.addCell(c);
		
		c = new Cell(" . ");
		c.setRowspan(6);
		t.addCell(c);
		
		t.addCell(c);
		
		c = new Cell("course");
		c.setRowspan(4);
		t.addCell(c);
		
		t.addCell(c);
		
		c = new Cell(" . ");
		c.setRowspan(6);
		t.addCell(c);
		
		t.addCell(c);
		
		// row 2
		c = new Cell(" . ");
		//t.addCell(c);
		
		c = new Cell("mondayCourse");
		c.setRowspan(4);
		t.addCell(c);
		
		c = new Cell(" . ");
		c.setRowspan(2);
		t.addCell(c);
		
		t.addCell(c);


		c = new Cell(" . ");
		t.addCell(c);
		t.addCell(c);
		t.addCell(c);
		t.addCell(c);
		t.addCell(c);
		t.addCell(c);
		t.addCell(c);
		t.addCell(c);

		System.out.println("end("+t.getNextColumn()+","+t.getNextRow()+")");
		
		document.add(t);
		document.close();
		Executable.openDocument(output);
		System.out.println(output.getCanonicalPath());
	}
}
