コード例 #1
0
        public PdfPCell RenderingCell(CellAttributes attributes)
        {
            var pdfCell = new PdfPCell();
            var table = new PdfGrid(1) { RunDirection = PdfWriter.RUN_DIRECTION_LTR };

            var filePath = System.IO.Path.Combine(AppPath.ApplicationPath, "Images\\" + _rnd.Next(1, 5).ToString("00") + ".png");
            var photo = PdfImageHelper.GetITextSharpImageFromImageFile(filePath);
            table.AddCell(new PdfPCell(photo, fit: false)
            {
                Border = 0,
                VerticalAlignment = Element.ALIGN_BOTTOM,
                HorizontalAlignment = Element.ALIGN_CENTER
            });

            var name = attributes.RowData.TableRowData.GetSafeStringValueOf("User");
            table.AddCell(new PdfPCell(attributes.BasicProperties.PdfFont.FontSelector.Process(name))
            {
                Border = 0,
                HorizontalAlignment = Element.ALIGN_CENTER
            });

            pdfCell.AddElement(table);

            return pdfCell;
        }
コード例 #2
0
        public void AddChartToPage(Document pdfDoc,
                                   int scalePercent = 100,
                                   float spacingBefore = 20,
                                   float spacingAfter = 10,
                                   float widthPercentage = 80)
        {
            using (var chartimage = new MemoryStream())
            {
                _chart.SaveImage(chartimage, ChartImageFormat.Bmp); //BMP gives the best compression result

                var iTextSharpImage = PdfImageHelper.GetITextSharpImageFromByteArray(chartimage.ToArray());
                iTextSharpImage.ScalePercent(scalePercent);
                iTextSharpImage.Alignment = Element.ALIGN_CENTER;

                var table = new PdfGrid(1)
                {
                    WidthPercentage = widthPercentage,
                    SpacingBefore = spacingBefore,
                    SpacingAfter = spacingAfter
                };
                table.AddCell(iTextSharpImage);

                pdfDoc.Add(table);
            }
        }
コード例 #3
0
ファイル: CustomPriceCell.cs プロジェクト: VahidN/PdfReport
        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        public PdfPCell RenderingCell(CellAttributes attributes)
        {
            var numColumns = 10;
            var salePrice = attributes.RowData.TableRowData
                                              .GetSafeStringValueOf<Transaction>(x => x.SalePrice, nullValue: "0")
                                              .PadLeft(numColumns, ' ');

            var table = new PdfGrid(numColumns)
            {
                RunDirection = PdfWriter.RUN_DIRECTION_LTR,
                WidthPercentage = 100
            };
            for (int i = 0; i < numColumns; i++)
            {
                var character = salePrice[i].ToString();
                table.AddCell(new PdfPCell(attributes.BasicProperties.PdfFont.FontSelector.Process(character))
                {
                    HorizontalAlignment = Element.ALIGN_CENTER,
                    BorderColor = BaseColor.GRAY,
                    UseAscender = true,
                    UseDescender = true,
                    VerticalAlignment = Element.ALIGN_MIDDLE,
                    BorderWidth = 1
                });
            }

            return new PdfPCell(table);
        }
コード例 #4
0
        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        public PdfPCell RenderingCell(CellAttributes attributes)
        {
            var pdfCell = new PdfPCell();
            var table = new PdfGrid(1) { RunDirection = PdfWriter.RUN_DIRECTION_LTR };

            var photo = PdfImageHelper.GetITextSharpImageFromImageFile(System.IO.Path.Combine(AppPath.ApplicationPath, "Images\\" + _rnd.Next(1, 5).ToString("00") + ".png"));
            table.AddCell(new PdfPCell(photo) { Border = 0, MinimumHeight = photo.Height, VerticalAlignment = Element.ALIGN_BOTTOM });

            var name = attributes.RowData.TableRowData.GetSafeStringValueOf<User>(x => x.Name);
            table.AddCell(new PdfPCell(attributes.BasicProperties.PdfFont.FontSelector.Process(name)) { Border = 0 });

            var lastName = attributes.RowData.TableRowData.GetSafeStringValueOf<User>(x => x.LastName);
            table.AddCell(new PdfPCell(attributes.BasicProperties.PdfFont.FontSelector.Process(lastName)) { Border = 0 });

            pdfCell.AddElement(table);

            return pdfCell;
        }
