public class RptSUGatePass : IKRPageFooter

    {

        #region Declaration

        PdfWriter _oPdfWriter;

        int _maxColumn = 5;

        Document _document;

        Font _fontStyle;

        PdfPTable _pdfTable = new PdfPTable(5);

        PdfPCell _pdfCell;

        MemoryStream _memoryStream = new MemoryStream();

        SUGatePass _oSUGatePass = new SUGatePass();

        #endregion


        public byte[] Report(SUGatePass oSUGatePass)

        {

            GlobalReport.BottomPx = 20;


            _oSUGatePass = oSUGatePass;

            #region

            _document = new Document(PageSize.A4, 10f, 10f, 20f, 30f);

            _pdfTable.WidthPercentage = 100;

            _pdfTable.HorizontalAlignment = Element.ALIGN_LEFT;

            _fontStyle = FontFactory.GetFont("Tahoma", 8f, 1);

            _oPdfWriter = PdfWriter.GetInstance(_document, _memoryStream);

            _oPdfWriter.PageEvent = new IKRPageFooter();

            _document.Open();


            float[] sizes = new float[_maxColumn];

            for (var i = 0; i < _maxColumn; i++)

            {

                if (i == 0) sizes[i] = 30;

                else if (i == 4) sizes[i] = 100;

                else sizes[i] = 50;

            }

            _pdfTable.SetWidths(sizes);

            #endregion


            this.ReportHeader();

            this.EmptyRow(1);


            if (_oSUGatePass.IsConfirm == 0)

            {

                this.NotConfirmed();

            }

            else

            {

                this.ParentInfo();

                this.EmptyRow(1);

                this.ReportBody();

                this.EmptyRow(1);

                this.QtyInWord();

                this.EmptyRow(1);

                this.SetRemark();

                this.EmptyRow(1);

                this.Signature();

            }


            _pdfTable.HeaderRows = 5;

            _document.Add(_pdfTable);


            this.OnEndPage(_oPdfWriter, _document);


            _document.Close();


            return _memoryStream.ToArray();

        }

        private void NotConfirmed()

        {

            _fontStyle = FontFactory.GetFont("Tahoma", 18f, 1);

            _pdfCell = new PdfPCell(new Phrase("You have to Confirm this Gatepass before Print", _fontStyle));

            _pdfCell.Colspan = _maxColumn;

            _pdfCell.HorizontalAlignment = Element.ALIGN_CENTER;

            _pdfCell.Border = 0;

            _pdfCell.ExtraParagraphSpace = 0;

            _pdfTable.AddCell(_pdfCell);

            _pdfTable.CompleteRow();

        }

        private void ReportHeader()

        {

            _pdfCell = new PdfPCell(this.AddLogo());

            _pdfCell.Colspan = 1;

            _pdfCell.Border = 0;

            _pdfTable.AddCell(_pdfCell);


            _pdfCell = new PdfPCell(this.SetPageTitle());

            _pdfCell.Colspan = _maxColumn - 1;

            _pdfCell.Border = 0;

            _pdfTable.AddCell(_pdfCell);

            _pdfTable.CompleteRow();

        }

        private PdfPTable AddLogo()

        {

            int maxColumn = 1;

            PdfPTable pdfTable = new PdfPTable(maxColumn);


            _pdfCell = new PdfPCell(IKR_Report.GetImage("HG6.png"));

            _pdfCell.Colspan = maxColumn;

            _pdfCell.HorizontalAlignment = Element.ALIGN_CENTER;

            _pdfCell.Border = 0;

            _pdfCell.ExtraParagraphSpace = 0;

            pdfTable.AddCell(_pdfCell);

            pdfTable.CompleteRow();


            return pdfTable;

        }

        private PdfPTable SetPageTitle()

        {

            int maxColumn = 5;

            PdfPTable pdfTable = new PdfPTable(maxColumn);


            _fontStyle = FontFactory.GetFont("Tahoma", 18f, 1);

            _pdfCell = new PdfPCell(new Phrase("Gate Pass Challan", _fontStyle));

            _pdfCell.Colspan = maxColumn;

            _pdfCell.HorizontalAlignment = Element.ALIGN_CENTER;

            _pdfCell.Border = 0;

            _pdfCell.ExtraParagraphSpace = 0;

            pdfTable.AddCell(_pdfCell);

            pdfTable.CompleteRow();


            _fontStyle = FontFactory.GetFont("Tahoma", 20f, 1);

            _pdfCell = new PdfPCell(new Phrase(_oSUGatePass.FromUnitFullName, _fontStyle));

            _pdfCell.Colspan = maxColumn;

            _pdfCell.HorizontalAlignment = Element.ALIGN_CENTER;

            _pdfCell.Border = 0;

            _pdfCell.ExtraParagraphSpace = 0;

            pdfTable.AddCell(_pdfCell);

            pdfTable.CompleteRow();


            _fontStyle = FontFactory.GetFont("Tahoma", 16f, 1);

            _pdfCell = new PdfPCell(new Phrase(_oSUGatePass.FromUnitAddress, _fontStyle));

            _pdfCell.Colspan = maxColumn;

            _pdfCell.HorizontalAlignment = Element.ALIGN_CENTER;

            _pdfCell.Border = 0;

            _pdfCell.ExtraParagraphSpace = 0;

            pdfTable.AddCell(_pdfCell);

            pdfTable.CompleteRow();


            return pdfTable;

        }

        private void ParentInfo()

        {

            _pdfCell = new PdfPCell(this.SetGatePassInfo());

            _pdfCell.Colspan = _maxColumn;

            _pdfCell.Border = 0;

            _pdfTable.AddCell(_pdfCell);

            _pdfTable.CompleteRow();

        }

        private void ReportBody()

        {

            _fontStyle = FontFactory.GetFont("Tahoma", 9f, 1);

            var fontStyle = FontFactory.GetFont("Tahoma", 9f, 0);


            #region Header

            _pdfCell = new PdfPCell(new Phrase("SL", _fontStyle));

            _pdfCell.HorizontalAlignment = Element.ALIGN_CENTER;

            _pdfCell.VerticalAlignment = Element.ALIGN_MIDDLE;

            _pdfCell.BackgroundColor = BaseColor.GRAY;

            _pdfTable.AddCell(_pdfCell);


            _pdfCell = new PdfPCell(new Phrase("Challan No", _fontStyle));

            _pdfCell.HorizontalAlignment = Element.ALIGN_CENTER;

            _pdfCell.VerticalAlignment = Element.ALIGN_MIDDLE;

            _pdfCell.BackgroundColor = BaseColor.GRAY;

            _pdfTable.AddCell(_pdfCell);


            _pdfCell = new PdfPCell(new Phrase("Challan Date", _fontStyle));

            _pdfCell.HorizontalAlignment = Element.ALIGN_CENTER;

            _pdfCell.VerticalAlignment = Element.ALIGN_MIDDLE;

            _pdfCell.BackgroundColor = BaseColor.GRAY;

            _pdfTable.AddCell(_pdfCell);


            _pdfCell = new PdfPCell(new Phrase("Qty", _fontStyle));

            _pdfCell.HorizontalAlignment = Element.ALIGN_CENTER;

            _pdfCell.VerticalAlignment = Element.ALIGN_MIDDLE;

            _pdfCell.BackgroundColor = BaseColor.GRAY;

            _pdfTable.AddCell(_pdfCell);


            _pdfCell = new PdfPCell(new Phrase("Remark", _fontStyle));

            _pdfCell.HorizontalAlignment = Element.ALIGN_CENTER;

            _pdfCell.VerticalAlignment = Element.ALIGN_MIDDLE;

            _pdfCell.BackgroundColor = BaseColor.GRAY;

            _pdfTable.AddCell(_pdfCell);


            _pdfTable.CompleteRow();

            #endregion


            #region Body

            int nSL = 1,

                nTotalChallanQty = 0;

            _oSUGatePass.SUChallans = _oSUGatePass.SUChallans.OrderBy(x => x.ChallanNo).ToList();

            foreach (var oSUChallan in _oSUGatePass.SUChallans)

            {

                nTotalChallanQty += oSUChallan.ChallanQty;


                _pdfCell = new PdfPCell(new Phrase(nSL++.ToString(), fontStyle));

                _pdfCell.HorizontalAlignment = Element.ALIGN_CENTER;

                _pdfCell.VerticalAlignment = Element.ALIGN_MIDDLE;

                _pdfCell.BackgroundColor = BaseColor.WHITE;

                _pdfTable.AddCell(_pdfCell);


                _pdfCell = new PdfPCell(new Phrase(oSUChallan.ChallanNo == "" ? "-" : oSUChallan.ChallanNo, fontStyle));

                _pdfCell.HorizontalAlignment = Element.ALIGN_LEFT;

                _pdfCell.VerticalAlignment = Element.ALIGN_MIDDLE;

                _pdfCell.BackgroundColor = BaseColor.WHITE;

                _pdfTable.AddCell(_pdfCell);


                _pdfCell = new PdfPCell(new Phrase(oSUChallan.ChallanDateSt == "" ? "-" : oSUChallan.ChallanDateSt, fontStyle));

                _pdfCell.HorizontalAlignment = Element.ALIGN_LEFT;

                _pdfCell.VerticalAlignment = Element.ALIGN_MIDDLE;

                _pdfCell.BackgroundColor = BaseColor.WHITE;

                _pdfTable.AddCell(_pdfCell);


                _pdfCell = new PdfPCell(new Phrase(oSUChallan.ChallanQty.ToString() == "" ? "-" : oSUChallan.ChallanQty.ToString(), fontStyle));

                _pdfCell.HorizontalAlignment = Element.ALIGN_RIGHT;

                _pdfCell.VerticalAlignment = Element.ALIGN_MIDDLE;

                _pdfCell.BackgroundColor = BaseColor.WHITE;

                _pdfTable.AddCell(_pdfCell);


                _pdfCell = new PdfPCell(new Phrase(oSUChallan.Remark == "" ? "-" : oSUChallan.Remark, fontStyle));

                _pdfCell.HorizontalAlignment = Element.ALIGN_LEFT;

                _pdfCell.VerticalAlignment = Element.ALIGN_MIDDLE;

                _pdfCell.BackgroundColor = BaseColor.WHITE;

                _pdfTable.AddCell(_pdfCell);


                _pdfTable.CompleteRow();


                if (nSL == 25)

                {

                    this.EmptyRow(2);

                    this.Signature();

                }

            }

            #endregion


            #region Sum

            _pdfCell = new PdfPCell(new Phrase("Total : ", _fontStyle));

            _pdfCell.HorizontalAlignment = Element.ALIGN_RIGHT;

            _pdfCell.VerticalAlignment = Element.ALIGN_MIDDLE;

            _pdfCell.BackgroundColor = BaseColor.WHITE;

            _pdfCell.Colspan = _maxColumn - 2;

            _pdfCell.Border = 0;

            _pdfTable.AddCell(_pdfCell);


            _pdfCell = new PdfPCell(new Phrase(nTotalChallanQty.ToString("#,##0"), _fontStyle));

            _pdfCell.HorizontalAlignment = Element.ALIGN_RIGHT;

            _pdfCell.VerticalAlignment = Element.ALIGN_MIDDLE;

            _pdfCell.BackgroundColor = BaseColor.WHITE;

            _pdfCell.Border = 0;

            _pdfTable.AddCell(_pdfCell);


            _pdfCell = new PdfPCell(new Phrase("", _fontStyle));

            _pdfCell.HorizontalAlignment = Element.ALIGN_LEFT;

            _pdfCell.VerticalAlignment = Element.ALIGN_MIDDLE;

            _pdfCell.BackgroundColor = BaseColor.WHITE;

            _pdfCell.Border = 0;

            _pdfTable.AddCell(_pdfCell);


            _pdfTable.CompleteRow();

            #endregion

        }

        private void EmptyRow(int nCount)

        {

            for (int i = 1; i <= nCount; i++)

            {

                _pdfCell = new PdfPCell(new Phrase(" ", _fontStyle));

                _pdfCell.BackgroundColor = BaseColor.WHITE;

                _pdfCell.Border = 0;

                _pdfCell.Colspan = _maxColumn;

                _pdfCell.ExtraParagraphSpace = 10;

                _pdfTable.AddCell(_pdfCell);

                _pdfTable.CompleteRow();

            }

        }

        private PdfPTable SetGatePassInfo()

        {

            PdfPTable pdfTable = new PdfPTable(6);

            int maxColumn = 6;


            _fontStyle = FontFactory.GetFont("Tahoma", 11f, 1);

            var fontStyle = FontFactory.GetFont("Tahoma", 11f, 0);

            var fontStyleGP = FontFactory.GetFont("Tahoma", 18f, 0);


            #region Row 1

            _pdfCell = new PdfPCell(new Phrase("GP No : ", _fontStyle));

            _pdfCell.HorizontalAlignment = Element.ALIGN_RIGHT;

            _pdfCell.VerticalAlignment = Element.ALIGN_MIDDLE;

            _pdfCell.BackgroundColor = BaseColor.WHITE;

            _pdfCell.Border = 0;

            pdfTable.AddCell(_pdfCell);


            _pdfCell = new PdfPCell(new Phrase(_oSUGatePass.GatePassNo, fontStyleGP));

            _pdfCell.HorizontalAlignment = Element.ALIGN_LEFT;

            _pdfCell.VerticalAlignment = Element.ALIGN_MIDDLE;

            _pdfCell.BackgroundColor = BaseColor.WHITE;

            _pdfCell.Colspan = 2;

            _pdfCell.Border = 0;

            pdfTable.AddCell(_pdfCell);


            _pdfCell = new PdfPCell(new Phrase("Date : ", _fontStyle));

            _pdfCell.HorizontalAlignment = Element.ALIGN_RIGHT;

            _pdfCell.VerticalAlignment = Element.ALIGN_MIDDLE;

            _pdfCell.BackgroundColor = BaseColor.WHITE;

            _pdfCell.Border = 0;

            pdfTable.AddCell(_pdfCell);


            _pdfCell = new PdfPCell(new Phrase(_oSUGatePass.GatePassDateSt, fontStyle));

            _pdfCell.HorizontalAlignment = Element.ALIGN_LEFT;

            _pdfCell.VerticalAlignment = Element.ALIGN_MIDDLE;

            _pdfCell.BackgroundColor = BaseColor.WHITE;

            _pdfCell.Colspan = 2;

            _pdfCell.Border = 0;

            pdfTable.AddCell(_pdfCell);


            pdfTable.CompleteRow();

            #endregion


            #region Row 2

            _pdfCell = new PdfPCell(new Phrase("To : ", _fontStyle));

            _pdfCell.HorizontalAlignment = Element.ALIGN_RIGHT;

            _pdfCell.VerticalAlignment = Element.ALIGN_MIDDLE;

            _pdfCell.BackgroundColor = BaseColor.WHITE;

            _pdfCell.Border = 0;

            pdfTable.AddCell(_pdfCell);


            _pdfCell = new PdfPCell(new Phrase(_oSUGatePass.ToUnitName, fontStyle));

            _pdfCell.HorizontalAlignment = Element.ALIGN_LEFT;

            _pdfCell.VerticalAlignment = Element.ALIGN_MIDDLE;

            _pdfCell.BackgroundColor = BaseColor.WHITE;

            _pdfCell.Colspan = 2;

            _pdfCell.Border = 0;

            pdfTable.AddCell(_pdfCell);


            _pdfCell = new PdfPCell(new Phrase("Car No : ", _fontStyle));

            _pdfCell.HorizontalAlignment = Element.ALIGN_RIGHT;

            _pdfCell.VerticalAlignment = Element.ALIGN_MIDDLE;

            _pdfCell.BackgroundColor = BaseColor.WHITE;

            _pdfCell.Border = 0;

            pdfTable.AddCell(_pdfCell);


            _pdfCell = new PdfPCell(new Phrase(_oSUGatePass.CarNo, fontStyle));

            _pdfCell.HorizontalAlignment = Element.ALIGN_LEFT;

            _pdfCell.VerticalAlignment = Element.ALIGN_MIDDLE;

            _pdfCell.BackgroundColor = BaseColor.WHITE;

            _pdfCell.Colspan = 2;

            _pdfCell.Border = 0;

            pdfTable.AddCell(_pdfCell);


            pdfTable.CompleteRow();

            #endregion


            #region Row 3

            _pdfCell = new PdfPCell(new Phrase("Driver :", _fontStyle));

            _pdfCell.HorizontalAlignment = Element.ALIGN_RIGHT;

            _pdfCell.VerticalAlignment = Element.ALIGN_MIDDLE;

            _pdfCell.BackgroundColor = BaseColor.WHITE;

            _pdfCell.Border = 0;

            pdfTable.AddCell(_pdfCell);


            _pdfCell = new PdfPCell(new Phrase(_oSUGatePass.DriverName, fontStyle));

            _pdfCell.HorizontalAlignment = Element.ALIGN_LEFT;

            _pdfCell.VerticalAlignment = Element.ALIGN_MIDDLE;

            _pdfCell.BackgroundColor = BaseColor.WHITE;

            _pdfCell.Colspan = 2;

            _pdfCell.Border = 0;

            pdfTable.AddCell(_pdfCell);


            _pdfCell = new PdfPCell(new Phrase("Driver Contact :", _fontStyle));

            _pdfCell.HorizontalAlignment = Element.ALIGN_RIGHT;

            _pdfCell.VerticalAlignment = Element.ALIGN_MIDDLE;

            _pdfCell.BackgroundColor = BaseColor.WHITE;

            _pdfCell.Border = 0;

            pdfTable.AddCell(_pdfCell);


            _pdfCell = new PdfPCell(new Phrase(_oSUGatePass.DriverPhone, fontStyle));

            _pdfCell.HorizontalAlignment = Element.ALIGN_LEFT;

            _pdfCell.VerticalAlignment = Element.ALIGN_MIDDLE;

            _pdfCell.BackgroundColor = BaseColor.WHITE;

            _pdfCell.Colspan = 2;

            _pdfCell.Border = 0;

            pdfTable.AddCell(_pdfCell);


            pdfTable.CompleteRow();

            #endregion


            #region Row 4


            if (!string.IsNullOrEmpty(_oSUGatePass.DeliveryManName) || !string.IsNullOrEmpty(_oSUGatePass.DeliveryManPhone))

            {

                _pdfCell = new PdfPCell(new Phrase("Del.Man :", _fontStyle));

                _pdfCell.HorizontalAlignment = Element.ALIGN_RIGHT;

                _pdfCell.VerticalAlignment = Element.ALIGN_MIDDLE;

                _pdfCell.BackgroundColor = BaseColor.WHITE;

                _pdfCell.Border = 0;

                pdfTable.AddCell(_pdfCell);


                _pdfCell = new PdfPCell(new Phrase(_oSUGatePass.DeliveryManName, fontStyle));

                _pdfCell.HorizontalAlignment = Element.ALIGN_LEFT;

                _pdfCell.VerticalAlignment = Element.ALIGN_MIDDLE;

                _pdfCell.BackgroundColor = BaseColor.WHITE;

                _pdfCell.Colspan = 2;

                _pdfCell.Border = 0;

                pdfTable.AddCell(_pdfCell);


                _pdfCell = new PdfPCell(new Phrase("Del.Man Tel :", _fontStyle));

                _pdfCell.HorizontalAlignment = Element.ALIGN_RIGHT;

                _pdfCell.VerticalAlignment = Element.ALIGN_MIDDLE;

                _pdfCell.BackgroundColor = BaseColor.WHITE;

                _pdfCell.Border = 0;

                pdfTable.AddCell(_pdfCell);


                _pdfCell = new PdfPCell(new Phrase(_oSUGatePass.DeliveryManPhone, fontStyle));

                _pdfCell.HorizontalAlignment = Element.ALIGN_LEFT;

                _pdfCell.VerticalAlignment = Element.ALIGN_MIDDLE;

                _pdfCell.BackgroundColor = BaseColor.WHITE;

                _pdfCell.Colspan = 2;

                _pdfCell.Border = 0;

                pdfTable.AddCell(_pdfCell);


                pdfTable.CompleteRow();

            }

            #endregion


            #region Row 5

            _pdfCell = new PdfPCell(new Phrase("Address :", _fontStyle));

            _pdfCell.HorizontalAlignment = Element.ALIGN_RIGHT;

            _pdfCell.VerticalAlignment = Element.ALIGN_MIDDLE;

            _pdfCell.BackgroundColor = BaseColor.WHITE;

            _pdfCell.Border = 0;

            pdfTable.AddCell(_pdfCell);


            _pdfCell = new PdfPCell(new Phrase(_oSUGatePass.ToUnitAddress, fontStyle));

            _pdfCell.HorizontalAlignment = Element.ALIGN_LEFT;

            _pdfCell.VerticalAlignment = Element.ALIGN_MIDDLE;

            _pdfCell.BackgroundColor = BaseColor.WHITE;

            _pdfCell.Colspan = maxColumn - 1;

            _pdfCell.Border = 0;

            pdfTable.AddCell(_pdfCell);


            pdfTable.CompleteRow();

            #endregion


            return pdfTable;

        }

        private void QtyInWord()

        {

            var fontStyle = FontFactory.GetFont("Tahoma", 10f, 1);

            _pdfCell = new PdfPCell(new Phrase("In Words : " + BasicMethods.ToTitleCase(BasicMethods.NumberToWords(_oSUGatePass.SUChallans.Sum(x => x.ChallanQty)) + " Only"), fontStyle));

            _pdfCell.BackgroundColor = BaseColor.WHITE;

            _pdfCell.HorizontalAlignment = Element.ALIGN_CENTER;

            _pdfCell.Border = 0;

            _pdfCell.Colspan = _maxColumn;

            _pdfTable.AddCell(_pdfCell);

            _pdfTable.CompleteRow();

        }

        private void SetRemark()

        {

            if (!string.IsNullOrEmpty(_oSUGatePass.Remark))

            {

                var fontStyle = FontFactory.GetFont("Tahoma", 10f, 0);

                _pdfCell = new PdfPCell(new Phrase("Remark : " + _oSUGatePass.Remark, fontStyle));

                _pdfCell.BackgroundColor = BaseColor.WHITE;

                _pdfCell.Border = 0;

                _pdfCell.Colspan = _maxColumn;

                _pdfTable.AddCell(_pdfCell);

                _pdfTable.CompleteRow();

            }

        }

        private void SetBlackRows()

        {

            int countRow = 30 - _oSUGatePass.SUChallans.Count;

            for (int i = 1; i <= countRow; i++)

            {

                _pdfCell = new PdfPCell(new Phrase(" ", _fontStyle));

                _pdfCell.BackgroundColor = BaseColor.WHITE;

                _pdfCell.Border = 0;

                _pdfCell.Colspan = _maxColumn;

                _pdfTable.AddCell(_pdfCell);

                _pdfTable.CompleteRow();

            }

        }

        private void Signature()

        {

            //this.SetBlackRows();


            _pdfCell = new PdfPCell(this.SetSignatures());

            _pdfCell.Colspan = _maxColumn;

            _pdfCell.Border = 0;

            _pdfTable.AddCell(_pdfCell);

            _pdfTable.CompleteRow();

        }

        private PdfPTable SetSignatures()

        {

            PdfPTable pdfTable = new PdfPTable(11);


            _fontStyle = FontFactory.GetFont("Tahoma", 9f, 1);

            var fontStyle = FontFactory.GetFont("Tahoma", 9f, 0);


            #region Dash

            _pdfCell = new PdfPCell(new Phrase("--------------------------", _fontStyle));

            _pdfCell.HorizontalAlignment = Element.ALIGN_CENTER;

            _pdfCell.VerticalAlignment = Element.ALIGN_BOTTOM;

            _pdfCell.BackgroundColor = BaseColor.WHITE;

            _pdfCell.Border = 0;

            _pdfCell.Colspan = 2;

            pdfTable.AddCell(_pdfCell);


            _pdfCell = new PdfPCell(new Phrase("", _fontStyle));

            _pdfCell.HorizontalAlignment = Element.ALIGN_CENTER;

            _pdfCell.VerticalAlignment = Element.ALIGN_BOTTOM;

            _pdfCell.BackgroundColor = BaseColor.WHITE;

            _pdfCell.Border = 0;

            _pdfCell.Colspan = 1;

            pdfTable.AddCell(_pdfCell);


            _pdfCell = new PdfPCell(new Phrase("----------------------", _fontStyle));

            _pdfCell.HorizontalAlignment = Element.ALIGN_CENTER;

            _pdfCell.VerticalAlignment = Element.ALIGN_BOTTOM;

            _pdfCell.BackgroundColor = BaseColor.WHITE;

            _pdfCell.Border = 0;

            _pdfCell.Colspan = 2;

            pdfTable.AddCell(_pdfCell);


            _pdfCell = new PdfPCell(new Phrase("", _fontStyle));

            _pdfCell.HorizontalAlignment = Element.ALIGN_CENTER;

            _pdfCell.VerticalAlignment = Element.ALIGN_BOTTOM;

            _pdfCell.BackgroundColor = BaseColor.WHITE;

            _pdfCell.Border = 0;

            _pdfCell.Colspan = 1;

            pdfTable.AddCell(_pdfCell);


            _pdfCell = new PdfPCell(new Phrase("----------------------", _fontStyle));

            _pdfCell.HorizontalAlignment = Element.ALIGN_CENTER;

            _pdfCell.VerticalAlignment = Element.ALIGN_BOTTOM;

            _pdfCell.BackgroundColor = BaseColor.WHITE;

            _pdfCell.Border = 0;

            _pdfCell.Colspan = 2;

            pdfTable.AddCell(_pdfCell);


            _pdfCell = new PdfPCell(new Phrase("", _fontStyle));

            _pdfCell.HorizontalAlignment = Element.ALIGN_CENTER;

            _pdfCell.VerticalAlignment = Element.ALIGN_BOTTOM;

            _pdfCell.BackgroundColor = BaseColor.WHITE;

            _pdfCell.Border = 0;

            _pdfCell.Colspan = 1;

            pdfTable.AddCell(_pdfCell);


            _pdfCell = new PdfPCell(new Phrase("----------------------", _fontStyle));

            _pdfCell.HorizontalAlignment = Element.ALIGN_CENTER;

            _pdfCell.VerticalAlignment = Element.ALIGN_BOTTOM;

            _pdfCell.BackgroundColor = BaseColor.WHITE;

            _pdfCell.Border = 0;

            _pdfCell.Colspan = 2;

            pdfTable.AddCell(_pdfCell);


            pdfTable.CompleteRow();

            #endregion


            #region Text

            _pdfCell = new PdfPCell(new Phrase("Signature of Receiver", _fontStyle));

            _pdfCell.HorizontalAlignment = Element.ALIGN_CENTER;

            _pdfCell.VerticalAlignment = Element.ALIGN_TOP;

            _pdfCell.BackgroundColor = BaseColor.WHITE;

            _pdfCell.Border = 0;

            _pdfCell.Colspan = 2;

            pdfTable.AddCell(_pdfCell);


            _pdfCell = new PdfPCell(new Phrase("", _fontStyle));

            _pdfCell.HorizontalAlignment = Element.ALIGN_CENTER;

            _pdfCell.VerticalAlignment = Element.ALIGN_TOP;

            _pdfCell.BackgroundColor = BaseColor.WHITE;

            _pdfCell.Border = 0;

            _pdfCell.Colspan = 1;

            pdfTable.AddCell(_pdfCell);


            _pdfCell = new PdfPCell(new Phrase("Checked By", _fontStyle));

            _pdfCell.HorizontalAlignment = Element.ALIGN_CENTER;

            _pdfCell.VerticalAlignment = Element.ALIGN_TOP;

            _pdfCell.BackgroundColor = BaseColor.WHITE;

            _pdfCell.Border = 0;

            _pdfCell.Colspan = 2;

            pdfTable.AddCell(_pdfCell);


            _pdfCell = new PdfPCell(new Phrase("", _fontStyle));

            _pdfCell.HorizontalAlignment = Element.ALIGN_CENTER;

            _pdfCell.VerticalAlignment = Element.ALIGN_TOP;

            _pdfCell.BackgroundColor = BaseColor.WHITE;

            _pdfCell.Border = 0;

            _pdfCell.Colspan = 1;

            pdfTable.AddCell(_pdfCell);


            _pdfCell = new PdfPCell(new Phrase("Delivery Staff", _fontStyle));

            _pdfCell.HorizontalAlignment = Element.ALIGN_CENTER;

            _pdfCell.VerticalAlignment = Element.ALIGN_TOP;

            _pdfCell.BackgroundColor = BaseColor.WHITE;

            _pdfCell.Border = 0;

            _pdfCell.Colspan = 2;

            pdfTable.AddCell(_pdfCell);


            _pdfCell = new PdfPCell(new Phrase("", _fontStyle));

            _pdfCell.HorizontalAlignment = Element.ALIGN_CENTER;

            _pdfCell.VerticalAlignment = Element.ALIGN_TOP;

            _pdfCell.BackgroundColor = BaseColor.WHITE;

            _pdfCell.Border = 0;

            _pdfCell.Colspan = 1;

            pdfTable.AddCell(_pdfCell);


            _pdfCell = new PdfPCell(new Phrase("Authorized By", _fontStyle));

            _pdfCell.HorizontalAlignment = Element.ALIGN_CENTER;

            _pdfCell.VerticalAlignment = Element.ALIGN_TOP;

            _pdfCell.BackgroundColor = BaseColor.WHITE;

            _pdfCell.Border = 0;

            _pdfCell.Colspan = 2;

            pdfTable.AddCell(_pdfCell);


            pdfTable.CompleteRow();

            #endregion


            return pdfTable;

        }

    }



Controller :

 public ActionResult PrintGatePass(string p)

        {

            var user = (User)Session["CurrentUser"];

            if (user == null) return RedirectToAction("Logoff", "Home");


            int nSUGatePassId = IKR.SingleIntED(p);

            if (nSUGatePassId == 0) return RedirectToAction("Error", "Home");


            _oSUGatePass = new SUGatePass();

            if (nSUGatePassId > 0)

            {

                _oSUGatePass = _oSUGatePassBL.Get(nSUGatePassId);

                _oSUGatePass.SUChallans = _oSUChallanBL.GetsByGatePassId(nSUGatePassId);

            }

            RptSUGatePass rpt = new RptSUGatePass();

            return File(rpt.Report(_oSUGatePass), "application/pdf");

        }


Front-end :

 PrintGatePass: function (oSUGatePass) {

        if (oWUGatePass.WUGatePassId == 0) {

            Swal.fire('Invalid Gate Pass', '', 'warning');

            return false;

        }

        var encodedParam = Base64.encode(oWUGatePass.SUGatePassId);

        window.open('../SUGatePass/PrintGatePass?p=' + encodedParam, '_blank');

    },