Pages Header Builder Class.
示例#1
0
        /// <summary>
        /// Defines dynamic headers for pages and individual groups.
        /// </summary>
        /// <param name="pagesHeaderBuilder">Pages Header Builder</param>
        /// <returns></returns>
        public PdfReport PagesHeader(Action <PagesHeaderBuilder> pagesHeaderBuilder)
        {
            var builder = new PagesHeaderBuilder(this);

            pagesHeaderBuilder(builder);
            return(this);
        }
示例#2
0
 /// <summary>
 /// Defines dynamic headers for pages and individual groups.
 /// </summary>
 /// <param name="pagesHeaderBuilder">Pages Header Builder</param>
 /// <returns></returns>
 public PdfReport PagesHeader(Action<PagesHeaderBuilder> pagesHeaderBuilder)
 {
     var builder = new PagesHeaderBuilder(this);
     pagesHeaderBuilder(builder);
     return this;
 }
        private PdfGrid createPOHeader(PagesHeaderBuilder header, int purchaseorderId)
        {
            int nTradeId = 0;
            string szMsg = "";
            string szAddress = "";
            string szCity = "";
            string szState = "";
            string szZip = "";
            string szCountry = "";
            string szTel = "";
            string szFax = "";
            string szWebSiteTrade = "";
            string szEmailTrade = "";
            string szTradeName = "";
            string szAsiTrade = "";
            string szSageTrade = "";
            string szPpaiTrade = "";

            string szPODate = "";
            string szPORef = "";
            string szPONo = "";
            string szPOShipDate = "";
            string szPOBy = "";
            string szPOBlindDrop = "";

            string szVendorCompanyName = "";
            string szVendorFirstName = "";
            string szVendorLastName = "";
            string szVendorTitle = "";
            string szVendorAddress1 = "";
            string szVendorAddress2 = "";
            string szVendorAddress3 = "";
            string szVendorCity = "";
            string szVendorState = "";
            string szVendorZip = "";
            string szVendorCountry = "";
            string szVendorTel = "";
            string szVendorFax = "";
            string szVendorEmail = "";
            string szVendorWebsite = "";
            string szVendorTel1 = "";
            string szVendorTel2 = "";

            long telHlp = 0;
            long faxHlp = 0;
            string telfmt = "000-000-0000";

            DateTime dDate = DateTime.Now;

            //The report data
            PurchaseOrders purchaseorder = db.PurchaseOrders.Find(purchaseorderId);
            if (purchaseorder != null)
            {
                nTradeId = Convert.ToInt32(purchaseorder.TradeId);
                dDate = Convert.ToDateTime(purchaseorder.PODate);
                szPODate = dDate.ToString("MM/dd/yyyy");
                szPORef = purchaseorder.PurchaseOrderReference;
                szPONo = purchaseorder.PurchaseOrderNo;
                szPOBy = purchaseorder.PaidBy;
                szPOBlindDrop = purchaseorder.BlindDrop;
                if (purchaseorder.ShipDate == null)
                {
                    szPOShipDate = string.Empty;
                }
                else
                {
                    dDate = Convert.ToDateTime(purchaseorder.ShipDate);
                    szPOShipDate = dDate.ToString("MM/dd/yyyy");

                }
            }
            TimelyDepotMVC.Controllers.SalesOrderController.GetTradeData(db, ref szAddress, ref szCity, ref szState, ref szZip, ref szCountry, ref szTel, ref szFax,
                ref szWebSiteTrade, ref szEmailTrade, ref szTradeName, ref szAsiTrade, ref szSageTrade, ref szPpaiTrade, nTradeId);
            if (string.IsNullOrEmpty(szTel))
            {
                szTel = "0";
            }
            if (string.IsNullOrEmpty(szFax))
            {
                szFax = "0";
            }

            telHlp = Convert.ToInt64(szTel);
            szTel = telHlp.ToString(telfmt);
            telHlp = Convert.ToInt64(szFax);
            szFax = telHlp.ToString(telfmt);

            TimelyDepotMVC.Controllers.PurchaseOrderController.GetVendorData(db, purchaseorder.VendorId, ref szVendorCompanyName, ref szVendorFirstName, ref szVendorLastName,
                ref szVendorTitle, ref szVendorAddress1, ref szVendorAddress2, ref szVendorAddress3, ref szVendorCity, ref szVendorState, ref szVendorZip, ref szVendorCountry,
                ref szVendorTel, ref szVendorFax, ref szVendorEmail, ref szVendorWebsite, ref szVendorTel1, ref szVendorTel2);
            if (string.IsNullOrEmpty(szVendorTel1))
            {
                szVendorTel1 = "0";
            }
            if (string.IsNullOrEmpty(szVendorTel2))
            {
                szVendorTel2 = "0";
            }
            if (string.IsNullOrEmpty(szVendorTel))
            {
                szVendorTel = "0";
            }

            telHlp = Convert.ToInt64(szVendorTel1);
            szVendorTel1 = telHlp.ToString(telfmt);
            telHlp = Convert.ToInt64(szVendorTel2);
            szVendorTel2 = telHlp.ToString(telfmt);
            telHlp = Convert.ToInt64(szVendorTel);
            szVendorTel = telHlp.ToString(telfmt);

            //The report layout
            Font times01 = FontFactory.GetFont("helvetica-bold", 12, BaseColor.BLACK);
            Font times02 = FontFactory.GetFont("helvetica-bold", 12, Font.ITALIC, BaseColor.BLACK);
            Font times03 = FontFactory.GetFont("helvetica-bold", 12, Font.UNDERLINE, BaseColor.BLACK);
            Font times04 = FontFactory.GetFont("helvetica", 12, BaseColor.BLACK);
            Font times05 = FontFactory.GetFont("helvetica", 12, Font.UNDERLINE, BaseColor.BLACK);
            Font times06 = FontFactory.GetFont("helvetica", 10, BaseColor.BLACK);
            Font times07 = FontFactory.GetFont("helvetica", 12, Font.ITALIC, BaseColor.BLACK);
            Font times08 = FontFactory.GetFont("helvetica-bold", 16, BaseColor.BLACK);

            PdfPCell nestingcell = null;
            PdfPCell hlpCel = null;
            Paragraph title = null;

            //Create the table for the headr
            var table = new PdfGrid(numColumns: 1);
            table.SetTotalWidth(new float[] { 553f });
            table.LockedWidth = true;
            table.RunDirection = PdfWriter.RUN_DIRECTION_LTR;
            table.SpacingAfter = 7;

            szMsg = string.Format("{0}", szTradeName);
            title = new Paragraph(szMsg, times04);
            hlpCel = new PdfPCell(title);
            hlpCel.RunDirection = PdfWriter.RUN_DIRECTION_LTR;
            hlpCel.BorderWidthLeft = 0;
            hlpCel.BorderWidthRight = 0;
            hlpCel.BorderWidthTop = 0;
            hlpCel.BorderWidthBottom = 0;
            hlpCel.PaddingTop = 4;
            hlpCel.PaddingLeft = 0;
            hlpCel.PaddingRight = 0;
            hlpCel.PaddingBottom = 1;
            //BorderColorTop = new BaseColor(System.Drawing.Color.LightGray),
            hlpCel.HorizontalAlignment = Element.ALIGN_CENTER;
            table.AddCell(hlpCel);

            szMsg = string.Format("{0}", szAddress);
            title = new Paragraph(szMsg, times04);
            hlpCel = new PdfPCell(title);
            hlpCel.RunDirection = PdfWriter.RUN_DIRECTION_LTR;
            hlpCel.BorderWidthLeft = 0;
            hlpCel.BorderWidthRight = 0;
            hlpCel.BorderWidthTop = 0;
            hlpCel.BorderWidthBottom = 0;
            hlpCel.PaddingTop = 1;
            hlpCel.PaddingLeft = 0;
            hlpCel.PaddingRight = 0;
            hlpCel.PaddingBottom = 1;
            //BorderColorTop = new BaseColor(System.Drawing.Color.LightGray),
            hlpCel.HorizontalAlignment = Element.ALIGN_CENTER;
            table.AddCell(hlpCel);

            szMsg = string.Format("{0}, {1} {2}", szCity, szState, szZip);
            title = new Paragraph(szMsg, times04);
            hlpCel = new PdfPCell(title);
            hlpCel.RunDirection = PdfWriter.RUN_DIRECTION_LTR;
            hlpCel.BorderWidthLeft = 0;
            hlpCel.BorderWidthRight = 0;
            hlpCel.BorderWidthTop = 0;
            hlpCel.BorderWidthBottom = 0;
            hlpCel.PaddingTop = 1;
            hlpCel.PaddingLeft = 0;
            hlpCel.PaddingRight = 0;
            hlpCel.PaddingBottom = 1;
            //BorderColorTop = new BaseColor(System.Drawing.Color.LightGray),
            hlpCel.HorizontalAlignment = Element.ALIGN_CENTER;
            table.AddCell(hlpCel);

            szMsg = string.Format("Tel: {0}", szTel);
            title = new Paragraph(szMsg, times04);
            hlpCel = new PdfPCell(title);
            hlpCel.RunDirection = PdfWriter.RUN_DIRECTION_LTR;
            hlpCel.BorderWidthLeft = 0;
            hlpCel.BorderWidthRight = 0;
            hlpCel.BorderWidthTop = 0;
            hlpCel.BorderWidthBottom = 0;
            hlpCel.PaddingTop = 1;
            hlpCel.PaddingLeft = 0;
            hlpCel.PaddingRight = 0;
            hlpCel.PaddingBottom = 1;
            //BorderColorTop = new BaseColor(System.Drawing.Color.LightGray),
            hlpCel.HorizontalAlignment = Element.ALIGN_CENTER;
            table.AddCell(hlpCel);

            szMsg = string.Format("Fax: {0}", szFax);
            title = new Paragraph(szMsg, times04);
            hlpCel = new PdfPCell(title);
            hlpCel.RunDirection = PdfWriter.RUN_DIRECTION_LTR;
            hlpCel.BorderWidthLeft = 0;
            hlpCel.BorderWidthRight = 0;
            hlpCel.BorderWidthTop = 0;
            hlpCel.BorderWidthBottom = 0;
            hlpCel.PaddingTop = 1;
            hlpCel.PaddingLeft = 0;
            hlpCel.PaddingRight = 0;
            hlpCel.PaddingBottom = 1;
            //BorderColorTop = new BaseColor(System.Drawing.Color.LightGray),
            hlpCel.HorizontalAlignment = Element.ALIGN_CENTER;
            table.AddCell(hlpCel);

            szMsg = string.Format("Email: {0}", szEmailTrade);
            title = new Paragraph(szMsg, times04);
            hlpCel = new PdfPCell(title);
            hlpCel.RunDirection = PdfWriter.RUN_DIRECTION_LTR;
            hlpCel.BorderWidthLeft = 0;
            hlpCel.BorderWidthRight = 0;
            hlpCel.BorderWidthTop = 0;
            hlpCel.BorderWidthBottom = 0;
            hlpCel.PaddingTop = 1;
            hlpCel.PaddingLeft = 0;
            hlpCel.PaddingRight = 0;
            hlpCel.PaddingBottom = 1;
            //BorderColorTop = new BaseColor(System.Drawing.Color.LightGray),
            hlpCel.HorizontalAlignment = Element.ALIGN_CENTER;
            table.AddCell(hlpCel);

            //
            szMsg = string.Format("{0}", szPODate);
            title = new Paragraph(szMsg, times04);
            hlpCel = new PdfPCell(title);
            hlpCel.RunDirection = PdfWriter.RUN_DIRECTION_LTR;
            hlpCel.BorderWidthLeft = 0;
            hlpCel.BorderWidthRight = 0;
            hlpCel.BorderWidthTop = 0;
            hlpCel.BorderWidthBottom = 0;
            hlpCel.PaddingTop = 10;
            hlpCel.PaddingLeft = 0;
            hlpCel.PaddingRight = 0;
            hlpCel.PaddingBottom = 1;
            //BorderColorTop = new BaseColor(System.Drawing.Color.LightGray),
            hlpCel.HorizontalAlignment = Element.ALIGN_LEFT;
            table.AddCell(hlpCel);

            PdfPTable nested = new PdfPTable(2);
            nested.SetTotalWidth(new float[] { 332f, 221f });
            nested.LockedWidth = true;

            szMsg = string.Format("Attn: {0} {1}", szVendorFirstName, szVendorLastName);
            title = new Paragraph(szMsg, times04);
            hlpCel = new PdfPCell(title);
            hlpCel.RunDirection = PdfWriter.RUN_DIRECTION_LTR;
            hlpCel.BorderWidth = 0;
            hlpCel.PaddingTop = 1;
            hlpCel.PaddingLeft = 4;
            hlpCel.PaddingRight = 1;
            hlpCel.PaddingBottom = 1;
            hlpCel.HorizontalAlignment = Element.ALIGN_LEFT;
            nested.AddCell(hlpCel);

            szMsg = string.Format("Ref: {0}", szPORef);
            title = new Paragraph(szMsg, times08);
            hlpCel = new PdfPCell(title);
            hlpCel.RunDirection = PdfWriter.RUN_DIRECTION_LTR;
            hlpCel.BorderWidth = 0;
            hlpCel.PaddingTop = 1;
            hlpCel.PaddingLeft = 4;
            hlpCel.PaddingRight = 1;
            hlpCel.PaddingBottom = 1;
            hlpCel.HorizontalAlignment = Element.ALIGN_LEFT;
            nested.AddCell(hlpCel);

            szMsg = string.Format("{0}", szVendorCompanyName.ToUpper());
            title = new Paragraph(szMsg, times04);
            hlpCel = new PdfPCell(title);
            hlpCel.RunDirection = PdfWriter.RUN_DIRECTION_LTR;
            hlpCel.BorderWidth = 0;
            hlpCel.PaddingTop = 1;
            hlpCel.PaddingLeft = 4;
            hlpCel.PaddingRight = 1;
            hlpCel.PaddingBottom = 1;
            hlpCel.HorizontalAlignment = Element.ALIGN_LEFT;
            nested.AddCell(hlpCel);

            szMsg = string.Format("Purchase Order No.: {0}", szPONo);
            title = new Paragraph(szMsg, times04);
            hlpCel = new PdfPCell(title);
            hlpCel.RunDirection = PdfWriter.RUN_DIRECTION_LTR;
            hlpCel.BorderWidth = 0;
            hlpCel.PaddingTop = 1;
            hlpCel.PaddingLeft = 4;
            hlpCel.PaddingRight = 1;
            hlpCel.PaddingBottom = 1;
            hlpCel.HorizontalAlignment = Element.ALIGN_LEFT;
            nested.AddCell(hlpCel);

            PdfPCell nesthousing = new PdfPCell(nested);
            nesthousing.BorderWidth = 0;
            nesthousing.Padding = 0f;
            table.AddCell(nesthousing);

            szMsg = string.Format("{0} {1} {2}", szVendorAddress1, szVendorAddress2, szVendorAddress3);
            title = new Paragraph(szMsg, times04);
            hlpCel = new PdfPCell(title);
            hlpCel.RunDirection = PdfWriter.RUN_DIRECTION_LTR;
            hlpCel.BorderWidth = 0;
            hlpCel.PaddingTop = 1;
            hlpCel.PaddingLeft = 4;
            hlpCel.PaddingRight = 1;
            hlpCel.PaddingBottom = 1;
            hlpCel.HorizontalAlignment = Element.ALIGN_LEFT;
            table.AddCell(hlpCel);

            szMsg = string.Format("{0}, {1} {2}", szVendorCity, szVendorState, szVendorZip);
            title = new Paragraph(szMsg, times04);
            hlpCel = new PdfPCell(title);
            hlpCel.RunDirection = PdfWriter.RUN_DIRECTION_LTR;
            hlpCel.BorderWidth = 0;
            hlpCel.PaddingTop = 1;
            hlpCel.PaddingLeft = 4;
            hlpCel.PaddingRight = 1;
            hlpCel.PaddingBottom = 1;
            hlpCel.HorizontalAlignment = Element.ALIGN_LEFT;
            table.AddCell(hlpCel);

            szMsg = string.Format("Tel: {0} {1} {2}", szVendorTel1, szVendorTel2, szVendorTel);
            title = new Paragraph(szMsg, times04);
            hlpCel = new PdfPCell(title);
            hlpCel.RunDirection = PdfWriter.RUN_DIRECTION_LTR;
            hlpCel.BorderWidth = 0;
            hlpCel.PaddingTop = 1;
            hlpCel.PaddingLeft = 4;
            hlpCel.PaddingRight = 1;
            hlpCel.PaddingBottom = 1;
            hlpCel.HorizontalAlignment = Element.ALIGN_LEFT;
            table.AddCell(hlpCel);

            szMsg = string.Format("Ship date: {0}", szPOShipDate);
            title = new Paragraph(szMsg, times01);
            hlpCel = new PdfPCell(title);
            hlpCel.RunDirection = PdfWriter.RUN_DIRECTION_LTR;
            hlpCel.BorderWidth = 0;
            hlpCel.PaddingTop = 20;
            hlpCel.PaddingLeft = 4;
            hlpCel.PaddingRight = 1;
            hlpCel.PaddingBottom = 1;
            hlpCel.HorizontalAlignment = Element.ALIGN_LEFT;
            table.AddCell(hlpCel);

            szMsg = string.Format("By: {0}", szPOBy);
            title = new Paragraph(szMsg, times01);
            hlpCel = new PdfPCell(title);
            hlpCel.RunDirection = PdfWriter.RUN_DIRECTION_LTR;
            hlpCel.BorderWidth = 0;
            hlpCel.PaddingTop = 1;
            hlpCel.PaddingLeft = 4;
            hlpCel.PaddingRight = 1;
            hlpCel.PaddingBottom = 1;
            hlpCel.HorizontalAlignment = Element.ALIGN_LEFT;
            table.AddCell(hlpCel);

            szMsg = string.Format("Blind Drop by: {0}", szPOBlindDrop);
            title = new Paragraph(szMsg, times01);
            hlpCel = new PdfPCell(title);
            hlpCel.RunDirection = PdfWriter.RUN_DIRECTION_LTR;
            hlpCel.BorderWidth = 0;
            hlpCel.PaddingTop = 1;
            hlpCel.PaddingLeft = 4;
            hlpCel.PaddingRight = 1;
            hlpCel.PaddingBottom = 6;
            hlpCel.HorizontalAlignment = Element.ALIGN_LEFT;
            table.AddCell(hlpCel);

            return table;
        }
        private static PdfGrid createHeader(PagesHeaderBuilder header)
        {
            var table = new PdfGrid(numColumns: 1)
            {
                WidthPercentage = 100,
                RunDirection = PdfWriter.RUN_DIRECTION_LTR,
                SpacingAfter = 7
            };

            var title = header.PdfFont.FontSelector.Process("Our new rpt.");
            var pdfCell = new PdfPCell(title)
            {
                RunDirection = PdfWriter.RUN_DIRECTION_LTR,
                BorderWidthLeft = 0,
                BorderWidthRight = 0,
                BorderWidthTop = 0,
                BorderWidthBottom = 1,
                Padding = 4,
                BorderColorBottom = new BaseColor(System.Drawing.Color.LightGray),
                HorizontalAlignment = Element.ALIGN_CENTER
            };

            table.AddCell(pdfCell);
            return table;
        }
        private PdfGrid createHeader(PagesHeaderBuilder header, int Invoiceid)
        {
            string szMsg = "";
            string szInvoiceNo = "123456";
            string szCustomerNo = "810901";
            string szTrade = "The Essence of Time";
            string szASI = "52715";
            string szSage = "52534";
            string szTrade01 = "2508 Merced Ave Unit # A";
            string szCity = "";
            string szState = "";
            string szZip = "";
            string szCountry = "";
            string szTel = "";
            string szFax = "";
            string szWebSiteTrade = "";
            string szEmailTrade = "";
            string szAsiTrade = "";
            string szSageTrade = "";
            string szPpaiTrade = "";
            string szTrade02 = "www.timessence.com";
            string szTrade03 = "South El Monte, CA 91733";
            string szTrade04 = "*****@*****.**";
            string szTrade05 = "626-527-3877";
            string szTrade06 = "626-527-3898";
            string szSoldto01 = "GINNY COLLINS";
            string szSoldto02 = "ADSTREET";
            string szSoldto03 = "120 HARDING STREET";
            string szSoldto04 = "CHAPIN, SC 29036";
            string szSoldto05 = " ";
            string szSoldto06 = " ";
            string szSoldto07 = "803-345-3208";
            string szSoldto08 = "803-932-0669";
            string szShipTo01 = "GINNY COLLINS";
            string szShipTo02 = "ADSTREET";
            string szShipTo03 = "120 HARDING STREET";
            string szShipTo04 = "CHAPIN, SC 29036";
            string szShipTo05 = " ";
            string szShipTo06 = " ";
            string szShipTo07 = "803-345-3208";
            string szShipTo08 = "803-932-0669";

            long telHlp = 0;
            long faxHlp = 0;
            string telfmt = "000-000-0000";

            CustomersContactAddress soldto = null;
            CustomersBillingDept billto = null;
            CustomersShipAddress shipto = null;
            VendorsContactAddress venaddress = null;

            IQueryable<CustomersContactAddress> qryAddress = null;
            IQueryable<VendorsContactAddress> qryVenAddres = null;
            IQueryable<CustomersShipAddress> qryshipto = null;
            IQueryable<CustomersBillingDept> qryBill = null;

            //Get the invoice data
            Invoice invoice = null;
            invoice = db.Invoices.Find(Invoiceid);
            if (invoice == null)
            {
                return null;
            }
            szInvoiceNo = invoice.InvoiceNo;

            TimelyDepotMVC.Controllers.SalesOrderController.GetCustomerData01(db, ref szASI, ref szSage, ref szTrade02, ref szTrade04, ref szCustomerNo, Convert.ToInt32(invoice.CustomerId));
            TimelyDepotMVC.Controllers.SalesOrderController.GetTradeData(db, ref szTrade01, ref szCity, ref szState, ref szZip, ref szCountry, ref szTel, ref szFax,
                ref szTrade02, ref szTrade04, ref szTrade, ref szAsiTrade, ref szSageTrade, ref szPpaiTrade, Convert.ToInt32(invoice.TradeId));
            telHlp = Convert.ToInt64(szTel);
            szTel = telHlp.ToString(telfmt);
            telHlp = Convert.ToInt64(szFax);
            szFax = telHlp.ToString(telfmt);

            //Get the SolTo Data
            qryAddress = db.CustomersContactAddresses.Where(ctad => ctad.CustomerId == invoice.CustomerId);
            if (qryAddress.Count() > 0)
            {
                soldto = qryAddress.FirstOrDefault<CustomersContactAddress>();
                if (soldto != null)
                {

                }
            }

            //Get the Bill to data
            qryBill = db.CustomersBillingDepts.Where(ctbi => ctbi.CustomerId == invoice.CustomerId);
            if (qryBill.Count() > 0)
            {
                billto = qryBill.FirstOrDefault<CustomersBillingDept>();
                if (billto != null)
                {
                }
            }

            //Get the ship to data
            qryshipto = db.CustomersShipAddresses.Where(ctsp => ctsp.Id == invoice.CustomerShiptoId);
            if (qryshipto.Count() > 0)
            {
                shipto = qryshipto.FirstOrDefault<CustomersShipAddress>();
                if (shipto != null)
                {
                }
            }

            //Get the Vendor address data
            qryVenAddres = db.VendorsContactAddresses.Where(vnad => vnad.VendorId == invoice.VendorId);
            if (qryVenAddres.Count() > 0)
            {
                venaddress = qryVenAddres.FirstOrDefault<VendorsContactAddress>();
                if (venaddress != null)
                {
                }
            }

            //Set the address
            szSoldto01 = string.Format("{0} {1}", soldto.FirstName, soldto.LastName);
            szSoldto02 = string.Format("{0}", soldto.CompanyName);
            szSoldto03 = string.Format("{0}", soldto.Address);
            szSoldto04 = string.Format("{0}, {1} {2}", soldto.City, soldto.State, soldto.Zip);
            if (string.IsNullOrEmpty(soldto.Tel))
            {
                szSoldto07 = "0";
            }
            else
            {
                szSoldto07 = soldto.Tel;
            }
            if (string.IsNullOrEmpty(soldto.Fax))
            {
                szSoldto08 = "0";
            }
            else
            {
                szSoldto08 = soldto.Fax;
            }

            telHlp = Convert.ToInt64(szSoldto07);
            szSoldto07 = telHlp.ToString(telfmt);
            telHlp = Convert.ToInt64(szSoldto08);
            szSoldto08 = telHlp.ToString(telfmt);

            if (invoice.IsBlindShip)
            {

            }
            else
            {
                //szFirstName = szTradeName;
                //szAddressHlp2 = szAddress;
                //szAddressHlp3 = string.Format("{0} {1} {2}", szCity, szState, szZip);

                //Ship to data
                //szFirstName2 = shipto.FirstName;
                //szLastName2 = shipto.LastName;
                //szCompany2 = soldto.CompanyName;
                //szAddressHlp4 = string.Format("{0}", shipto.Address1);
                //szAddressHlp5 = string.Format("{0} {1} {2}", shipto.City, shipto.State, shipto.Zip);
                if (shipto != null)
                {
                    szShipTo01 = string.Format("{0} {1}", shipto.FirstName, shipto.LastName);
                    szShipTo02 = string.Format("{0}", soldto.CompanyName);
                    szShipTo03 = string.Format("{0}", shipto.Address1);
                    szShipTo04 = string.Format("{0} {1} {2}", shipto.City, shipto.State, shipto.Zip);

                    if (string.IsNullOrEmpty(shipto.Tel))
                    {
                        szShipTo07 = "0";
                    }
                    else
                    {
                        szShipTo07 = shipto.Tel;
                    }
                    if (string.IsNullOrEmpty(shipto.Fax))
                    {
                        szShipTo08 = "0";
                    }
                    else
                    {
                        szShipTo08 = shipto.Fax;
                    }

                    telHlp = Convert.ToInt64(szShipTo07);
                    szShipTo07 = telHlp.ToString(telfmt);
                    telHlp = Convert.ToInt64(szShipTo08);
                    szShipTo08 = telHlp.ToString(telfmt);

                }
                else
                {
                    szShipTo01 = string.Format("{0} {1}", string.Empty, string.Empty);
                    szShipTo02 = string.Format("{0}", string.Empty);
                    szShipTo03 = string.Format("{0}", string.Empty);
                    szShipTo04 = string.Format("{0} {1} {2}", string.Empty, string.Empty, string.Empty);
                    szShipTo07 = string.Format("{0}", string.Empty);
                    szShipTo08 = string.Format("{0}", string.Empty);
                }
            }

            //Create the table for the headr
            var table = new PdfGrid(numColumns: 2);
            table.SetTotalWidth(new float[] { 372.5f, 180.5f });
            table.LockedWidth = true;
            table.RunDirection = PdfWriter.RUN_DIRECTION_LTR;
            table.SpacingAfter = 7;

            //Paragraph title = new Paragraph("I N V O I C E", times);

            //List al available fonts in the sistem
            //foreach (var item in FontFactory.RegisteredFonts)
            //{

            //}

            // Variety of ways to use the GetFont() method:
            //Font arial = FontFactory.GetFont("Arial", 28, BaseColor.GRAY);
            //Font verdana = FontFactory.GetFont("Verdana", 16, Font.BOLDITALIC, new BaseColor(125, 88, 15));
            //Font palatino = FontFactory.GetFont(
            //     "palatino linotype italique",
            //      BaseFont.CP1252,
            //      BaseFont.EMBEDDED,
            //      10,
            //      Font.ITALIC,
            //      BaseColor.GREEN
            //      );
            //Font smallfont = FontFactory.GetFont("Arial", 7);
            //Font xFont = FontFactory.GetFont("nina fett");
            //xFont.Size = 10;
            //xFont.SetStyle("Italic");
            //xFont.SetColor(100, 50, 200);

            //var title = header.PdfFont.FontSelector.Process("I N V O I C E");
            //Font times = FontFactory.GetFont("helvetica-bold");
            //times.Size = 16;
            //times.SetStyle("Italic");
            //times.SetColor(0, 0, 0);

            PdfPCell hlpCell = null;
            Paragraph hlpPar = null;

            BaseFont bftimes = BaseFont.CreateFont(BaseFont.HELVETICA_BOLD, BaseFont.CP1252, true);
            Font times = new Font(bftimes, 18, Font.ITALIC, BaseColor.BLACK);
            Paragraph title = new Paragraph("I N V O I C E", times);

            //Title
            var pdfCell = new PdfPCell(title);
            pdfCell.RunDirection = PdfWriter.RUN_DIRECTION_LTR;
            pdfCell.BorderWidthTop = 0;
            pdfCell.BorderWidthLeft = 0;
            pdfCell.BorderWidthRight = 0;
            pdfCell.BorderWidthBottom = 0;
            pdfCell.Padding = 4;
            pdfCell.BorderColorBottom = new BaseColor(System.Drawing.Color.LightGray);
            pdfCell.HorizontalAlignment = Element.ALIGN_CENTER;
            table.AddCell(pdfCell);

            //Invoice and customer
            PdfPTable nested = new PdfPTable(2);
            nested.SetTotalWidth(new float[] { 97.65f, 62.85f });
            nested.LockedWidth = true;

            Font times01 = FontFactory.GetFont("helvetica-bold", 14, BaseColor.BLACK);
            szMsg = string.Format("Invoice No.:");
            title = new Paragraph(szMsg, times01);
            hlpCell = new PdfPCell(title);
            hlpCell.RunDirection = PdfWriter.RUN_DIRECTION_LTR;
            hlpCell.BorderWidth = 0;
            hlpCell.PaddingTop = 1;
            hlpCell.PaddingLeft = 4;
            hlpCell.PaddingRight = 1;
            hlpCell.PaddingBottom = 1;
            hlpCell.HorizontalAlignment = Element.ALIGN_RIGHT;
            nested.AddCell(hlpCell);

            szMsg = string.Format("{0}", szInvoiceNo);
            title = new Paragraph(szMsg, times01);
            hlpCell = new PdfPCell(title);
            hlpCell.RunDirection = PdfWriter.RUN_DIRECTION_LTR;
            hlpCell.BorderWidth = 0;
            hlpCell.PaddingTop = 1;
            hlpCell.PaddingLeft = 4;
            hlpCell.PaddingRight = 1;
            hlpCell.PaddingBottom = 1;
            hlpCell.HorizontalAlignment = Element.ALIGN_LEFT;
            nested.AddCell(hlpCell);

            Font times02 = FontFactory.GetFont("helvetica-bold", 12, BaseColor.BLACK);
            szMsg = string.Format("Customer No:");
            title = new Paragraph(szMsg, times02);
            hlpCell = new PdfPCell(title);
            hlpCell.RunDirection = PdfWriter.RUN_DIRECTION_LTR;
            hlpCell.BorderWidth = 0;
            hlpCell.PaddingTop = 1;
            hlpCell.PaddingLeft = 4;
            hlpCell.PaddingRight = 1;
            hlpCell.PaddingBottom = 1;
            hlpCell.HorizontalAlignment = Element.ALIGN_RIGHT;
            nested.AddCell(hlpCell);

            Font times03 = FontFactory.GetFont("helvetica", 12, BaseColor.BLACK);
            szMsg = string.Format("{0}", szCustomerNo);
            title = new Paragraph(szMsg, times03);
            hlpCell = new PdfPCell(title);
            hlpCell.RunDirection = PdfWriter.RUN_DIRECTION_LTR;
            hlpCell.BorderWidth = 0;
            hlpCell.PaddingTop = 1;
            hlpCell.PaddingLeft = 4;
            hlpCell.PaddingRight = 1;
            hlpCell.PaddingBottom = 1;
            hlpCell.HorizontalAlignment = Element.ALIGN_LEFT;
            nested.AddCell(hlpCell);

            PdfPCell nesthousing = new PdfPCell(nested);
            nesthousing.BorderWidth = 0;
            nesthousing.Padding = 0f;
            table.AddCell(nesthousing);

            szMsg = string.Format("{0}", szTrade);
            hlpPar = new Paragraph(szMsg, times01);
            hlpCell = new PdfPCell(hlpPar);
            hlpCell.RunDirection = PdfWriter.RUN_DIRECTION_LTR;
            hlpCell.BorderWidth = 0;
            hlpCell.PaddingTop = 1;
            hlpCell.PaddingLeft = 4;
            hlpCell.PaddingRight = 1;
            hlpCell.PaddingBottom = 1;
            hlpCell.HorizontalAlignment = Element.ALIGN_LEFT;
            table.AddCell(hlpCell);

            PdfPTable nested01 = new PdfPTable(4);
            nested01.SetTotalWidth(new float[] { 46.5f, 44f, 46f, 44f });
            nested01.LockedWidth = true;

            hlpPar = new Paragraph("ASI:", times03);
            hlpCell = new PdfPCell(hlpPar);
            hlpCell.RunDirection = PdfWriter.RUN_DIRECTION_LTR;
            hlpCell.BorderWidth = 0;
            hlpCell.PaddingTop = 1;
            hlpCell.PaddingLeft = 4;
            hlpCell.PaddingRight = 1;
            hlpCell.PaddingBottom = 1;
            hlpCell.HorizontalAlignment = Element.ALIGN_RIGHT;
            nested01.AddCell(hlpCell);

            szMsg = string.Format("{0}", szASI);
            hlpPar = new Paragraph(szMsg, times03);
            hlpCell = new PdfPCell(hlpPar);
            hlpCell.RunDirection = PdfWriter.RUN_DIRECTION_LTR;
            hlpCell.BorderWidth = 0;
            hlpCell.PaddingTop = 1;
            hlpCell.PaddingLeft = 4;
            hlpCell.PaddingRight = 1;
            hlpCell.PaddingBottom = 1;
            hlpCell.HorizontalAlignment = Element.ALIGN_LEFT;
            nested01.AddCell(hlpCell);

            hlpPar = new Paragraph("SAGE:", times03);
            hlpCell = new PdfPCell(hlpPar);
            hlpCell.RunDirection = PdfWriter.RUN_DIRECTION_LTR;
            hlpCell.BorderWidth = 0;
            hlpCell.PaddingTop = 1;
            hlpCell.PaddingLeft = 4;
            hlpCell.PaddingRight = 1;
            hlpCell.PaddingBottom = 1;
            hlpCell.HorizontalAlignment = Element.ALIGN_RIGHT;
            nested01.AddCell(hlpCell);

            szMsg = string.Format("{0}", szSage);
            hlpPar = new Paragraph(szMsg, times03);
            hlpCell = new PdfPCell(hlpPar);
            hlpCell.RunDirection = PdfWriter.RUN_DIRECTION_LTR;
            hlpCell.BorderWidth = 0;
            hlpCell.PaddingTop = 1;
            hlpCell.PaddingLeft = 4;
            hlpCell.PaddingRight = 1;
            hlpCell.PaddingBottom = 1;
            hlpCell.HorizontalAlignment = Element.ALIGN_LEFT;
            nested01.AddCell(hlpCell);

            PdfPCell nesthousing01 = new PdfPCell(nested01);
            nesthousing01.BorderWidth = 0;
            nesthousing01.Padding = 0f;
            table.AddCell(nesthousing01);

            //
            szMsg = string.Format("{0}", szTrade01);
            hlpPar = new Paragraph(szMsg, times03);
            hlpCell = new PdfPCell(hlpPar);
            hlpCell.RunDirection = PdfWriter.RUN_DIRECTION_LTR;
            hlpCell.BorderWidth = 0;
            hlpCell.PaddingTop = 1;
            hlpCell.PaddingLeft = 4;
            hlpCell.PaddingRight = 1;
            hlpCell.PaddingBottom = 1;
            hlpCell.HorizontalAlignment = Element.ALIGN_LEFT;
            table.AddCell(hlpCell);

            szMsg = string.Format("{0}", szTrade02);
            hlpPar = new Paragraph(szMsg, times03);
            hlpCell = new PdfPCell(hlpPar);
            hlpCell.RunDirection = PdfWriter.RUN_DIRECTION_LTR;
            hlpCell.BorderWidth = 0;
            hlpCell.PaddingTop = 1;
            hlpCell.PaddingLeft = 4;
            hlpCell.PaddingRight = 1;
            hlpCell.PaddingBottom = 1;
            hlpCell.HorizontalAlignment = Element.ALIGN_RIGHT;
            table.AddCell(hlpCell);

            //
            szTrade03 = string.Format("{0}, {1} {2}", szCity, szState, szZip);
            szMsg = string.Format("{0}", szTrade03);
            hlpPar = new Paragraph(szMsg, times03);
            hlpCell = new PdfPCell(hlpPar);
            hlpCell.RunDirection = PdfWriter.RUN_DIRECTION_LTR;
            hlpCell.BorderWidth = 0;
            hlpCell.PaddingTop = 1;
            hlpCell.PaddingLeft = 4;
            hlpCell.PaddingRight = 1;
            hlpCell.PaddingBottom = 1;
            hlpCell.HorizontalAlignment = Element.ALIGN_LEFT;
            table.AddCell(hlpCell);

            szMsg = string.Format("{0}", szTrade04);
            hlpPar = new Paragraph(szMsg, times03);
            hlpCell = new PdfPCell(hlpPar);
            hlpCell.RunDirection = PdfWriter.RUN_DIRECTION_LTR;
            hlpCell.BorderWidth = 0;
            hlpCell.PaddingTop = 1;
            hlpCell.PaddingLeft = 4;
            hlpCell.PaddingRight = 1;
            hlpCell.PaddingBottom = 1;
            hlpCell.HorizontalAlignment = Element.ALIGN_RIGHT;
            table.AddCell(hlpCell);

            //
            szMsg = string.Format("Tel: {0}", szTrade05);
            hlpPar = new Paragraph(szMsg, times03);
            hlpCell = new PdfPCell(hlpPar);
            hlpCell.RunDirection = PdfWriter.RUN_DIRECTION_LTR;
            hlpCell.BorderWidth = 0;
            hlpCell.PaddingTop = 1;
            hlpCell.PaddingLeft = 4;
            hlpCell.PaddingRight = 1;
            hlpCell.PaddingBottom = 1;
            hlpCell.HorizontalAlignment = Element.ALIGN_LEFT;
            table.AddCell(hlpCell);

            szMsg = string.Format("{0}", " ");
            hlpPar = new Paragraph(szMsg, times03);
            hlpCell = new PdfPCell(hlpPar);
            hlpCell.RunDirection = PdfWriter.RUN_DIRECTION_LTR;
            hlpCell.BorderWidth = 0;
            hlpCell.PaddingTop = 1;
            hlpCell.PaddingLeft = 4;
            hlpCell.PaddingRight = 1;
            hlpCell.PaddingBottom = 1;
            hlpCell.HorizontalAlignment = Element.ALIGN_RIGHT;
            table.AddCell(hlpCell);

            //
            szMsg = string.Format("Fax: {0}", szTrade06);
            hlpPar = new Paragraph(szMsg, times03);
            hlpCell = new PdfPCell(hlpPar);
            hlpCell.RunDirection = PdfWriter.RUN_DIRECTION_LTR;
            hlpCell.BorderWidth = 0;
            hlpCell.PaddingTop = 1;
            hlpCell.PaddingLeft = 4;
            hlpCell.PaddingRight = 1;
            hlpCell.PaddingBottom = 1;
            hlpCell.HorizontalAlignment = Element.ALIGN_LEFT;
            table.AddCell(hlpCell);

            szMsg = string.Format("{0}", " ");
            hlpPar = new Paragraph(szMsg, times03);
            hlpCell = new PdfPCell(hlpPar);
            hlpCell.RunDirection = PdfWriter.RUN_DIRECTION_LTR;
            hlpCell.BorderWidth = 0;
            hlpCell.PaddingTop = 1;
            hlpCell.PaddingLeft = 4;
            hlpCell.PaddingRight = 1;
            hlpCell.PaddingBottom = 1;
            hlpCell.HorizontalAlignment = Element.ALIGN_RIGHT;
            table.AddCell(hlpCell);

            // Addresses
            Font times04 = FontFactory.GetFont("helvetica", 10, BaseColor.BLACK);
            Font times05 = FontFactory.GetFont("helvetica-bold", 10, BaseColor.BLACK);

            PdfPTable nested02 = new PdfPTable(2);
            nested02.SetTotalWidth(new float[] { 259.47f, 259.47f });
            nested02.LockedWidth = true;

            szMsg = string.Format("{0}", "Sold to");
            hlpPar = new Paragraph(szMsg, times04);
            hlpCell = new PdfPCell(hlpPar);
            hlpCell.RunDirection = PdfWriter.RUN_DIRECTION_LTR;
            hlpCell.BorderWidth = 0;
            hlpCell.PaddingTop = 3;
            hlpCell.PaddingLeft = 12;
            hlpCell.PaddingRight = 1;
            hlpCell.PaddingBottom = 6;
            hlpCell.HorizontalAlignment = Element.ALIGN_LEFT;
            nested02.AddCell(hlpCell);

            szMsg = string.Format("{0}", "Ship to");
            hlpPar = new Paragraph(szMsg, times04);
            hlpCell = new PdfPCell(hlpPar);
            hlpCell.RunDirection = PdfWriter.RUN_DIRECTION_LTR;
            hlpCell.BorderWidth = 0;
            hlpCell.PaddingTop = 3;
            hlpCell.PaddingLeft = 8;
            hlpCell.PaddingRight = 1;
            hlpCell.PaddingBottom = 3;
            hlpCell.HorizontalAlignment = Element.ALIGN_LEFT;
            nested02.AddCell(hlpCell);

            PdfPCell nesthousing02 = new PdfPCell(nested02);
            nesthousing02.Colspan = 2;
            nesthousing02.BorderWidth = 0;
            nesthousing02.Padding = 0f;
            table.AddCell(nesthousing02);

            //Sold  table
            PdfPTable soldtotbl = new PdfPTable(numColumns: 3);
            soldtotbl.SetTotalWidth(new float[] { 30.1f, 113f, 98f });
            soldtotbl.LockedWidth = true;

            szMsg = string.Format("{0}", "Attn:");
            hlpPar = new Paragraph(szMsg, times04);
            PdfPCell hlpslto = new PdfPCell(hlpPar);
            hlpslto.RunDirection = PdfWriter.RUN_DIRECTION_LTR;
            hlpslto.BorderWidthTop = 0.5f;
            hlpslto.BorderWidthLeft = 0.5f;
            hlpslto.BorderWidthRight = 0;
            hlpslto.BorderWidthBottom = 0;
            hlpslto.PaddingTop = 1;
            hlpslto.PaddingLeft = 8;
            hlpslto.PaddingRight = 1;
            hlpslto.PaddingBottom = 1;
            hlpslto.HorizontalAlignment = Element.ALIGN_LEFT;
            soldtotbl.AddCell(hlpslto);

            szMsg = string.Format("{0}", szSoldto01);
            hlpPar = new Paragraph(szMsg, times05);
            hlpslto = new PdfPCell(hlpPar);
            hlpslto.RunDirection = PdfWriter.RUN_DIRECTION_LTR;
            hlpslto.Colspan = 2;
            hlpslto.BorderWidthTop = 0.5f;
            hlpslto.BorderWidthLeft = 0;
            hlpslto.BorderWidthRight = 0.5f;
            hlpslto.BorderWidthBottom = 0;
            hlpslto.PaddingTop = 1;
            hlpslto.PaddingLeft = 1;
            hlpslto.PaddingRight = 1;
            hlpslto.PaddingBottom = 1;
            hlpslto.HorizontalAlignment = Element.ALIGN_LEFT;
            soldtotbl.AddCell(hlpslto);

            szMsg = string.Format("{0}", " ");
            hlpPar = new Paragraph(szMsg, times04);
            hlpslto = new PdfPCell(hlpPar);
            hlpslto.RunDirection = PdfWriter.RUN_DIRECTION_LTR;
            hlpslto.BorderWidthTop = 0;
            hlpslto.BorderWidthLeft = 0.5f;
            hlpslto.BorderWidthRight = 0;
            hlpslto.BorderWidthBottom = 0;
            hlpslto.PaddingTop = 1;
            hlpslto.PaddingLeft = 8;
            hlpslto.PaddingRight = 1;
            hlpslto.PaddingBottom = 1;
            hlpslto.HorizontalAlignment = Element.ALIGN_LEFT;
            soldtotbl.AddCell(hlpslto);

            szMsg = string.Format("{0}", szSoldto02);
            hlpPar = new Paragraph(szMsg, times05);
            hlpslto = new PdfPCell(hlpPar);
            hlpslto.RunDirection = PdfWriter.RUN_DIRECTION_LTR;
            hlpslto.Colspan = 2;
            hlpslto.BorderWidthTop = 0;
            hlpslto.BorderWidthLeft = 0f;
            hlpslto.BorderWidthRight = 0.5f;
            hlpslto.BorderWidthBottom = 0;
            hlpslto.PaddingTop = 1;
            hlpslto.PaddingLeft = 1;
            hlpslto.PaddingRight = 1;
            hlpslto.PaddingBottom = 1;
            hlpslto.HorizontalAlignment = Element.ALIGN_LEFT;
            soldtotbl.AddCell(hlpslto);

            szMsg = string.Format("{0}", " ");
            hlpPar = new Paragraph(szMsg, times04);
            hlpslto = new PdfPCell(hlpPar);
            hlpslto.RunDirection = PdfWriter.RUN_DIRECTION_LTR;
            hlpslto.BorderWidthTop = 0;
            hlpslto.BorderWidthLeft = 0.5f;
            hlpslto.BorderWidthRight = 0;
            hlpslto.BorderWidthBottom = 0;
            hlpslto.PaddingTop = 1;
            hlpslto.PaddingLeft = 8;
            hlpslto.PaddingRight = 1;
            hlpslto.PaddingBottom = 1;
            hlpslto.HorizontalAlignment = Element.ALIGN_LEFT;
            soldtotbl.AddCell(hlpslto);

            szMsg = string.Format("{0}", szSoldto03);
            hlpPar = new Paragraph(szMsg, times04);
            hlpslto = new PdfPCell(hlpPar);
            hlpslto.RunDirection = PdfWriter.RUN_DIRECTION_LTR;
            hlpslto.Colspan = 2;
            hlpslto.BorderWidthTop = 0;
            hlpslto.BorderWidthLeft = 0f;
            hlpslto.BorderWidthRight = 0.5f;
            hlpslto.BorderWidthBottom = 0;
            hlpslto.PaddingTop = 1;
            hlpslto.PaddingLeft = 1;
            hlpslto.PaddingRight = 1;
            hlpslto.PaddingBottom = 1;
            hlpslto.HorizontalAlignment = Element.ALIGN_LEFT;
            soldtotbl.AddCell(hlpslto);

            szMsg = string.Format("{0}", " ");
            hlpPar = new Paragraph(szMsg, times04);
            hlpslto = new PdfPCell(hlpPar);
            hlpslto.RunDirection = PdfWriter.RUN_DIRECTION_LTR;
            hlpslto.BorderWidthTop = 0;
            hlpslto.BorderWidthLeft = 0.5f;
            hlpslto.BorderWidthRight = 0;
            hlpslto.BorderWidthBottom = 0;
            hlpslto.PaddingTop = 1;
            hlpslto.PaddingLeft = 8;
            hlpslto.PaddingRight = 1;
            hlpslto.PaddingBottom = 1;
            hlpslto.HorizontalAlignment = Element.ALIGN_LEFT;
            soldtotbl.AddCell(hlpslto);

            szMsg = string.Format("{0}", szSoldto04);
            hlpPar = new Paragraph(szMsg, times04);
            hlpslto = new PdfPCell(hlpPar);
            hlpslto.RunDirection = PdfWriter.RUN_DIRECTION_LTR;
            hlpslto.Colspan = 2;
            hlpslto.BorderWidthTop = 0;
            hlpslto.BorderWidthLeft = 0f;
            hlpslto.BorderWidthRight = 0.5f;
            hlpslto.BorderWidthBottom = 0;
            hlpslto.PaddingTop = 1;
            hlpslto.PaddingLeft = 1;
            hlpslto.PaddingRight = 1;
            hlpslto.PaddingBottom = 1;
            hlpslto.HorizontalAlignment = Element.ALIGN_LEFT;
            soldtotbl.AddCell(hlpslto);

            szMsg = string.Format("{0}", szSoldto05);
            hlpPar = new Paragraph(szMsg, times04);
            hlpslto = new PdfPCell(hlpPar);
            hlpslto.RunDirection = PdfWriter.RUN_DIRECTION_LTR;
            hlpslto.BorderWidthTop = 0;
            hlpslto.BorderWidthLeft = 0.5f;
            hlpslto.BorderWidthRight = 0;
            hlpslto.BorderWidthBottom = 0;
            hlpslto.PaddingTop = 1;
            hlpslto.PaddingLeft = 8;
            hlpslto.PaddingRight = 1;
            hlpslto.PaddingBottom = 1;
            hlpslto.HorizontalAlignment = Element.ALIGN_LEFT;
            soldtotbl.AddCell(hlpslto);

            szMsg = string.Format("{0}", szSoldto06);
            hlpPar = new Paragraph(szMsg, times04);
            hlpslto = new PdfPCell(hlpPar);
            hlpslto.RunDirection = PdfWriter.RUN_DIRECTION_LTR;
            hlpslto.Colspan = 2;
            hlpslto.BorderWidthTop = 0;
            hlpslto.BorderWidthLeft = 0f;
            hlpslto.BorderWidthRight = 0.5f;
            hlpslto.BorderWidthBottom = 0;
            hlpslto.PaddingTop = 1;
            hlpslto.PaddingLeft = 1;
            hlpslto.PaddingRight = 1;
            hlpslto.PaddingBottom = 1;
            hlpslto.HorizontalAlignment = Element.ALIGN_LEFT;
            soldtotbl.AddCell(hlpslto);

            szMsg = string.Format("Tel: {0}", szSoldto07);
            hlpPar = new Paragraph(szMsg, times04);
            hlpslto = new PdfPCell(hlpPar);
            hlpslto.RunDirection = PdfWriter.RUN_DIRECTION_LTR;
            hlpslto.BorderWidthTop = 0;
            hlpslto.BorderWidthLeft = 0.5f;
            hlpslto.BorderWidthRight = 0;
            hlpslto.BorderWidthBottom = 0.5f;
            hlpslto.Colspan = 2;
            hlpslto.PaddingTop = 1;
            hlpslto.PaddingLeft = 8;
            hlpslto.PaddingRight = 1;
            hlpslto.PaddingBottom = 3;
            hlpslto.HorizontalAlignment = Element.ALIGN_LEFT;
            soldtotbl.AddCell(hlpslto);

            szMsg = string.Format("Fax: {0}", szSoldto08);
            hlpPar = new Paragraph(szMsg, times04);
            hlpslto = new PdfPCell(hlpPar);
            hlpslto.RunDirection = PdfWriter.RUN_DIRECTION_LTR;
            hlpslto.BorderWidthTop = 0;
            hlpslto.BorderWidthLeft = 0f;
            hlpslto.BorderWidthRight = 0.5f;
            hlpslto.BorderWidthBottom = 0.5f;
            hlpslto.PaddingTop = 1;
            hlpslto.PaddingLeft = 1;
            hlpslto.PaddingRight = 1;
            hlpslto.PaddingBottom = 3;
            hlpslto.HorizontalAlignment = Element.ALIGN_LEFT;
            soldtotbl.AddCell(hlpslto);

            //Ship to table
            PdfPTable shiptotbl = new PdfPTable(numColumns: 3);
            shiptotbl.SetTotalWidth(new float[] { 30.1f, 113f, 98f });
            shiptotbl.LockedWidth = true;

            szMsg = string.Format("{0}", "Attn:");
            hlpPar = new Paragraph(szMsg, times04);
            PdfPCell hlpspto = new PdfPCell(hlpPar);
            hlpspto.RunDirection = PdfWriter.RUN_DIRECTION_LTR;
            hlpspto.BorderWidthTop = 0.5f;
            hlpspto.BorderWidthLeft = 0.5f;
            hlpspto.BorderWidthRight = 0;
            hlpspto.BorderWidthBottom = 0;
            hlpspto.PaddingTop = 1;
            hlpspto.PaddingLeft = 8;
            hlpspto.PaddingRight = 1;
            hlpspto.PaddingBottom = 1;
            hlpspto.HorizontalAlignment = Element.ALIGN_LEFT;
            shiptotbl.AddCell(hlpspto);

            szMsg = string.Format("{0}", szShipTo01);
            hlpPar = new Paragraph(szMsg, times05);
            hlpspto = new PdfPCell(hlpPar);
            hlpspto.RunDirection = PdfWriter.RUN_DIRECTION_LTR;
            hlpspto.Colspan = 2;
            hlpspto.BorderWidthTop = 0.5f;
            hlpspto.BorderWidthLeft = 0;
            hlpspto.BorderWidthRight = 0.5f;
            hlpspto.BorderWidthBottom = 0;
            hlpspto.PaddingTop = 1;
            hlpspto.PaddingLeft = 1;
            hlpspto.PaddingRight = 1;
            hlpspto.PaddingBottom = 1;
            hlpspto.HorizontalAlignment = Element.ALIGN_LEFT;
            shiptotbl.AddCell(hlpspto);

            szMsg = string.Format("{0}", " ");
            hlpPar = new Paragraph(szMsg, times04);
            hlpspto = new PdfPCell(hlpPar);
            hlpspto.RunDirection = PdfWriter.RUN_DIRECTION_LTR;
            hlpspto.BorderWidthTop = 0;
            hlpspto.BorderWidthLeft = 0.5f;
            hlpspto.BorderWidthRight = 0;
            hlpspto.BorderWidthBottom = 0;
            hlpspto.PaddingTop = 1;
            hlpspto.PaddingLeft = 8;
            hlpspto.PaddingRight = 1;
            hlpspto.PaddingBottom = 1;
            hlpspto.HorizontalAlignment = Element.ALIGN_LEFT;
            shiptotbl.AddCell(hlpspto);

            szMsg = string.Format("{0}", szShipTo02);
            hlpPar = new Paragraph(szMsg, times05);
            hlpspto = new PdfPCell(hlpPar);
            hlpspto.RunDirection = PdfWriter.RUN_DIRECTION_LTR;
            hlpspto.Colspan = 2;
            hlpspto.BorderWidthTop = 0;
            hlpspto.BorderWidthLeft = 0f;
            hlpspto.BorderWidthRight = 0.5f;
            hlpspto.BorderWidthBottom = 0;
            hlpspto.PaddingTop = 1;
            hlpspto.PaddingLeft = 1;
            hlpspto.PaddingRight = 1;
            hlpspto.PaddingBottom = 1;
            hlpspto.HorizontalAlignment = Element.ALIGN_LEFT;
            shiptotbl.AddCell(hlpspto);

            szMsg = string.Format("{0}", " ");
            hlpPar = new Paragraph(szMsg, times04);
            hlpspto = new PdfPCell(hlpPar);
            hlpspto.RunDirection = PdfWriter.RUN_DIRECTION_LTR;
            hlpspto.BorderWidthTop = 0;
            hlpspto.BorderWidthLeft = 0.5f;
            hlpspto.BorderWidthRight = 0;
            hlpspto.BorderWidthBottom = 0;
            hlpspto.PaddingTop = 1;
            hlpspto.PaddingLeft = 8;
            hlpspto.PaddingRight = 1;
            hlpspto.PaddingBottom = 1;
            hlpspto.HorizontalAlignment = Element.ALIGN_LEFT;
            shiptotbl.AddCell(hlpspto);

            szMsg = string.Format("{0}", szShipTo03);
            hlpPar = new Paragraph(szMsg, times04);
            hlpspto = new PdfPCell(hlpPar);
            hlpspto.RunDirection = PdfWriter.RUN_DIRECTION_LTR;
            hlpspto.Colspan = 2;
            hlpspto.BorderWidthTop = 0;
            hlpspto.BorderWidthLeft = 0f;
            hlpspto.BorderWidthRight = 0.5f;
            hlpspto.BorderWidthBottom = 0;
            hlpspto.PaddingTop = 1;
            hlpspto.PaddingLeft = 1;
            hlpspto.PaddingRight = 1;
            hlpspto.PaddingBottom = 1;
            hlpspto.HorizontalAlignment = Element.ALIGN_LEFT;
            shiptotbl.AddCell(hlpspto);

            szMsg = string.Format("{0}", " ");
            hlpPar = new Paragraph(szMsg, times04);
            hlpspto = new PdfPCell(hlpPar);
            hlpspto.RunDirection = PdfWriter.RUN_DIRECTION_LTR;
            hlpspto.BorderWidthTop = 0;
            hlpspto.BorderWidthLeft = 0.5f;
            hlpspto.BorderWidthRight = 0;
            hlpspto.BorderWidthBottom = 0;
            hlpspto.PaddingTop = 1;
            hlpspto.PaddingLeft = 8;
            hlpspto.PaddingRight = 1;
            hlpspto.PaddingBottom = 1;
            hlpspto.HorizontalAlignment = Element.ALIGN_LEFT;
            shiptotbl.AddCell(hlpspto);

            szMsg = string.Format("{0}", szShipTo04);
            hlpPar = new Paragraph(szMsg, times04);
            hlpspto = new PdfPCell(hlpPar);
            hlpspto.RunDirection = PdfWriter.RUN_DIRECTION_LTR;
            hlpspto.Colspan = 2;
            hlpspto.BorderWidthTop = 0;
            hlpspto.BorderWidthLeft = 0f;
            hlpspto.BorderWidthRight = 0.5f;
            hlpspto.BorderWidthBottom = 0;
            hlpspto.PaddingTop = 1;
            hlpspto.PaddingLeft = 1;
            hlpspto.PaddingRight = 1;
            hlpspto.PaddingBottom = 1;
            hlpspto.HorizontalAlignment = Element.ALIGN_LEFT;
            shiptotbl.AddCell(hlpspto);

            szMsg = string.Format("{0}", szShipTo05);
            hlpPar = new Paragraph(szMsg, times04);
            hlpspto = new PdfPCell(hlpPar);
            hlpspto.RunDirection = PdfWriter.RUN_DIRECTION_LTR;
            hlpspto.BorderWidthTop = 0;
            hlpspto.BorderWidthLeft = 0.5f;
            hlpspto.BorderWidthRight = 0;
            hlpspto.BorderWidthBottom = 0;
            hlpspto.PaddingTop = 1;
            hlpspto.PaddingLeft = 8;
            hlpspto.PaddingRight = 1;
            hlpspto.PaddingBottom = 1;
            hlpspto.HorizontalAlignment = Element.ALIGN_LEFT;
            shiptotbl.AddCell(hlpspto);

            szMsg = string.Format("{0}", szShipTo06);
            hlpPar = new Paragraph(szMsg, times04);
            hlpspto = new PdfPCell(hlpPar);
            hlpspto.RunDirection = PdfWriter.RUN_DIRECTION_LTR;
            hlpspto.Colspan = 2;
            hlpspto.BorderWidthTop = 0;
            hlpspto.BorderWidthLeft = 0f;
            hlpspto.BorderWidthRight = 0.5f;
            hlpspto.BorderWidthBottom = 0;
            hlpspto.PaddingTop = 1;
            hlpspto.PaddingLeft = 1;
            hlpspto.PaddingRight = 1;
            hlpspto.PaddingBottom = 1;
            hlpspto.HorizontalAlignment = Element.ALIGN_LEFT;
            shiptotbl.AddCell(hlpspto);

            szMsg = string.Format("Tel: {0}", szShipTo07);
            hlpPar = new Paragraph(szMsg, times04);
            hlpspto = new PdfPCell(hlpPar);
            hlpspto.RunDirection = PdfWriter.RUN_DIRECTION_LTR;
            hlpspto.BorderWidthTop = 0;
            hlpspto.BorderWidthLeft = 0.5f;
            hlpspto.BorderWidthRight = 0;
            hlpspto.BorderWidthBottom = 0.5f;
            hlpspto.Colspan = 2;
            hlpspto.PaddingTop = 1;
            hlpspto.PaddingLeft = 8;
            hlpspto.PaddingRight = 1;
            hlpspto.PaddingBottom = 3;
            hlpspto.HorizontalAlignment = Element.ALIGN_LEFT;
            shiptotbl.AddCell(hlpspto);

            szMsg = string.Format("Fax: {0}", szShipTo08);
            hlpPar = new Paragraph(szMsg, times04);
            hlpspto = new PdfPCell(hlpPar);
            hlpspto.RunDirection = PdfWriter.RUN_DIRECTION_LTR;
            hlpspto.BorderWidthTop = 0;
            hlpspto.BorderWidthLeft = 0f;
            hlpspto.BorderWidthRight = 0.5f;
            hlpspto.BorderWidthBottom = 0.5f;
            hlpspto.PaddingTop = 1;
            hlpspto.PaddingLeft = 1;
            hlpspto.PaddingRight = 1;
            hlpspto.PaddingBottom = 3;
            hlpspto.HorizontalAlignment = Element.ALIGN_LEFT;
            shiptotbl.AddCell(hlpspto);

            //The Address
            PdfPTable nested03 = new PdfPTable(2);
            nested03.SetTotalWidth(new float[] { 259.47f, 259.47f });
            nested03.LockedWidth = true;

            szMsg = string.Format("{0}", "Sold tox");
            hlpPar = new Paragraph(szMsg, times04);
            //hlpCell = new PdfPCell(hlpPar);

            hlpCell = new PdfPCell(soldtotbl);
            hlpCell.RunDirection = PdfWriter.RUN_DIRECTION_LTR;
            hlpCell.BorderWidth = 0;
            hlpCell.PaddingTop = 0;
            hlpCell.PaddingLeft = 8;
            hlpCell.PaddingRight = 0;
            hlpCell.PaddingBottom = 0;
            hlpCell.HorizontalAlignment = Element.ALIGN_LEFT;
            nested03.AddCell(hlpCell);

            szMsg = string.Format("{0}", "Ship tox");
            hlpPar = new Paragraph(szMsg, times04);
            //hlpCell = new PdfPCell(hlpPar);

            hlpCell = new PdfPCell(shiptotbl);
            hlpCell.RunDirection = PdfWriter.RUN_DIRECTION_LTR;
            hlpCell.BorderWidth = 0;
            hlpCell.PaddingTop = 1;
            hlpCell.PaddingLeft = 4;
            hlpCell.PaddingRight = 1;
            hlpCell.PaddingBottom = 1;
            hlpCell.HorizontalAlignment = Element.ALIGN_LEFT;
            nested03.AddCell(hlpCell);

            PdfPCell nesthousing03 = new PdfPCell(nested03);
            nesthousing03.Colspan = 2;
            nesthousing03.BorderWidth = 0;
            nesthousing03.Padding = 0f;
            table.AddCell(nesthousing03);

            //Invoice data
            szMsg = string.Format("{0}", "Invoice Data");
            hlpPar = new Paragraph(szMsg, times04);
            hlpCell = new PdfPCell(hlpPar);

            PdfPTable invoicedatatbl = GetInvoiceData(times04, times05, invoice);
            hlpCell = new PdfPCell(invoicedatatbl);
            hlpCell.RunDirection = PdfWriter.RUN_DIRECTION_LTR;
            hlpCell.BorderWidth = 0;
            hlpCell.PaddingTop = 3;
            hlpCell.PaddingLeft = 0;
            hlpCell.PaddingRight = 0;
            hlpCell.PaddingBottom = 0;
            hlpCell.HorizontalAlignment = Element.ALIGN_CENTER;

            PdfPCell nesthousing04 = new PdfPCell(hlpCell);
            nesthousing04.Colspan = 2;
            nesthousing04.BorderWidth = 0;
            hlpCell.Padding = 0f;
            table.AddCell(nesthousing04);

            return table;
        }