code: protected DocWriter createWriter(final MBasicTable table, final Document document,
  			final OutputStream out) throws DocumentException {
  		final PdfWriter writer = PdfWriter.getInstance(document, out);
  		// writer.setViewerPreferences(PdfWriter.PageLayoutTwoColumnLeft);
  
  		// title
  		if (table.getName() != null) {
  			final HeaderFooter header = new HeaderFooter(new Phrase(table.getName()), false);
  			header.setAlignment(Element.ALIGN_LEFT);
  			header.setBorder(Rectangle.NO_BORDER);
  			document.setHeader(header);
  			document.addTitle(table.getName());
  		}
  
  		// simple page numbers : x
  		// HeaderFooter footer = new HeaderFooter(new Phrase(), true);
  		// footer.setAlignment(Element.ALIGN_RIGHT);
  		// footer.setBorder(Rectangle.TOP);
  		// document.setFooter(footer);
  
  		// add the event handler for advanced page numbers : x/y
  		writer.setPageEvent(new AdvancedPageNumberEvents());
  
  		return writer;
  	}
docs: We create a writer that listens to the document and directs a PDF-stream to out
  
  @param table
  MBasicTable
  @param document
  Document
  @param out
  OutputStream
  @return DocWriter
  @throws DocumentException
  e