
import com.lowagie.text.*;
import com.lowagie.text.pdf.*;
import com.lowagie.text.rtf.*;
import com.lowagie.text.html.*;

import java.sql.*;
import java.util.ArrayList;
import java.io.*;

public class testForBug
{

	public static void main(String []args)
	{
		Document doc = new Document(PageSize.A4.rotate(), 0.5f,0.5f,0.5f,0.5f);
		Font titleFont = FontFactory.getFont("Courier", 12, Font.BOLD);
		Font regularFont = FontFactory.getFont("Courier", 10);
		String []data = {"Scott","Hayes","Hello this is my name","Marvin","Evans","Hello, will see you later","Joe","Blow","See you later"};
		try
		{
			PdfWriter pw = PdfWriter.getInstance(doc, new FileOutputStream("testPDF.pdf"));
			
			doc.open();
	
			Paragraph titlePara = new Paragraph(new Phrase("TestPDF\n ",titleFont ));
			titlePara.setAlignment(Paragraph.ALIGN_CENTER);
			doc.add(titlePara);
			for(int j=0;j<2;j++){  //for each page.
				int 		NumColumns 		 	 = 3;
				Table 		datatable  		 	 = new Table(NumColumns);  
		    	int 		headerwidths[] 	 	 = {30,30,40};
			
				datatable.setWidths(headerwidths);
		    	datatable.setWidth(90);
				datatable.setPadding(2.5f);
				datatable.setBorder(Table.NO_BORDER);
				datatable.setCellsFitPage(false);
					
					
				Cell cell = new Cell(new Phrase("Firstname",regularFont));
				cell.setNoWrap(true);
				cell.setBorder(Cell.BOTTOM);
				datatable.addCell(cell);
				
				cell = new Cell(new Phrase("Lastname",regularFont));
				cell.setNoWrap(true);
				cell.setBorder(Cell.BOTTOM);
				datatable.addCell(cell);
				cell = new Cell(new Phrase("Message",regularFont));
				cell.setNoWrap(true);
				cell.setBorder(Cell.BOTTOM);
				datatable.addCell(cell);
				
				datatable.endHeaders();			
			
				for(int i=0;i<9;i++){
					cell = new Cell(new Phrase(data[i],regularFont));
					cell.setNoWrap(true);
					cell.setBorder(Cell.NO_BORDER);
					if (j == 1 && (i < 3 || i > 5))cell.setGrayFill(0.9f);
					datatable.addCell(cell);
				}
				doc.add(datatable);
				//doc.newPage();
			}
			
			doc.close();
		}catch(Exception e)
		{
			e.printStackTrace(System.out);
		}
	}
}