コード例 #5
0
ファイル: TableHelper.cs プロジェクト: VahidN/PdfReport
 // Public Methods (6)
 /// <summary>
 /// Adds a border to an existing PdfGrid
 /// </summary>
 /// <param name="table">Table</param>
 /// <param name="borderColor">Border's color</param>
 /// <param name="spacingBefore">Spacing before the table</param>
 /// <returns>A new PdfGrid</returns>
 public static PdfGrid AddBorderToTable(this PdfGrid table, BaseColor borderColor, float spacingBefore)
 {
     var outerTable = new PdfGrid(numColumns: 1)
     {
         WidthPercentage = table.WidthPercentage,
         SpacingBefore = spacingBefore
     };
     var pdfCell = new PdfPCell(table) { BorderColor = borderColor };
     outerTable.AddCell(pdfCell);
     return outerTable;
 }
コード例 #6
0
        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        public PdfPCell RenderingCell(CellAttributes attributes)
        {
            var pdfCell = new PdfPCell();
            var table = new PdfGrid(1) { RunDirection = PdfWriter.RUN_DIRECTION_LTR };

            // Please note that All columns and properties of an object will create a single cell here.

            var idx = attributes.RowData.ColumnNumber;
            var data = attributes.RowData.TableRowData;

            var character = data.GetSafeStringValueOf<CharacterInfo>(x => x.Character, propertyIndex: idx);
            table.AddCell(new PdfPCell(_customFont.FontSelector.Process(character)) { Border = 0, HorizontalAlignment = Element.ALIGN_CENTER });

            var characterCode = data.GetSafeStringValueOf<CharacterInfo>(x => x.CharacterCode, propertyIndex: idx);
            table.AddCell(new PdfPCell(attributes.BasicProperties.PdfFont.FontSelector.Process(characterCode)) { Border = 0, HorizontalAlignment = Element.ALIGN_CENTER });

            pdfCell.AddElement(table);

            return pdfCell;
        }
コード例 #7
0
        public PdfGrid RenderingReportHeader(Document pdfDoc, PdfWriter pdfWriter, IList<SummaryCellData> summaryData)
        {
            if (_image == null) //cache is empty
            {
                var templatePath = System.IO.Path.Combine(AppPath.ApplicationPath, "data\\PdfHeaderTemplate.pdf");
                _image = PdfImageHelper.GetITextSharpImageFromPdfTemplate(pdfWriter, templatePath);
            }

            var table = new PdfGrid(1);
            var cell = new PdfPCell(_image, true) { Border = 0 };
            table.AddCell(cell);
            return table;
        }
コード例 #8
0
ファイル: CustomHeader.cs プロジェクト: VahidN/PdfReport
        public PdfGrid RenderingReportHeader(Document pdfDoc, PdfWriter pdfWriter, IList<SummaryCellData> summaryData)
        {
            if (_image == null) //cache is empty
            {
                var templatePath = System.IO.Path.Combine(AppPath.ApplicationPath, "data\\PdfHeaderTemplate.pdf");
                _image = PdfImageHelper.GetITextSharpImageFromPdfTemplate(pdfWriter, templatePath);
            }

            var table = new PdfGrid(1);
            var cell = new PdfPCell(_image, true) { Border = 0 };
            table.AddCell(cell);
            return table;

            //Note: return null if you want to skip this callback and render nothing. Also in this case, you need to set the header.CacheHeader(cache: false) too.
        }
コード例 #9
0
        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;
        }
コード例 #10
0
 private static void addImageCell(string picturePath, PdfGrid mainTable)
 {
     mainTable.AddCell(new PdfPCell(PdfImageHelper.GetITextSharpImageFromImageFile(picturePath))
     {
         Border = 0,
         HorizontalAlignment = Element.ALIGN_CENTER,
         VerticalAlignment = Element.ALIGN_MIDDLE
     });
 }
コード例 #11
0
        private void addOptions(string answer1, string answer2, string answer3, string answer4, IPdfFont font, PdfGrid mainTable)
        {
            var optionsTable = new PdfGrid(numColumns: 2)
            {
                RunDirection = (int)_pdfRunDirection,
                WidthPercentage = 100,
            };

            //---------------- row - 1
            optionsTable.AddCell(new PdfPCell(font.FontSelector.Process("a) " + answer1))
            {
                Border = 0,
                Padding = 5
            });
            optionsTable.AddCell(new PdfPCell(font.FontSelector.Process("b) " + answer2))
            {
                Border = 0,
                Padding = 5
            });

            //---------------- row - 2
            optionsTable.AddCell(new PdfPCell(font.FontSelector.Process("c) " + answer3))
            {
                Border = 0,
                Padding = 5
            });
            optionsTable.AddCell(new PdfPCell(font.FontSelector.Process("d) " + answer4))
            {
                Border = 0,
                Padding = 5
            });
            mainTable.AddCell(new PdfPCell(optionsTable) { Border = 0 });
        }
