iTextSharp.text.pdf.PdfPRow.SetWidths C# (CSharp) Метод

SetWidths() публичный Метод

public SetWidths ( float widths ) : bool
widths float
Результат bool
        public bool SetWidths(float[] widths)
        {
            if (widths.Length != cells.Length)
                return false;
            System.Array.Copy(widths, 0, this.widths, 0, cells.Length);
            float total = 0;
            calculated = false;
            for (int k = 0; k < widths.Length; ++k) {
                PdfPCell cell = cells[k];

                if (cell == null) {
                    total += widths[k];
                    continue;
                }

                cell.Left = total;
                int last = k + cell.Colspan;
                for (; k < last; ++k)
                    total += widths[k];
                --k;
                cell.Right = total;
                cell.Top = 0;
            }
            return true;
        }

Usage Example

Пример #1
0
        /** Adds a cell element.
         * @param cell the cell element
         */
        public void AddCell(PdfPCell cell)
        {
            PdfPCell ncell   = new PdfPCell(cell);
            int      colspan = ncell.Colspan;

            colspan       = Math.Max(colspan, 1);
            colspan       = Math.Min(colspan, currentRow.Length - currentRowIdx);
            ncell.Colspan = colspan;
            if (colspan != 1)
            {
                isColspan = true;
            }
            int rdir = ncell.RunDirection;

            if (rdir == PdfWriter.RUN_DIRECTION_DEFAULT)
            {
                ncell.RunDirection = runDirection;
            }
            currentRow[currentRowIdx] = ncell;
            currentRowIdx            += colspan;
            if (currentRowIdx >= currentRow.Length)
            {
                if (runDirection == PdfWriter.RUN_DIRECTION_RTL)
                {
                    PdfPCell[] rtlRow = new PdfPCell[absoluteWidths.Length];
                    int        rev    = currentRow.Length;
                    for (int k = 0; k < currentRow.Length; ++k)
                    {
                        PdfPCell rcell = currentRow[k];
                        int      cspan = rcell.Colspan;
                        rev        -= cspan;
                        rtlRow[rev] = rcell;
                        k          += cspan - 1;
                    }
                    currentRow = rtlRow;
                }
                PdfPRow row = new PdfPRow(currentRow);
                if (totalWidth > 0)
                {
                    row.SetWidths(absoluteWidths);
                    totalHeight += row.MaxHeights;
                }
                rows.Add(row);
                currentRow    = new PdfPCell[absoluteWidths.Length];
                currentRowIdx = 0;
            }
        }
All Usage Examples Of iTextSharp.text.pdf.PdfPRow::SetWidths