public void ProcessRequest(HttpContext context)
        {
            //PDFBuilder.HtmlToPdfBuilder builder = new HtmlToPdfBuilder(PageSize.A4);
            //builder.AddPage();
            //builder.ImportStylesheet(context.Server.MapPath("pdfstylesheet.css"));

            int ShowID = Convert.ToInt32(context.Request["showid"]);

            Shows show = new Shows(ShowID);

            ShowDetails sd = new ShowDetails();
            DataTable table = sd.GetShowDetails(ShowID).Tables[0];
            String pdfPath = context.Server.MapPath("PreviewSchedule.pdf");
            Boolean publish = false;
            if (!String.IsNullOrEmpty(context.Request["publish"]) && context.Request["publish"].ToString() == "1") publish = true;

            Document doc = new Document(PageSize.A4, 25, 10, 10, 10);
            Stream  output ;
            if (publish)
            {
                String path = context.Server.MapPath(@"..\schedules\");
                path += DateTime.Today.ToString("yyyy");
                if (!Directory.Exists(path))
                {
                    Directory.CreateDirectory(path);
                }
                path += String.Format("\\{0:yyyyMM}_{1}.pdf", show.ShowDate, show.ShowName);
                output = new FileStream(path, FileMode.Create);
            } else {
                output = new MemoryStream();
            }
            var writer = PdfWriter.GetInstance(doc, output);
            StyleSheet sheet = new StyleSheet();

            doc.Open();

            int clsNo = 0;
            ShowClasses sc = new ShowClasses();
            DataSet callingList = sc.getCallingList(ShowID);
            foreach (DataRow row in callingList.Tables[0].Rows)
            {
                if (clsNo > 0 && clsNo != Convert.ToInt32( row["ClsNo"]))  {
                    doc.NewPage();
                }

                var dayClasses = HTMLWorker.ParseToList(new StringReader(dayHtml), sheet);
                foreach (var htmlElement in dayClasses)
                {
                    doc.Add(htmlElement as IElement);
                }
            };

            doc.NewPage();
            contents = File.ReadAllText(context.Server.MapPath("schedule2RulesNRegs.html"));
            parsedHTML = HTMLWorker.ParseToList(new StringReader(contents), sheet);
            foreach (var htmlElement in parsedHTML)
            {
                doc.Add(htmlElement as IElement);
            }

            doc.Close();

            if (publish)
            {

            }
            else
            {
                context.Response.ClearContent();
                context.Response.ContentType = "application/pdf";
                context.Response.AddHeader("content-disposition", String.Format("inline;filename=PreviewSchedule.pdf"));
                context.Response.BinaryWrite( (output as MemoryStream).ToArray());
            }
        }
        public void ProcessRequest(HttpContext context)
        {
            int ShowID = Convert.ToInt32(context.Request["showid"]);
            int RingID = Convert.ToInt32(context.Request["ringid"]);
            String cmd = context.Request["doc"].ToString();
            Shows show = new Shows(ShowID);

            ShowDetails sd = new ShowDetails();
            DataTable table = sd.GetShowDetails(ShowID).Tables[0];
            String pdfPath = context.Server.MapPath(cmd + ".pdf");
            Boolean publish = false;
            if (!String.IsNullOrEmpty(context.Request["publish"]) && context.Request["publish"].ToString() == "1") publish = true;

            Document doc = new Document(PageSize.A4, -50, -50, 2, 2);
            Stream output;
            if (publish)
            {
                String path = context.Server.MapPath(@"..\schedules\");
                path += DateTime.Today.ToString("yyyy");
                if (!Directory.Exists(path))
                {
                    Directory.CreateDirectory(path);
                }
                path += String.Format("\\{0:yyyyMM}_{1}.pdf", show.ShowDate, show.ShowName);
                output = new FileStream(path, FileMode.Create);
            }
            else
            {
                output = new MemoryStream();
            }
            var writer = PdfWriter.GetInstance(doc, output);
            StyleSheet sheet = new StyleSheet();

            doc.Open();
            Font font = new Font(Font.COURIER, 10, Font.NORMAL, Color.BLACK);
            Font resFont = new Font(Font.COURIER, 9, Font.ITALIC, Color.BLACK);
            Font headerFont = new Font(Font.COURIER, 10, Font.BOLD, Color.BLACK);
            Font headerFont2 = new Font(Font.HELVETICA, 12, Font.BOLD, Color.BLACK);
            Font ClassTitleFont = new Font(Font.HELVETICA, 16, Font.NORMAL, Color.BLACK);
            ShowClasses sc = new ShowClasses();
            Rings currentRing = new Rings(RingID);
            List<ShowClasses> showClasses = ShowClasses.GetAllClassesForShowRing(ShowID, RingID);
            foreach (ShowClasses showClass in showClasses)
            {
                PdfPTable ptable = new PdfPTable(3);
                PdfPCell cell;

                String grades = showClass.Grades;
                if (grades.Length == 1)
                {
                    grades = "Grade " + grades;
                }
                else
                {
                    grades = "Grades " + grades[0] + "-" + grades[grades.Length - 1];
                }
                String tmp = String.Format("Ring No:{5}   Class No:{0} {1} {2} {3} ({4})", showClass.ClassNo, showClass.longHeight, showClass.longCatagory, showClass.LongClassName, grades, currentRing.RingNo);
                cell = new PdfPCell(new Phrase(new Chunk(tmp, ClassTitleFont)));
                cell.Colspan = 3;
                cell.BorderWidth = 0;
                ptable.AddCell(cell);
                cell = new PdfPCell(new Phrase(new Chunk("", ClassTitleFont)));
                cell.Colspan = 3;
                cell.BorderWidth = 0;
                ptable.AddCell(cell);
                ptable.AddCell(cell);
                ptable.AddCell(cell);
                doc.Add(ptable);

                DataSet callingList = sc.getCallingList(ShowID, showClass.ID);
                float[] colWidths = { 35, 50, 200, 200 };
                PdfPTable callingListTbl = new PdfPTable(colWidths);

                cell = new PdfPCell(new Phrase(new Chunk("RO", headerFont)));
                cell.BorderWidth = 0;
                callingListTbl.AddCell(cell);

                cell = new PdfPCell(new Phrase(new Chunk("Ring No", headerFont)));
                cell.BorderWidth = 0;
                callingListTbl.AddCell(cell);

                cell = new PdfPCell(new Phrase(new Chunk("Handler", headerFont)));
                cell.BorderWidth = 0;
                callingListTbl.AddCell(cell);

                cell = new PdfPCell(new Phrase(new Chunk("Dog Name", headerFont)));
                cell.BorderWidth = 0;
                callingListTbl.AddCell(cell);
                int altFlag = 0;
                Color altLine = Color.LIGHT_GRAY;
                foreach (DataRow row in callingList.Tables[0].Rows)
                {
                    Color altColor = Color.WHITE;
                    if (altFlag % 2 == 0 && showClass.EntryType != 5)
                    {
                        altColor = altLine;
                    }

                    cell = new PdfPCell(new Phrase(new Chunk(row["RO"].ToString(), font)));
                    cell.BorderWidth = 0;
                    cell.BorderWidth = 2;
                    cell.BorderColor = Color.RED;
                    cell.BackgroundColor = altColor;
                    cell.HorizontalAlignment = Element.ALIGN_RIGHT;
                    callingListTbl.AddCell(cell);

                    if (showClass.EntryType == 5)
                    {
                        cell = new PdfPCell(new Phrase(new Chunk("Team Name:", headerFont2)));
                        cell.BackgroundColor = altColor;
                        cell.BorderWidth = 1;
                        cell.Colspan = 2;
                        cell.FixedHeight = 30F;
                        callingListTbl.AddCell(cell);

                        cell = new PdfPCell(new Phrase(new Chunk(ShowClasses.expandHeight(row), headerFont2)));
                        cell.BackgroundColor = altColor;
                        cell.BorderWidth = 1;
                        cell.FixedHeight = 30F;
                        cell.HorizontalAlignment = Element.ALIGN_RIGHT;
                        callingListTbl.AddCell(cell);

                        cell = new PdfPCell(new Phrase(new Chunk("", font)));
                        cell.BackgroundColor = altColor;
                        cell.Colspan = 1;
                        cell.BorderWidth = 0;
                        cell.FixedHeight = 30F;
                        callingListTbl.AddCell(cell);
                    }

                    int borderWidth = 0;
                    if (showClass.EntryType == 5) borderWidth = 1;
                    cell = new PdfPCell(new Phrase(new Chunk(row["RingNumber"].ToString(), font)));
                    cell.HorizontalAlignment = Element.ALIGN_RIGHT;
                    cell.BackgroundColor = altColor;
                    cell.BorderWidth = borderWidth;
                    callingListTbl.AddCell(cell);

                    int DefaultHandler = Convert.ToInt32(row["DefaultHandler"]);
                    int AltHandler = Convert.ToInt32(row["AltHandler"]);
                    String handlerName = row["Name"].ToString();
                    User user;
                    if (DefaultHandler > 0) {
                        user = new User(DefaultHandler);
                        handlerName = user.Name;
                    }
                    if (AltHandler > 0)
                    {
                        user = new User(AltHandler);
                        handlerName = user.Name;
                    }

                    cell = new PdfPCell(new Phrase(new Chunk(handlerName, font)));
                    cell.BackgroundColor = altColor;
                    cell.BorderWidth = borderWidth;
                    callingListTbl.AddCell(cell);

                    cell = new PdfPCell(new Phrase(new Chunk(row["KCName"].ToString(), font)));
                    cell.BackgroundColor = altColor;
                    cell.BorderWidth = borderWidth;
                    callingListTbl.AddCell(cell);

                    if (showClass.EntryType == 4 || showClass.EntryType == 5)
                    {
                        int UserID = Convert.ToInt32(row["UserID"]);
                        int DogID = Convert.ToInt32(row["DogID"]);
                        //MultiDog md = new MultiDog(UserID, DogID, showClass.ID);

                        List<MultiDog> otherHandlers = MultiDog.getMultiDog(UserID, DogID, showClass.ID);

                        String reserves = "";
                        int dogCnt = 0;
                        foreach (MultiDog md in otherHandlers)
                        {
                            String res = "";
                            if (dogCnt > 2 && md.Handlername.Length > 0)
                            {
                                if (reserves.Length > 0) reserves += "; ";
                                reserves += String.Format("{0} & {1}", md.Handlername, md.Dogname);
                            }

                            if (dogCnt < 3)
                            {

                                cell = new PdfPCell(new Phrase(new Chunk("", font)));
                                cell.BorderWidth = 0;
                                cell.BackgroundColor = altColor;
                                cell.HorizontalAlignment = Element.ALIGN_RIGHT;
                                callingListTbl.AddCell(cell);

                                cell = new PdfPCell(new Phrase(new Chunk(res, font)));
                                cell.HorizontalAlignment = Element.ALIGN_RIGHT;
                                cell.BackgroundColor = altColor;
                                cell.BorderWidth = 1;
                                callingListTbl.AddCell(cell);

                                cell = new PdfPCell(new Phrase(new Chunk(md.Handlername, font)));
                                cell.BackgroundColor = altColor;
                                cell.BorderWidth = 1;
                                callingListTbl.AddCell(cell);

                                cell = new PdfPCell(new Phrase(new Chunk(md.Dogname, font)));
                                cell.BackgroundColor = altColor;
                                cell.BorderWidth = 1;
                                callingListTbl.AddCell(cell);
                            }
                            dogCnt++;

                        }

                        cell = new PdfPCell(new Phrase(new Chunk("", font)));
                        cell.BackgroundColor = altColor;
                        cell.BorderWidth = 0;
                        cell.FixedHeight = 30F;
                        callingListTbl.AddCell(cell);

                        cell = new PdfPCell(new Phrase(new Chunk("Reserves: " + reserves, resFont)));
                        cell.BackgroundColor = altColor;
                        cell.Colspan = 3;
                        cell.BorderWidth = 1;
                        cell.FixedHeight = 30F;
                        callingListTbl.AddCell(cell);
                    }
                    altFlag++;

                }
                doc.Add(callingListTbl);
                doc.NewPage();
            }

            doc.Close();

            if (publish)
            {

            }
            else
            {
                context.Response.ClearContent();
                context.Response.ContentType = "application/pdf";
                context.Response.AddHeader("content-disposition", String.Format("inline;filename=PreviewSchedule.pdf"));
                context.Response.BinaryWrite((output as MemoryStream).ToArray());
            }
        }
        public void ProcessRequest(HttpContext context)
        {
            int ShowID = Convert.ToInt32(context.Request["showid"]);
            int RingID = Convert.ToInt32(context.Request["ringid"]);
            String cmd = context.Request["doc"].ToString();
            Shows show = new Shows(ShowID);

            ShowDetails sd = new ShowDetails();
            DataTable table = sd.GetShowDetails(ShowID).Tables[0];
            String pdfPath = context.Server.MapPath(cmd + ".pdf");
            Boolean publish = false;
            if (!String.IsNullOrEmpty(context.Request["publish"]) && context.Request["publish"].ToString() == "1") publish = true;

            Document doc = new Document(PageSize.A6, 35, 0, 20, 2);
            Stream output;
            if (publish)
            {
                String path = context.Server.MapPath(@"..\schedules\");
                path += DateTime.Today.ToString("yyyy");
                if (!Directory.Exists(path))
                {
                    Directory.CreateDirectory(path);
                }
                path += String.Format("\\{0:yyyyMM}_{1}.pdf", show.ShowDate, show.ShowName);
                output = new FileStream(path, FileMode.Create);
            }
            else
            {
                output = new MemoryStream();
            }
            var writer = PdfWriter.GetInstance(doc, output);
            StyleSheet sheet = new StyleSheet();

            doc.Open();
            Font font = new Font(Font.HELVETICA, 10, Font.NORMAL, Color.BLACK);
            Font smallFont = new Font(Font.HELVETICA, 8, Font.NORMAL, Color.BLACK);
            Font notSoBigFont = new Font(Font.HELVETICA, 11, Font.BOLD, Color.BLACK);
            Font fontWhite = new Font(Font.HELVETICA, 10, Font.NORMAL, Color.WHITE);
            Font headerFont = new Font(Font.HELVETICA, 12, Font.BOLD, Color.BLACK);
            Font spaceFont = new Font(Font.HELVETICA, 40, Font.BOLD, Color.WHITE);
            Font totalsFont = new Font(Font.HELVETICA, 14, Font.BOLD, Color.BLACK);
            Font bigBoyFont = new Font(Font.HELVETICA, 20, Font.BOLD, Color.BLACK);
            Font bigBoyFont2 = new Font(Font.HELVETICA, 25, Font.BOLD, Color.BLACK);
            PdfPCell blankCell = new PdfPCell(new Phrase(new Chunk("", font)));
            ShowClasses sc = new ShowClasses();
            Rings currentRing = new Rings(RingID);
            List<ShowClasses> showClasses = ShowClasses.GetAllClassesForShowRing(ShowID, RingID);
            String tmp;
            foreach (ShowClasses showClass in showClasses)
            {
                PdfPCell cell;
                DataSet callingList = sc.getCallingList(ShowID, showClass.ID);

                String grades = showClass.Grades;
                if (grades.Length == 1)
                {
                    grades = "Grade " + grades;
                }
                else
                {
                    grades = "Grades " + grades[0] + "-" + grades[grades.Length - 1];
                }
                PdfPTable ptable = new PdfPTable(1);
                tmp = String.Format("Class {0}", showClass.ClassNo);
                cell = new PdfPCell(new Phrase(new Chunk(tmp, bigBoyFont2)));
                cell.BorderWidth = 0;
                cell.Padding = 5;
                cell.HorizontalAlignment = Element.ALIGN_MIDDLE;
                cell.VerticalAlignment = Element.ALIGN_CENTER;
                ptable.AddCell(cell);

                tmp = String.Format("{0} {1} {2} {3}", showClass.longHeight, showClass.longCatagory, showClass.LongClassName, showClass.ClassName);
                cell = new PdfPCell(new Phrase(new Chunk(tmp, totalsFont)));
                cell.BorderWidth = 0;
                cell.Padding = 5;
                cell.HorizontalAlignment = Element.ALIGN_MIDDLE;
                cell.VerticalAlignment = Element.ALIGN_CENTER;
                ptable.AddCell(cell);

                tmp = String.Format("{0}", grades);
                cell = new PdfPCell(new Phrase(new Chunk(tmp, totalsFont)));
                cell.BorderWidth = 0;
                cell.Padding = 5;
                cell.FixedHeight = 100f;
                cell.HorizontalAlignment = Element.ALIGN_MIDDLE;
                cell.VerticalAlignment = Element.ALIGN_CENTER;
                ptable.AddCell(cell);

                tmp = String.Format("Ring {0}", currentRing.RingNo);
                cell = new PdfPCell(new Phrase(new Chunk(tmp, totalsFont)));
                cell.BorderWidth = 0;
                cell.Padding = 5;
                cell.FixedHeight = 30f;
                cell.HorizontalAlignment = Element.ALIGN_MIDDLE;
                ptable.AddCell(cell);

                tmp = String.Format("Ring Order = {0}", showClass.Position + 1);
                cell = new PdfPCell(new Phrase(new Chunk(tmp, totalsFont)));
                cell.BorderWidth = 0;
                cell.Padding = 5;
                cell.FixedHeight = 30f;
                cell.HorizontalAlignment = Element.ALIGN_MIDDLE;
                ptable.AddCell(cell);

                doc.Add(ptable);
                doc.NewPage();

                foreach (DataRow row in callingList.Tables[0].Rows)
                {
                    int Cat = Convert.ToInt32(row["Catagory"]);
                    if (Cat == 0)
                    {
                        PdfPTable tbl = new PdfPTable(1);
                        int dogGrade = Convert.ToInt32(row["Grade"]);
                        if (dogGrade == 99 ) {
                            tmp = "Veteran";
                        } else {
                            tmp = String.Format("Grade {0}", row["Grade"]);
                        }
                        cell = new PdfPCell(new Phrase(new Chunk(tmp, bigBoyFont2)));
                        cell.BackgroundColor = CMYKColor.LIGHT_GRAY;
                        cell.BorderWidth = 2;
                        cell.Padding = 9;
                        cell.PaddingTop = 4;
                        cell.HorizontalAlignment = Element.ALIGN_RIGHT;
                        tbl.AddCell(cell);
                        doc.Add(tbl);

                    }

                    float[] colWidths = { 300, 150 };
                    PdfPTable callingListTbl = new PdfPTable(colWidths);
                    tmp = String.Format("Class {0}: {1} {2} {3} {4}", showClass.ClassNo, showClass.longHeight, showClass.LongClassName, grades, showClass.ClassName);
                    cell = new PdfPCell(new Phrase(new Chunk(tmp, notSoBigFont)));
                    cell.BorderWidth = 2;
                    cell.BorderColorRight = Color.BLACK;
                    cell.BorderColorBottom = Color.BLACK;
                    cell.Padding = 5;
                    cell.PaddingTop = 1;
                    cell.PaddingLeft = 2;
                    cell.FixedHeight = 50f;
                    callingListTbl.AddCell(cell);

                    tmp = String.Format("{0}", row["RO"]);
                    cell = new PdfPCell(new Phrase(new Chunk(tmp, bigBoyFont)));
                    cell.BorderWidth = 2;
                    cell.BorderColorLeft = Color.BLACK;
                    cell.BorderColorBottom = Color.BLACK;
                    cell.HorizontalAlignment = Element.ALIGN_CENTER;
                    cell.Padding = 5;
                    callingListTbl.AddCell(cell);

                    cell = new PdfPCell(new Phrase(new Chunk("Course Time", notSoBigFont)));
                    cell.BorderWidth = 2;
                    cell.Padding = 5;
                    cell.BorderColorRight = Color.BLACK;
                    cell.HorizontalAlignment = Element.ALIGN_RIGHT;
                    callingListTbl.AddCell(cell);

                    cell = new PdfPCell(new Phrase(new Chunk("", notSoBigFont)));
                    cell.BorderWidth = 2;
                    cell.Padding = 5;
                    cell.BorderColorBottom = Color.BLACK;
                    callingListTbl.AddCell(cell);

                    int DefaultHandler = Convert.ToInt32(row["DefaultHandler"]);
                    int AltHandler = Convert.ToInt32(row["AltHandler"]);
                    String handlerName = row["Name"].ToString();
                    User user;
                    if (DefaultHandler > 0)
                    {
                        user = new User(DefaultHandler);
                        handlerName = user.Name;
                    }
                    if (AltHandler > 0)
                    {
                        user = new User(AltHandler);
                        handlerName = user.Name;
                    }

                    if (showClass.EntryType == 5)
                    {
                        cell = new PdfPCell(new Phrase(new Chunk(String.Format("{0}", handlerName), smallFont)));
                        cell.BorderWidth = 0;
                        cell.Colspan = 1;
                        cell.HorizontalAlignment = Element.ALIGN_LEFT;
                        callingListTbl.AddCell(cell);

                        cell = new PdfPCell(new Phrase(new Chunk(String.Format("{0,-10}", row["KCName"]), smallFont)));
                        cell.Colspan = 1;
                        cell.HorizontalAlignment = Element.ALIGN_RIGHT;
                        cell.BorderWidth = 0;
                    }
                    else
                    {
                        cell = new PdfPCell(new Phrase(new Chunk(String.Format("{0}", handlerName), notSoBigFont)));
                        cell.BorderWidth = 0;
                        cell.Colspan = 2;
                        callingListTbl.AddCell(cell);

                        cell = new PdfPCell(new Phrase(new Chunk(String.Format("{0,-10} {1}", row["RingNumber"], row["KCName"]), notSoBigFont)));
                        cell.BorderWidth = 0;
                    }
                    if (showClass.EntryType < 4)
                    {
                        cell.FixedHeight = 170f;
                    }
                    cell.Colspan = 2;
                    callingListTbl.AddCell(cell);

                    if (showClass.EntryType == 4 || showClass.EntryType == 5 )
                    {
                        int UserID = Convert.ToInt32(row["UserID"]);
                        int DogID = Convert.ToInt32(row["DogID"]);
                        List<MultiDog> otherHandlers = MultiDog.getMultiDog(UserID, DogID, showClass.ID);

                        int dogCnt = 0;
                        foreach (MultiDog md in otherHandlers)
                        {

                            if (dogCnt < 3)
                            {
                                //html += String.Format("<div class='dogInClass'><div style='width:8px;height:10px;' class='dogIcon'></div>[{1}] {0}</div>", md.Dogname, dogRow["RO"]);
                                if (showClass.EntryType == 4)
                                {
                                    cell = new PdfPCell(new Phrase(new Chunk(String.Format("{0}", md.Handlername), notSoBigFont)));
                                    cell.BorderWidth = 0;
                                    cell.Colspan = 2;
                                    callingListTbl.AddCell(cell);
                                    cell = new PdfPCell(new Phrase(new Chunk(String.Format("{0,-10} {1}", "", md.Dogname), notSoBigFont)));
                                    cell.BorderWidth = 0;
                                    cell.FixedHeight = 160f;
                                    cell.Colspan = 2;
                                }
                                else
                                {
                                    cell = new PdfPCell(new Phrase(new Chunk(String.Format("{0}", md.Handlername), smallFont)));
                                    cell.BorderWidth = 0;
                                    cell.Colspan = 1;
                                    cell.HorizontalAlignment = Element.ALIGN_LEFT;
                                    callingListTbl.AddCell(cell);
                                    cell = new PdfPCell(new Phrase(new Chunk(String.Format("{0,-10} {1}", "", md.Dogname), smallFont)));
                                    cell.HorizontalAlignment = Element.ALIGN_RIGHT;
                                    cell.BorderWidth = 0;
                                    cell.Colspan = 1;

                                }
                                callingListTbl.AddCell(cell);
                            }
                            dogCnt++;
                        }

                        if (showClass.EntryType == 5)
                        {
                            cell = new PdfPCell(new Phrase(new Chunk("", smallFont)));
                            cell.BorderWidth = 0;
                            cell.FixedHeight = 140f;
                            cell.Colspan = 2;
                            callingListTbl.AddCell(cell);

                        }
                    }

                    cell = new PdfPCell(new Phrase(new Chunk("Time", notSoBigFont)));
                    cell.BorderWidth = 2;
                    cell.BorderColorRight = Color.BLACK;
                    cell.BorderColorBottom = Color.BLACK;
                    cell.Padding = 5;
                    cell.HorizontalAlignment = Element.ALIGN_CENTER;
                    callingListTbl.AddCell(cell);
                    callingListTbl.AddCell(blankCell);

                    cell = new PdfPCell(new Phrase(new Chunk("Course Faults", notSoBigFont)));
                    cell.BorderWidth = 2;
                    cell.BorderColorRight = Color.BLACK;
                    cell.BorderColorBottom = Color.BLACK;
                    cell.Padding = 5;
                    cell.HorizontalAlignment = Element.ALIGN_CENTER;
                    callingListTbl.AddCell(cell);
                    callingListTbl.AddCell(blankCell);

                    cell = new PdfPCell(new Phrase(new Chunk("Time Faults", notSoBigFont)));
                    cell.BorderWidth = 2;
                    cell.BorderColorRight = Color.BLACK;
                    cell.BorderColorBottom = Color.BLACK;
                    cell.Padding = 5;
                    cell.HorizontalAlignment = Element.ALIGN_CENTER;
                    callingListTbl.AddCell(cell);
                    callingListTbl.AddCell(blankCell);

                    cell = new PdfPCell(new Phrase(new Chunk("Totals Faults", notSoBigFont)));
                    cell.BorderWidth = 2;
                    cell.BorderColorRight = Color.BLACK;
                    cell.BorderColorBottom = Color.BLACK;
                    cell.Padding = 5;
                    cell.HorizontalAlignment = Element.ALIGN_CENTER;
                    callingListTbl.AddCell(cell);
                    callingListTbl.AddCell(blankCell);
                    doc.Add(callingListTbl);
                    doc.NewPage();

                }
            }

            doc.Close();

            if (publish)
            {

            }
            else
            {
                context.Response.ClearContent();
                context.Response.ContentType = "application/pdf";
                context.Response.AddHeader("content-disposition", String.Format("inline;filename=PreviewSchedule.pdf"));
                context.Response.BinaryWrite((output as MemoryStream).ToArray());
            }
        }