コード例 #12
0
 private static void addQuestionText(string id, string questionText, IPdfFont font, PdfGrid mainTable)
 {
     mainTable.AddCell(new PdfPCell(font.FontSelector.Process(id + ") " + questionText))
     {
         Border = 0,
         Padding = 5,
         Colspan = 2
     });
 }
コード例 #13
0
        private PdfGrid createTable(string html)
        {
            var table = new PdfGrid(1)
            {
                RunDirection = (int)FooterProperties.RunDirection,
                WidthPercentage = FooterProperties.TableWidthPercentage
            };
            var htmlCell = new XmlWorkerHelper
            {
                Html = html,
                RunDirection = FooterProperties.RunDirection,
                InlineCss = FooterProperties.InlineCss,
                ImagesPath = FooterProperties.ImagesPath,
                CssFilesPath = FooterProperties.CssFilesPath,
                PdfElement = _totalPageCountImage,
                DefaultFont = FooterProperties.PdfFont.Fonts[0]
            }.RenderHtml();
            htmlCell.Border = 0;
            table.AddCell(htmlCell);

            if (FooterProperties.ShowBorder)
                return table.AddBorderToTable(FooterProperties.BorderColor, FooterProperties.SpacingBeforeTable);
            table.SpacingBefore = this.FooterProperties.SpacingBeforeTable;

            return table;
        }
コード例 #14
0
ファイル: TableHelper.cs プロジェクト: VahidN/PdfReport
 /// <summary>
 /// Creates a new PdfGrid with one column and row.
 /// </summary>
 /// <param name="phrase">An optional phrase to display</param>
 /// <param name="widthPercentage">Width of the table</param>
 /// <param name="fixedHeight">Height of the table</param>
 /// <param name="border">Border width</param>
 /// <returns>A PdfGrid</returns>
 public static PdfGrid CreateEmptyRowTable(string phrase = " ", float widthPercentage = 100, float fixedHeight = 35, int border = 0)
 {
     var table = new PdfGrid(1) { WidthPercentage = widthPercentage };
     var emptyHeaderCell = new PdfPCell(new Phrase(phrase)) { Border = border, FixedHeight = fixedHeight };
     table.AddCell(emptyHeaderCell);
     return table;
 }
コード例 #15
0
ファイル: TableHelper.cs プロジェクト: VahidN/PdfReport
        /// <summary>
        /// Creates a simple PdfGrid.
        /// </summary>
        /// <param name="columnsNumber">Number of columns</param>
        /// <param name="pdfCellAttributesList">PdfCells Attributes List</param>
        /// <param name="nullRowBackgroundColor">You can set the cells attributes to null. nullRowBackgroundColor indicates background color of these cells. Default color is white here.</param>
        /// <param name="showBorder">Indicates visibility of the table's border</param>
        /// <returns>A PdfGrid</returns>
        public static PdfGrid SimpleTable(int columnsNumber, IList<CellAttributes> pdfCellAttributesList, BaseColor nullRowBackgroundColor, bool showBorder = true)
        {
            var table = new PdfGrid(numColumns: columnsNumber) { WidthPercentage = 100 };

            for (var i = 0; i < pdfCellAttributesList.Count; i += columnsNumber)
            {
                var row = pdfCellAttributesList.Skip(i).Take(columnsNumber);
                var nonNullCells = row.Where(x => x != null).ToList();
                if (nonNullCells.Count == 1)
                {
                    //merge null cells
                    var rowCell = nonNullCells[0].CreateSafePdfPCell(new TextBlockField());
                    rowCell.Colspan = columnsNumber;
                    table.AddCell(rowCell);
                }
                else
                {
                    foreach (var cell in row)
                    {
                        var rowCell = cell == null
                            ? new PdfPCell { Border = 0, BackgroundColor = nullRowBackgroundColor }
                            : cell.CreateSafePdfPCell(new TextBlockField());
                        table.AddCell(rowCell);
                    }
                }
            }

            return showBorder ? AddBorderToTable(table) : table;
        }
