using System;
using System.Collections.Generic;
using System.Text;

namespace CreateTable
{
    class Program
    {
        static void Main(string[] args)
        {
            // Setup the parameters
           string output = "CreateTable.pdf";
           string PageSize = "A4";

           // Create the library
           PDFlibAX.PDFlibrary PDFlib = new PDFlibAX.PDFlibrary();

           // Set the page size of the new document
           PDFlib.SetPageSize(PageSize);

           // Create the table and specify the number of rows and columns
           int tableID = PDFlib.CreateTable(2, 4);

           // Specify color and width of borders   
           PDFlib.SetTableBorderColor(tableID, 0, 0.0, 0.8, 0);
           PDFlib.SetTableBorderWidth(tableID, 0, 0.1);

           // Specify table row height and table column width
           PDFlib.SetTableRowHeight(tableID, 1, 2, 30);
           PDFlib.SetTableColumnWidth(tableID, 1, 4, 100);

           // Specify a background color for the column headers
           PDFlib.SetTableCellBackgroundColor(tableID, 1, 1, 1, 4, 1, 0.0, 0.0);
           PDFlib.SetTableCellAlignment(tableID, 1, 1, 2, 4, 4);

           // Setup the column headers for the first row
           PDFlib.SetTableCellContent(tableID, 1, 1, "<b>Dog</b>");
           PDFlib.SetTableCellContent(tableID, 1, 2, "<b>Cat</b>");
           PDFlib.SetTableCellContent(tableID, 1, 3, "<b>Chicken</b>");
           PDFlib.SetTableCellContent(tableID, 1, 4, "<b>Cow</b>");

           // Insert the content for the second row
           PDFlib.SetTableCellContent(tableID, 2, 1, "bone<br>meat");
           PDFlib.SetTableCellContent(tableID, 2, 2, "rice<br><b>fish</b>");
           PDFlib.SetTableCellContent(tableID, 2, 3, "<b>worm</b><br>wheat");
           PDFlib.SetTableCellContent(tableID, 2, 4, "grass<br>oat");


           // Draw the table onto the document
           double s = PDFlib.DrawTableRows(tableID, 80, 700, 400, 1, 0);

           // Save the document to disk
           PDFlib.SaveToFile(output);

           // Check to see if the table could be created
           if (s == 0)
           {
               Console.WriteLine("Could not create table!");
           }
        }
    }
}
