title: iTextSharp - Table in absolute coordinates
body: <p>I am trying to use this <a href="http://what-when-how.com/itext-5/adding-a-table-at-an-absolute-position-itext-5/" rel="nofollow noreferrer">tutorial</a> to position table in absolute coordinates using iTextSharp. Here is my code: </p>
  
  <pre><code>using System;
  using System.Collections.Generic;
  using System.Linq;
  using System.Text;
  using iTextSharp;
  using iTextSharp.text;
  using iTextSharp.text.pdf;
  using System.IO;
  
  namespace iTextSharpQuestion
  {
      class Program
  {
      static void Main(string[] args)
      {
          System.IO.FileStream fs = new FileStream(@"C:\Temp\" + "First PDF document.pdf", FileMode.Create);
          Document document = new Document(PageSize.LETTER, 25, 25, 30, 30);
          document.SetPageSize(iTextSharp.text.PageSize.LETTER.Rotate());
          PdfWriter writer = PdfWriter.GetInstance(document, fs);
          document.Open();
          PdfContentByte cb = writer.DirectContent;
          BaseFont f_cn = BaseFont.CreateFont(BaseFont.TIMES_ROMAN, BaseFont.CP1252, false);
          cb.BeginText();
          cb.SetFontAndSize(f_cn, 9);
  
          PdfPTable ObjTestTable = TestTable();
          ObjTestTable.WriteSelectedRows(0, -1, 200, 50, cb);
  
          cb.EndText();
          // Close the document
          document.Close();
          // Close the writer instance
          writer.Close();
          // Always close open filehandles explicity
          fs.Close();
      }
      public static PdfPTable TestTable()
      {
          PdfPTable table = new PdfPTable(3);
          PdfPCell cell = new PdfPCell(new Phrase("Header spanning 3 columns"));
          cell.Colspan = 3;
          cell.HorizontalAlignment = 1; //0=Left, 1=Centre, 2=Right
          table.AddCell(cell);
          table.AddCell("Col 1 Row 1");
          table.AddCell("Col 2 Row 1");
          table.AddCell("Col 3 Row 1");
          table.AddCell("Col 1 Row 2");
          table.AddCell("Col 2 Row 2");
          table.AddCell("Col 3 Row 2");
          return table;
  
      }
  
  }
  }
  </code></pre>
  
  <p>The following line generates error message</p>
  
  <pre><code>ObjTestTable.WriteSelectedRows(0, -1, 200, 50, cb);
  </code></pre>
  
  <p>The error message is </p>
  
  <blockquote>
    <p>The table width must be greater than zero.</p>
  </blockquote>
  
  <p>Tutorial suggests to use width zero. What am I doing wrong?</p>