コード例 #16
0
        private static PdfGrid createFooter01(PagesFooterBuilder footer, string date, FooterData data)
        {
            string szMsg = "";
            Paragraph title = null;

            Font times01 = FontFactory.GetFont("helvetica-bold", 10, BaseColor.BLACK);
            Font times02 = FontFactory.GetFont("helvetica-bold", 10, Font.ITALIC, BaseColor.BLACK);
            Font times03 = FontFactory.GetFont("helvetica-bold", 10, Font.UNDERLINE, BaseColor.BLACK);
            Font times04 = FontFactory.GetFont("helvetica", 10, BaseColor.BLACK);
            Font times05 = FontFactory.GetFont("helvetica", 10, Font.UNDERLINE, BaseColor.BLACK);
            Font times06 = FontFactory.GetFont("helvetica", 8, BaseColor.BLACK);

            var table = new PdfGrid(numColumns: 4)
            {
                WidthPercentage = 100,
                RunDirection = PdfWriter.RUN_DIRECTION_LTR
            };

            PdfPCell nestingcell = null;
            PdfPCell hlpCel = null;

            //First Row Sales Amount
            PdfPTable nested = new PdfPTable(numColumns: 3);
            nested.SetTotalWidth(new float[] { 390.6f, 83.6f, 64.2f });
            nested.LockedWidth = true;

            szMsg = string.Format("Notes:");
            title = new Paragraph(szMsg, times06);
            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_LEFT;
            nested.AddCell(hlpCel);

            szMsg = string.Format("Sales Amount:");
            title = new Paragraph(szMsg, times02);
            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_LEFT;
            nested.AddCell(hlpCel);

            szMsg = string.Format("{0}", "96.85");
            title = new Paragraph(szMsg, times02);
            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_RIGHT;
            nested.AddCell(hlpCel);

            nestingcell = new PdfPCell(nested);
            nestingcell.Colspan = 4;
            nestingcell.RunDirection = PdfWriter.RUN_DIRECTION_LTR;
            nestingcell.BorderWidthLeft = 0;
            nestingcell.BorderWidthRight = 0;
            nestingcell.BorderWidthTop = 0;
            nestingcell.BorderWidthBottom = 0;
            nestingcell.Padding = 0;
            //BorderColorTop = new BaseColor(System.Drawing.Color.LightGray),
            nestingcell.HorizontalAlignment = Element.ALIGN_CENTER;
            table.AddCell(nestingcell);

            //Second Row Sales Amount
            PdfPTable nested01 = new PdfPTable(numColumns: 2);
            nested01.SetTotalWidth(new float[] { 390.6f, 147.8f });
            nested01.LockedWidth = true;

            szMsg = string.Format("{0}", "The note goes here !! (Use 4 rows)");
            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_LEFT;
            nested01.AddCell(hlpCel);

            PdfPTable nested02 = new PdfPTable(numColumns: 2);
            nested02.SetTotalWidth(new float[] { 83.6f, 64.2f });
            nested02.LockedWidth = true;

            szMsg = string.Format("Tax {0} %:", " ");
            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_LEFT;
            nested02.AddCell(hlpCel);

            szMsg = string.Format("{0}", "0.00");
            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_RIGHT;
            nested02.AddCell(hlpCel);

            szMsg = string.Format("Shipping & Handling:", " ");
            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_LEFT;
            nested02.AddCell(hlpCel);

            szMsg = string.Format("{0}", "21.00");
            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_RIGHT;
            nested02.AddCell(hlpCel);

            hlpCel = new PdfPCell(nested02);
            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;
            nested01.AddCell(hlpCel);

            nestingcell = new PdfPCell(nested01);
            nestingcell.Colspan = 4;
            nestingcell.RunDirection = PdfWriter.RUN_DIRECTION_LTR;
            nestingcell.BorderWidthLeft = 0;
            nestingcell.BorderWidthRight = 0;
            nestingcell.BorderWidthTop = 0;
            nestingcell.BorderWidthBottom = 0;
            nestingcell.Padding = 0;
            //BorderColorTop = new BaseColor(System.Drawing.Color.LightGray),
            nestingcell.HorizontalAlignment = Element.ALIGN_CENTER;
            table.AddCell(nestingcell);

            //Page counter
            var datePhrase = footer.PdfFont.FontSelector.Process(date);
            var datePhrase01 = footer.PdfFont.FontSelector.Process(" ");
            var datePdfCell = new PdfPCell(datePhrase01)
            {
                RunDirection = PdfWriter.RUN_DIRECTION_LTR,
                BorderWidthLeft = 0,
                BorderWidthRight = 0,
                BorderWidthTop = 1,
                BorderWidthBottom = 0,
                Padding = 4,
                BorderColorTop = new BaseColor(System.Drawing.Color.LightGray),
                HorizontalAlignment = Element.ALIGN_CENTER
            };

            var nullPdfCell = new PdfPCell
            {
                RunDirection = PdfWriter.RUN_DIRECTION_LTR,
                BorderWidthLeft = 0,
                BorderWidthRight = 0,
                BorderWidthTop = 1,
                BorderWidthBottom = 0,
                Padding = 4,
                BorderColorTop = new BaseColor(System.Drawing.Color.LightGray),
                HorizontalAlignment = Element.ALIGN_RIGHT
            };

            var pageNumberPhrase = footer.PdfFont.FontSelector.Process("Page " + data.CurrentPageNumber + " of ");
            var pageNumberPdfCell = new PdfPCell(pageNumberPhrase)
            {
                RunDirection = PdfWriter.RUN_DIRECTION_LTR,
                BorderWidthLeft = 0,
                BorderWidthRight = 0,
                BorderWidthTop = 1,
                BorderWidthBottom = 0,
                Padding = 4,
                BorderColorTop = new BaseColor(System.Drawing.Color.LightGray),
                HorizontalAlignment = Element.ALIGN_RIGHT
            };

            var totalPagesNumberImagePdfCell = new PdfPCell(data.TotalPagesCountImage)
            {
                RunDirection = PdfWriter.RUN_DIRECTION_LTR,
                BorderWidthLeft = 0,
                BorderWidthRight = 0,
                BorderWidthTop = 1,
                BorderWidthBottom = 0,
                Padding = 4,
                PaddingLeft = 0,
                BorderColorTop = new BaseColor(System.Drawing.Color.LightGray),
                HorizontalAlignment = Element.ALIGN_LEFT
            };

            table.AddCell(datePdfCell);
            table.AddCell(nullPdfCell);
            table.AddCell(pageNumberPdfCell);
            table.AddCell(totalPagesNumberImagePdfCell);
            return table;
        }
