import java.io.FileOutputStream;
import java.io.IOException;import com.itextpdf.text.Document;
import com.itextpdf.text.DocumentException;
import com.itextpdf.text.Phrase;
import com.itextpdf.text.Rectangle;
import com.itextpdf.text.pdf.PdfContentByte;
import com.itextpdf.text.pdf.PdfPCell;
import com.itextpdf.text.pdf.PdfPCellEvent;
import com.itextpdf.text.pdf.PdfPTable;
import com.itextpdf.text.pdf.PdfWriter;class CustomCell implements PdfPCellEvent {
/*public void cellLayout(PdfPCell cell, Rectangle rect,
PdfContentByte[] canvas) {
PdfContentByte cb = canvas[PdfPTable.LINECANVAS];
cb.setLineDash(new float[] { 3.0f, 3.0f }, 0);
cb.stroke();
}*/
public void cellLayout(PdfPCell cell, Rectangle position,
            PdfContentByte[] canvases) {    // TODO Auto-generated method stub
    PdfContentByte cb = canvases[PdfPTable.LINECANVAS];
    cb.saveState();
    //cb.setLineCap(PdfContentByte.LINE_CAP_ROUND);
    //cb.setLineDash(0, 1, 1);
    cb.setLineWidth(0.5f);
    cb.setLineDash(new float[] { 5.0f, 5.0f }, 0);
    cb.moveTo(position.getLeft(), position.getBottom());
    cb.lineTo(position.getRight(), position.getBottom());
    cb.stroke();
    cb.restoreState();}
}public class DottedLineCell2 { /**
 * @param args
 */
public static void main(String[] args)  throws IOException, DocumentException {
// TODO 自動生成されたメソッド・スタブ
Document document = new Document();
PdfWriter.getInstance(document, new FileOutputStream("output.pdf"));
document.open();
CustomCell border = new CustomCell();
PdfPTable table = new PdfPTable(6);
PdfPCell cell;
for (int i = 1; i <= 6; i++) {
cell = new PdfPCell(new Phrase("test")); cell.setBorder(Rectangle.NO_BORDER); cell.setCellEvent(border);
table.addCell(cell);
}
document.add(table);
document.close();
}}