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

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

public SplitRow ( PdfPTable table, int rowIndex, float new_height ) : PdfPRow
table PdfPTable
rowIndex int
new_height float
Результат PdfPRow
        public PdfPRow SplitRow(PdfPTable table, int rowIndex, float new_height)
        {
            LOGGER.Info("Splitting " + rowIndex + " " + new_height);
            // second part of the row
            PdfPCell[] newCells = new PdfPCell[cells.Length];
            float[] fixHs = new float[cells.Length];
            float[] minHs = new float[cells.Length];
            bool allEmpty = true;
            // loop over all the cells
            for (int k = 0; k < cells.Length; ++k) {
                float newHeight = new_height;
                PdfPCell cell = cells[k];
                if (cell == null) {
                    int index = rowIndex;
                    if (table.RowSpanAbove(index, k)) {
                        while (table.RowSpanAbove(--index, k)) {
                            newHeight += table.GetRow(index).MaxHeights;
                        }
                        PdfPRow row = table.GetRow(index);
                        if (row != null && row.GetCells()[k] != null) {
                            newCells[k] = new PdfPCell(row.GetCells()[k]);
                            newCells[k].Column = null;
                            newCells[k].Rowspan = row.GetCells()[k].Rowspan - rowIndex + index;
                            allEmpty = false;
                        }
                    }
                    continue;
                }
                fixHs[k] = cell.FixedHeight;
                minHs[k] = cell.MinimumHeight;
                Image img = cell.Image;
                PdfPCell newCell = new PdfPCell(cell);
                if (img != null) {
                    float padding = cell.EffectivePaddingBottom + cell.EffectivePaddingTop + 2;
                    if ((img.ScaleToFitLineWhenOverflow || img.ScaledHeight + padding < newHeight)
                        && newHeight > padding) {
                        newCell.Phrase = null;
                        allEmpty = false;
                    }
                }
                else {
                    float y;
                    ColumnText ct = ColumnText.Duplicate(cell.Column);
                    float left = cell.Left + cell.EffectivePaddingLeft;
                    float bottom = cell.Top + cell.EffectivePaddingBottom - newHeight;
                    float right = cell.Right - cell.EffectivePaddingRight;
                    float top = cell.Top - cell.EffectivePaddingTop;
                    switch (cell.Rotation) {
                        case 90:
                        case 270:
                            y = SetColumn(ct, bottom, left, top, right);
                            break;
                        default:
                            y = SetColumn(ct, left, bottom + 0.00001f, cell.NoWrap ? RIGHT_LIMIT : right, top);
                            break;
                    }
                    int status;
                    status = ct.Go(true);
                    bool thisEmpty = (ct.YLine == y);
                    if (thisEmpty) {
                        newCell.Column = ColumnText.Duplicate(cell.Column);
                        ct.FilledWidth = 0;
                    }
                    else if ((status & ColumnText.NO_MORE_TEXT) == 0) {
                        newCell.Column = ct;
                        ct.FilledWidth = 0;
                    }
                    else
                        newCell.Phrase = null;
                    allEmpty = (allEmpty && thisEmpty);
                }
                newCells[k] = newCell;
                cell.FixedHeight = newHeight;
            }
            if (allEmpty) {
                for (int k = 0; k < cells.Length; ++k) {
                    PdfPCell cell = cells[k];
                    if (cell == null)
                        continue;
                    if (fixHs[k] > 0)
                        cell.FixedHeight = fixHs[k];
                    else
                        cell.MinimumHeight = minHs[k];
                }
                return null;
            }
            CalculateHeights();
            PdfPRow split = new PdfPRow(newCells);
            split.widths = (float[]) widths.Clone();
            return split;
        }