コード例 #17
0
        private PdfGrid createTable(string html, HeaderBasicProperties basicProperties)
        {
            var table = new PdfGrid(1)
            {
                RunDirection = (int)basicProperties.RunDirection,
                WidthPercentage = basicProperties.TableWidthPercentage
            };
            var htmlCell = new HtmlWorkerHelper
            {
                PdfFont = basicProperties.PdfFont,
                HorizontalAlignment = basicProperties.HorizontalAlignment,
                Html = html,
                RunDirection = basicProperties.RunDirection,
                StyleSheet = basicProperties.StyleSheet
            }.RenderHtml();
            htmlCell.HorizontalAlignment = (int)basicProperties.HorizontalAlignment;
            htmlCell.Border = 0;
            table.AddCell(htmlCell);

            if (basicProperties.ShowBorder)
                return table.AddBorderToTable(basicProperties.BorderColor, basicProperties.SpacingBeforeTable);
            table.SpacingBefore = basicProperties.SpacingBeforeTable;

            return table;
        }
コード例 #18
0
        private PdfGrid createTable(string html, XHeaderBasicProperties basicProperties)
        {
            var table = new PdfGrid(1)
            {
                RunDirection = (int)basicProperties.RunDirection,
                WidthPercentage = basicProperties.TableWidthPercentage
            };
            var htmlCell = new XmlWorkerHelper
            {
                Html = html,
                RunDirection = basicProperties.RunDirection,
                CssFilesPath = basicProperties.CssFilesPath,
                ImagesPath = basicProperties.ImagesPath,
                InlineCss = basicProperties.InlineCss
            }.RenderHtml();
            htmlCell.Border = 0;
            table.AddCell(htmlCell);

            if (basicProperties.ShowBorder)
                return table.AddBorderToTable(basicProperties.BorderColor, basicProperties.SpacingBeforeTable);
            table.SpacingBefore = basicProperties.SpacingBeforeTable;

            return table;
        }
コード例 #19
0
ファイル: TableHelper.cs プロジェクト: VahidN/PdfReport
        private static void addSimpleRowCell(PdfGrid table, Action<CellRowData, CellBasicProperties> cellDataItem)
        {
            var cellBasicProperties = new CellBasicProperties
            {
                BorderColor = BaseColor.BLACK,
                HorizontalAlignment = HorizontalAlignment.Center,
                RunDirection = PdfRunDirection.LeftToRight,
                FontColor = new BaseColor(Color.Black.ToArgb()),
                BackgroundColor = BaseColor.WHITE,
                PdfFontStyle = DocumentFontStyle.Normal
            };
            var cellData = new CellRowData { Value = string.Empty, FormattedValue = string.Empty };

            if (cellDataItem != null)
                cellDataItem(cellData, cellBasicProperties);

            if (cellData.CellTemplate == null)
                cellData.CellTemplate = new TextBlockField();

            var cellAttributes = new CellAttributes
            {
                BasicProperties = cellBasicProperties,
                RowData = cellData
            };
            table.AddCell(cellAttributes.CreateSafePdfPCell(cellData.CellTemplate));
        }
