title: iText java - Split table vertically and horizontally
body: <p>I am an iText java developer. I have been working with large tables and now I am stuck in splitting a table vertically. </p>
  
  <p>In page 119 of iText in Action, honourable Bruno Lowagie (I got so much respect for this guy) explains how to split a large table so that columns appear in two distinct pages.</p>
  
  <p>I followed his example and it works fine when a document has few rows. </p>
  
  <p>In my case I have 100 rows, maning that the document needs to split 100 rows in several pages while at the same time split columns vertically. I ran my code as follows but only the first 34 rows are displayed. </p>
  
  <p>Can someone kindly explain what could be wrong with this code:</p>
  
  <pre><code>//create a PDFPTable with 24 columns
  PdfPTable tbl = new PdfPTable(new float{1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1});
  //loop through 100 rows
  for (int i = 0; i &lt; 100; i++) {
      //insert 24 table cells
  }
  
  tbl.setTotalWidth(1500);//set table width
  float top = document.top() - document.topMargin() - 30;
  PdfContentByte canvas = writer.getDirectContent();
  tbl.writeSelectedRows(0, 12, 0, -1, document.leftMargin(), top, canvas);
  document.newPage();
  // draw the remaining two columns on the next page
  tbl.writeSelectedRows(12, -1, 0, -1, 5, top, canvas);
  </code></pre>