示例#1
0
        public void visit(TDocumentTable table)
        {
            this.table_temp = new PdfPTable(column_count);

            PdfPCell cell = new PdfPCell(new Phrase("Header spanning 3 columns"));

            cell.Colspan             = column_count;
            cell.HorizontalAlignment = 1; //0=Left, 1=Centre, 2=Right
            table_temp.AddCell(cell);

            for (int x = 0; x < table.RowCount; x++)
            {
                try
                {
                    table.DocumentElements[x].accept(this);
                }
                catch (Exception ex)
                {
                    Console.Error.WriteLine(ex.Message);
                }
            }
        }
示例#2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="table"></param>
        public void visit(TDocumentTable table)
        {
            StringBuilder CHTML   = new StringBuilder("<TABLE ");
            string        bgColor = table.BackgroundColor;

            if (bgColor != null)
            {
                CHTML.Append(" bgcolor=" + bgColor + " ");
            }
            int _width = table.Width;

            if (_width > 0)
            {
                CHTML.Append(" WIDTH=" + _width);
                if (table.PercentageWidth)
                {
                    CHTML.Append("% ");
                }
                else
                {
                    CHTML.Append(" ");
                }
            }

            if (table.Border > -1)
            {
                CHTML.Append(" BORDER=" + table.Border);
            }

            if (table.Cellpadding > -1)
            {
                CHTML.Append(" CELLSPACING=" + table.Cellpadding);
            }



            string color = table.BackgroundColor;

            if (color != null)
            {
                CHTML.Append(" BGCOLOR=\"" + color + "\" ");
            }
            CHTML.Append(">\n");

            string _caption = table.Caption;

            if (_caption != null)
            {
                CHTML.Append("\n<CAPTION>" + _caption + " </CAPTION>\n");
            }
            document.Append(CHTML.ToString());
            for (int x = 0; x < table.DocumentElements.Count; x++)
            {
                try
                {
                    ((TDocumentElement)table.DocumentElements[x]).accept(this);
                }
                catch (Exception ex)
                {
                    Console.Error.WriteLine(ex.Message);
                }
            }
            document.Append("\n</TABLE>");
        }