コード例 #20
0
        private PdfGrid createTable(string html)
        {
            var table = new PdfGrid(1)
            {
                RunDirection = (int)FooterProperties.RunDirection,
                WidthPercentage = FooterProperties.TableWidthPercentage
            };
            var htmlCell = new HtmlWorkerHelper
            {
                PdfFont = FooterProperties.PdfFont,
                HorizontalAlignment = FooterProperties.HorizontalAlignment,
                Html = html,
                RunDirection = FooterProperties.RunDirection,
                StyleSheet = FooterProperties.StyleSheet,
                PdfElement = _totalPageCountImage
            }.RenderHtml();
            htmlCell.HorizontalAlignment = (int)FooterProperties.HorizontalAlignment;
            htmlCell.Border = 0;
            table.AddCell(htmlCell);

            if (FooterProperties.ShowBorder)
                return table.AddBorderToTable(FooterProperties.BorderColor, FooterProperties.SpacingBeforeTable);
            table.SpacingBefore = this.FooterProperties.SpacingBeforeTable;

            return table;
        }
コード例 #21
0
        private static PdfGrid createFooter(PagesFooterBuilder footer, string date, FooterData data)
        {
            var table = new PdfGrid(numColumns: 4)
            {
                WidthPercentage = 100,
                RunDirection = PdfWriter.RUN_DIRECTION_LTR
            };

            var datePhrase = footer.PdfFont.FontSelector.Process(date);
            var datePdfCell = new PdfPCell(datePhrase)
            {
                RunDirection = PdfWriter.RUN_DIRECTION_LTR,
                BorderWidthLeft = 0,
                BorderWidthRight = 0,
                BorderWidthTop = 1,
                BorderWidthBottom = 0,
                Padding = 4,
                BorderColorTop = new BaseColor(System.Drawing.Color.LightGray),
                HorizontalAlignment = Element.ALIGN_CENTER
            };

            var nullPdfCell = new PdfPCell
            {
                RunDirection = PdfWriter.RUN_DIRECTION_LTR,
                BorderWidthLeft = 0,
                BorderWidthRight = 0,
                BorderWidthTop = 1,
                BorderWidthBottom = 0,
                Padding = 4,
                BorderColorTop = new BaseColor(System.Drawing.Color.LightGray),
                HorizontalAlignment = Element.ALIGN_RIGHT
            };

            var pageNumberPhrase = footer.PdfFont.FontSelector.Process("Page " + data.CurrentPageNumber + " of ");
            var pageNumberPdfCell = new PdfPCell(pageNumberPhrase)
            {
                RunDirection = PdfWriter.RUN_DIRECTION_LTR,
                BorderWidthLeft = 0,
                BorderWidthRight = 0,
                BorderWidthTop = 1,
                BorderWidthBottom = 0,
                Padding = 4,
                BorderColorTop = new BaseColor(System.Drawing.Color.LightGray),
                HorizontalAlignment = Element.ALIGN_RIGHT
            };

            var totalPagesNumberImagePdfCell = new PdfPCell(data.TotalPagesCountImage)
            {
                RunDirection = PdfWriter.RUN_DIRECTION_LTR,
                BorderWidthLeft = 0,
                BorderWidthRight = 0,
                BorderWidthTop = 1,
                BorderWidthBottom = 0,
                Padding = 4,
                PaddingLeft = 0,
                BorderColorTop = new BaseColor(System.Drawing.Color.LightGray),
                HorizontalAlignment = Element.ALIGN_LEFT
            };

            table.AddCell(datePdfCell);
            table.AddCell(nullPdfCell);
            table.AddCell(pageNumberPdfCell);
            table.AddCell(totalPagesNumberImagePdfCell);
            return table;
        }
