상속: IElement
예제 #1
0
        /**
         * Gets the TableWrapper from the Stack and adds a new row.
         * @since 5.0.6
         */
        public void ProcessRow()
        {
            List <PdfPCell> row        = new List <PdfPCell>();
            List <float>    cellWidths = new List <float>();
            bool            percentage = false;
            float           width;
            float           totalWidth = 0;
            int             zeroWidth  = 0;
            TableWrapper    table      = null;

            while (true)
            {
                IElement obj = stack.Pop();
                if (obj is CellWrapper)
                {
                    CellWrapper cell = (CellWrapper)obj;
                    width = cell.Width;
                    cellWidths.Add(width);
                    percentage |= cell.IsPercentage;
                    if (width == 0)
                    {
                        zeroWidth++;
                    }
                    else
                    {
                        totalWidth += width;
                    }
                    row.Add(cell.Cell);
                }
                if (obj is TableWrapper)
                {
                    table = (TableWrapper)obj;
                    break;
                }
            }
            table.AddRow(row);
            if (cellWidths.Count > 0)
            {
                // cells come off the stack in reverse, naturally
                totalWidth = 100 - totalWidth;
                cellWidths.Reverse();
                float[] widths = new float[cellWidths.Count];
                for (int i = 0; i < widths.Length; i++)
                {
                    widths[i] = cellWidths[i];
                    if (widths[i] == 0 && percentage && zeroWidth > 0)
                    {
                        widths[i] = totalWidth / zeroWidth;
                    }
                }
                table.ColWidths = widths;
            }
            stack.Push(table);
        }
예제 #2
0
            /**
             * @throws DocumentException
             * @see com.itextpdf.text.html.simpleparser.HTMLTagProcessors#startElement(com.itextpdf.text.html.simpleparser.HTMLWorker, java.lang.String, java.util.Map)
             */
            public void StartElement(HTMLWorker worker, String tag, IDictionary <String, String> attrs)
            {
                worker.CarriageReturn();
                TableWrapper table = new TableWrapper(attrs);

                worker.PushToStack(table);
                worker.PushTableState();
                worker.SetPendingTD(false);
                worker.SetPendingTR(false);
                worker.SetSkipText(true);
                // Table alignment should not affect children elements, thus remove
                attrs.Remove(HtmlTags.ALIGN);
                worker.UpdateChain(tag, attrs);
            }
예제 #3
0
        /**
         * Processes the Table.
         * @throws DocumentException
         * @since 5.0.6
         */
        virtual public void ProcessTable()
        {
            TableWrapper table = (TableWrapper)stack.Pop();
            PdfPTable    tb    = table.CreateTable();

            if (stack.Count == 0)
            {
                document.Add(tb);
            }
            else
            {
                ((ITextElementArray)stack.Peek()).Add(tb);
            }
        }
예제 #4
0
            /**
             * @throws DocumentException
             * @see com.itextpdf.text.html.simpleparser.HTMLTagProcessors#startElement(com.itextpdf.text.html.simpleparser.HTMLWorker, java.lang.String, java.util.Map)
             */
            virtual public void StartElement(HTMLWorker worker, String tag, IDictionary <String, String> attrs)
            {
                worker.CarriageReturn();
                TableWrapper table = new TableWrapper(attrs);

                worker.PushToStack(table);
                worker.PushTableState();
                worker.SetPendingTD(false);
                worker.SetPendingTR(false);
                worker.SetSkipText(true);
                // Table alignment should not affect children elements, thus remove
                attrs.Remove(HtmlTags.ALIGN);
                // In case this is a nested table reset colspan and rowspan
                attrs[HtmlTags.COLSPAN] = "1";
                attrs[HtmlTags.ROWSPAN] = "1";
                worker.UpdateChain(tag, attrs);
            }