title: iTextSharp PDF embedded barcodes using tables. Unable to format to one page
body: <p>I am creating a page of barcodes to fit onto onlinelabels.com  <a href="http://www.onlinelabels.com/Products/OL2050LP.htm#LabelSpecs" rel="nofollow noreferrer">(ol2050LP)</a>. </p>
  
  <p>I have successfully produced barcodes and also have them nicely displaying in the table as I would expect. </p>
  
  <p>The problem I am having is that it seems there is some phantom header and footer on the page pushing the last 2 rows of barcodes of the page.</p>
  
  <p>My results:</p>
  
  <p><a href="https://i.stack.imgur.com/wWMNT.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/wWMNT.png" alt="enter image description here"></a></p>
  
  <p>Below is my method:</p>
  
  <pre><code> public void CreatePDF(List&lt;BarcodeLib.Barcode.DataMatrix&gt; listOfBarcodes)
          {
              if (listOfBarcodes.Count &gt;= 1)
              {
                  Document document = new Document();
                  PdfPTable table = new PdfPTable(13);
                  document.SetPageSize(PageSize.A4);
                  document.SetMargins(0.25f, 0.25f, 0.2505f, 0.2505f);
  
                  try
                  {
                      PdfWriter.GetInstance(document, new FileStream(@"test.pdf", FileMode.CreateNew));
                      document.Open();
                      foreach (BarcodeLib.Barcode.DataMatrix image in listOfBarcodes)
                      {
                          iTextSharp.text.Image dmatrix = iTextSharp.text.Image.GetInstance(image.drawBarcodeAsBytes(), true);
                          dmatrix.SetDpi(300, 300);
                          dmatrix.ScaleAbsolute(37, 37);
                          table.AddCell(dmatrix);
                      }
                      document.Add(table);
                      document.Close();
                  }
                  catch (DocumentException de)
                  {
                      Console.Error.WriteLine(de.Message);
                  }
                  catch (IOException ioe)
                  {
                      Console.Error.WriteLine(ioe.Message);
                  }
              }
          }
  </code></pre>