コード例 #22
0
        /// <summary>
        /// Fires when a page is finished, just before being written to the document.
        /// </summary>
        /// <param name="writer">PdfWriter</param>
        /// <param name="document">PDF Document</param>
        /// <param name="columnCellsSummaryData">List of all rows summaries data</param>
        public void PageFinished(PdfWriter writer, Document document, IList<SummaryCellData> columnCellsSummaryData)
        {
            var footerTable = AddPageFooter(new FooterData
            {
                PdfDoc = document,
                PdfWriter = writer,
                SummaryData = columnCellsSummaryData,
                CurrentPageNumber = writer.PageNumber,
                TotalPagesCountImage = _totalPageCountImage
            });

            var table = new PdfGrid(1)
            {
                RunDirection = (int)FooterProperties.RunDirection,
                WidthPercentage = FooterProperties.TableWidthPercentage
            };
            var tableCell = new PdfPCell(footerTable) { Border = 0 };
            table.AddCell(tableCell);

            var page = document.PageSize;
            table.SetTotalWidth(new[] { page.Width - document.LeftMargin - document.RightMargin });
            table.WriteSelectedRows(
                    rowStart: 0,
                    rowEnd: -1,
                    xPos: document.LeftMargin,
                    yPos: document.BottomMargin - FooterProperties.SpacingBeforeTable,
                    canvas: writer.DirectContent);
        }
コード例 #23
0
        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;
        }
