/** @see com.itextpdf.text.xml.simpleparser.SimpleXMLDocHandler#endDocument() */
 public void endDocument() {
   try {
     // flush the stack
     for (int k = 0; k < stack.size(); ++k) document.add(stack.elementAt(k));
     // add current paragraph
     if (currentParagraph != null) document.add(currentParagraph);
     currentParagraph = null;
   } catch (Exception e) {
     throw new ExceptionConverter(e);
   }
 }
 /**
  * Processes the Table.
  *
  * @throws DocumentException
  * @since 5.0.6
  */
 public void processTable() throws DocumentException {
   TableWrapper table = (TableWrapper) stack.pop();
   PdfPTable tb = table.createTable();
   tb.setSplitRows(true);
   if (stack.empty()) document.add(tb);
   else ((TextElementArray) stack.peek()).add(tb);
 }
 /**
  * Fetches the List from the Stack and adds it to the TextElementArray on top of the Stack, or to
  * the Document if the Stack is empty.
  *
  * @throws DocumentException
  * @since 5.0.6
  */
 public void processList() throws DocumentException {
   if (stack.empty()) return;
   Element obj = stack.pop();
   if (!(obj instanceof com.itextpdf.text.List)) {
     stack.push(obj);
     return;
   }
   if (stack.empty()) document.add(obj);
   else ((TextElementArray) stack.peek()).add(obj);
 }
 /**
  * Flushes the current paragraph, indicating that we're starting a new block. If the stack is
  * empty, the paragraph is added to the document. Otherwise the Paragraph is added to the stack.
  *
  * @since 5.0.6
  */
 public void carriageReturn() throws DocumentException {
   if (currentParagraph == null) return;
   if (stack.empty()) document.add(currentParagraph);
   else {
     Element obj = stack.pop();
     if (obj instanceof TextElementArray) {
       TextElementArray current = (TextElementArray) obj;
       current.add(currentParagraph);
     }
     stack.push(obj);
   }
   currentParagraph = null;
 }
 /**
  * Looks for the List object on the Stack, and adds the ListItem to the List.
  *
  * @throws DocumentException
  * @since 5.0.6
  */
 public void processListItem() throws DocumentException {
   if (stack.empty()) return;
   Element obj = stack.pop();
   if (!(obj instanceof ListItem)) {
     stack.push(obj);
     return;
   }
   if (stack.empty()) {
     document.add(obj);
     return;
   }
   ListItem item = (ListItem) obj;
   Element list = stack.pop();
   if (!(list instanceof com.itextpdf.text.List)) {
     stack.push(list);
     return;
   }
   ((com.itextpdf.text.List) list).add(item);
   item.adjustListSymbolFont();
   stack.push(list);
 }