public void pageBreak() {
   if (breakHandlingParent != null) {
     if (sectionParent.getHeightLimit() >= 0.0f) {
       // fill remaining space on page break
       fillTable(sectionParent.getHeightLimit());
     }
     // flush
     flushTable();
     breakHandlingParent.columnBreak();
   } else {
     // more column breaks than available columns
     // but we cannot break to a new page
     // don't really know what to do in such situation
     // anyway it is logical error made by document creator
     setColIdx(colIdx + 1);
   }
 }
  private void flushTable() {
    sectionParent.addElement(getElement());

    // initialize layout table
    layoutTable = cloneAndClearTable(layoutTable, true);

    // initialize simulated text
    texts = new ArrayList<ColumnText>();
    setColIdx(0);
  }
 public void addElement(Element element) {
   if (element instanceof SectionPdfPTable) {
     // section is a specific container
     // it is not added to direct parent container
     // but to section parent container which may be
     // StylableDocument or StylableTableCell or StylableHeaderFooter table cell
     sectionParent.addElement(element);
   } else {
     // ordinary element
     texts.get(colIdx).addElement(element);
     simulateText();
   }
 }
 private void simulateText() {
   float maxHeight = sectionParent.getHeightLimit();
   List<ColumnText> splittedTexts = fillTable(maxHeight);
   if (splittedTexts == null) {
     // fits in current column on page
     if (balanceText) {
       float minHeight = 0f;
       if (maxHeight < 0.0f) {
         maxHeight = layoutTable.calculateHeights();
       }
       float currHeight = 0.0f;
       while (Math.abs(maxHeight - minHeight) > 0.1f) {
         currHeight = (minHeight + maxHeight) / 2;
         if (fillTable(currHeight) == null) {
           // try to lower height
           maxHeight = currHeight;
         } else {
           // have to raise height
           minHeight = currHeight;
         }
       }
       // populate table with last height
       if (currHeight != maxHeight) {
         fillTable(maxHeight);
       }
     } else {
       if (maxHeight >= 0.0f) {
         // fill minimum space only
         fillTable(-1.0f);
       }
     }
   } else {
     // overflow
     if (breakHandlingParent != null) {
       flushTable();
       breakHandlingParent.columnBreak();
       //
       texts = splittedTexts;
       colIdx = texts.size() - 1;
       simulateText();
     }
   }
 }
 private void setWidthIfNecessary() {
   if (layoutTable.getTotalWidth() != sectionParent.getWidthLimit()) {
     layoutTable.setTotalWidth(sectionParent.getWidthLimit());
   }
 }