コード例 #24
0
ファイル: GroupingPdfReport.cs プロジェクト: VahidN/PdfReport
        public IPdfReportData CreatePdfReport()
        {
            return new PdfReport().DocumentPreferences(doc =>
            {
                doc.RunDirection(PdfRunDirection.LeftToRight);
                doc.Orientation(PageOrientation.Portrait);
                doc.PageSize(PdfPageSize.A4);
                doc.DocumentMetadata(new DocumentMetadata { Author = "Vahid", Application = "PdfRpt", Keywords = "Test", Subject = "Test Rpt", Title = "Test" });
                doc.Compression(new CompressionSettings
                {
                    EnableCompression = true,
                    EnableFullCompression = true
                });
            })
             .DefaultFonts(fonts =>
             {
                 fonts.Path(System.IO.Path.Combine(Environment.GetEnvironmentVariable("SystemRoot"), "fonts\\arial.ttf"),
                            System.IO.Path.Combine(Environment.GetEnvironmentVariable("SystemRoot"), "fonts\\verdana.ttf"));
                 fonts.Size(9);
                 fonts.Color(System.Drawing.Color.Black);
             })
             .PagesFooter(footer =>
             {
                 footer.DefaultFooter(DateTime.Now.ToString("MM/dd/yyyy"));
             })
             .PagesHeader(header =>
             {
                 header.CacheHeader(cache: true); // It's a default setting to improve the performance.
                 header.CustomHeader(new GroupingHeaders { PdfRptFont = header.PdfFont });
             })
             .MainTableTemplate(template =>
             {
                 template.BasicTemplate(BasicTemplate.SilverTemplate);
             })
             .MainTablePreferences(table =>
             {
                 table.ColumnsWidthsType(TableColumnWidthType.Relative);
                 table.GroupsPreferences(new GroupsPreferences
                 {
                     GroupType = GroupType.HideGroupingColumns,
                     RepeatHeaderRowPerGroup = true,
                     ShowOneGroupPerPage = false,
                     SpacingBeforeAllGroupsSummary = 5f,
                     NewGroupAvailableSpacingThreshold = 150,
                     SpacingAfterAllGroupsSummary = 5f
                 });
                 table.SpacingAfter(4f);
             })
             .MainTableDataSource(dataSource =>
             {
                 var listOfRows = new List<Employee>();
                 var rnd = new Random();
                 for (int i = 0; i < 170; i++)
                 {
                     listOfRows.Add(
                         new Employee
                         {
                             Age = rnd.Next(25, 35),
                             Id = i + 1000,
                             Salary = rnd.Next(1000, 4000),
                             Name = "Employee " + i,
                             Department = "Department " + rnd.Next(1, 3)
                         });
                 }

                 listOfRows = listOfRows.OrderBy(x => x.Department).ThenBy(x => x.Age).ToList();
                 dataSource.StronglyTypedList(listOfRows);
             })
             .MainTableSummarySettings(summarySettings =>
             {
                 summarySettings.PreviousPageSummarySettings("Cont.");
                 summarySettings.OverallSummarySettings("Sum");
                 summarySettings.AllGroupsSummarySettings("Groups Sum");
             })
             .MainTableColumns(columns =>
             {
                 columns.AddColumn(column =>
                 {
                     column.PropertyName("rowNo");
                     column.IsRowNumber(true);
                     column.CellsHorizontalAlignment(HorizontalAlignment.Center);
                     column.IsVisible(true);
                     column.Order(0);
                     column.Width(20);
                     column.HeaderCell("#");
                 });

                 columns.AddColumn(column =>
                 {
                     column.PropertyName<Employee>(x => x.Department);
                     column.CellsHorizontalAlignment(HorizontalAlignment.Center);
                     column.Order(1);
                     column.Width(20);
                     column.HeaderCell("Department");
                     column.Group(
                     (val1, val2) =>
                     {
                         return val1.ToString() == val2.ToString();
                     });
                 });

                 columns.AddColumn(column =>
                 {
                     column.PropertyName<Employee>(x => x.Age);
                     column.CellsHorizontalAlignment(HorizontalAlignment.Center);
                     column.Order(2);
                     column.Width(20);
                     column.HeaderCell("Age");
                     column.Group(
                     (val1, val2) =>
                     {
                         return (int)val1 == (int)val2;
                     });
                 });

                 columns.AddColumn(column =>
                 {
                     column.PropertyName<Employee>(x => x.Id);
                     column.CellsHorizontalAlignment(HorizontalAlignment.Center);
                     column.IsVisible(true);
                     column.Order(3);
                     column.Width(20);
                     column.HeaderCell("Id");
                 });

                 columns.AddColumn(column =>
                 {
                     column.PropertyName<Employee>(x => x.Name);
                     column.CellsHorizontalAlignment(HorizontalAlignment.Center);
                     column.IsVisible(true);
                     column.Order(4);
                     column.Width(20);
                     column.HeaderCell("Name");
                 });

                 columns.AddColumn(column =>
                 {
                     column.PropertyName<Employee>(x => x.Salary);
                     column.CellsHorizontalAlignment(HorizontalAlignment.Center);
                     column.IsVisible(true);
                     column.Order(5);
                     column.Width(20);
                     column.HeaderCell("Salary");
                     column.ColumnItemsTemplate(template =>
                     {
                         template.TextBlock();
                         template.DisplayFormatFormula(obj => obj == null || string.IsNullOrEmpty(obj.ToString())
                                                            ? string.Empty : string.Format("{0:n0}", obj));
                     });
                     column.AggregateFunction(aggregateFunction =>
                     {
                         aggregateFunction.NumericAggregateFunction(AggregateFunction.Sum);
                         aggregateFunction.DisplayFormatFormula(obj => obj == null || string.IsNullOrEmpty(obj.ToString())
                                                            ? string.Empty : string.Format("{0:n0}", obj));
                     });
                 });
             })
             .MainTableEvents(events =>
             {
                 events.DataSourceIsEmpty(message: "There is no data available to display.");
                 events.GroupAdded(args =>
                     {
                         //args.PdfDoc.Add(new Phrase("\nGroup added event."));

                         /*var data = args.ColumnCellsSummaryData
                             .Where(data => data.CellData.PropertyName.Equals("propertyName")
                                    && data.GroupNumber == 1);*/

                         var salary = args.LastOverallAggregateValueOf<Employee>(x => x.Salary);
                         var table = new PdfGrid(1)
                         {
                             RunDirection = (int)PdfRunDirection.LeftToRight,
                             WidthPercentage = args.PageSetup.MainTablePreferences.WidthPercentage
                         };
                         var htmlCell = new XmlWorkerHelper
                         {
                             // the registered fonts (DefaultFonts section) should be specified here
                             Html = string.Format(@"<br/><span style='font-size:9pt;font-family:verdana;'>
                                                    <b>Group <i>added</i> event.</b>
                                                    Total Salary: {0}</span>", salary),
                             RunDirection = PdfRunDirection.LeftToRight,
                             CssFilesPath = null, // optional
                             ImagesPath = null, // optional
                             InlineCss = null, // optional
                             DefaultFont = args.PdfFont.Fonts[1] // verdana
                         }.RenderHtml();
                         htmlCell.Border = 0;
                         table.AddCell(htmlCell);
                         table.SpacingBefore = args.PageSetup.MainTablePreferences.SpacingBefore;

                         args.PdfDoc.Add(table);
                     });
             })
             .Export(export =>
             {
                 export.ToExcel();
             })
             .Generate(data => data.AsPdfFile(string.Format("{0}\\Pdf\\RptGroupingSample-{1}.pdf", AppPath.ApplicationPath, Guid.NewGuid().ToString("N"))));
        }
コード例 #25
0
        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;
        }