Exemplo n.º 1
0
        protected internal void RenderCells(RenderingContext ctx, ArrayList cells, bool hasToFit)
        {
            if (hasToFit) {
                foreach (PdfCell cell in cells) {
                    if (!cell.Header) {
                        if (cell.Bottom < IndentBottom) return;
                    }
                }
            }
            foreach (PdfCell cell in cells) {
                if (!ctx.IsCellRenderedOnPage(cell, PageNumber)) {

                    float correction = 0;
                    if (ctx.NumCellRendered(cell) >= 1) {
                        correction = 1.0f;
                    }

                    lines = cell.GetLines(ctx.pagetop, IndentBottom - correction);

                    // if there is still text to render we render it
                    if (lines != null && lines.Count > 0) {

                        // we write the text
                        float cellTop = cell.GetTop(ctx.pagetop - ctx.oldHeight);
                        text.MoveText(0, cellTop);
                        float cellDisplacement = FlushLines() - cellTop;

                        text.MoveText(0, cellDisplacement);
                        if (ctx.oldHeight + cellDisplacement > currentHeight) {
                            currentHeight = ctx.oldHeight + cellDisplacement;
                        }

                        ctx.CellRendered(cell, PageNumber);
                    }

                    float indentBottom = Math.Max(cell.Bottom, IndentBottom);

                    Rectangle tableRect = ctx.table.GetRectangle(ctx.pagetop, IndentBottom);

                    indentBottom = Math.Max(tableRect.Bottom, indentBottom);

                    // we paint the borders of the cells
                    Rectangle cellRect = cell.GetRectangle(tableRect.Top, indentBottom);
                    //cellRect.Bottom = cellRect.Bottom;
                    if (cellRect.Height > 0) {
                        ctx.lostTableBottom = indentBottom;
                        ctx.cellGraphics.Rectangle(cellRect);
                    }

                    // and additional graphics
                    ArrayList images = cell.GetImages(ctx.pagetop, IndentBottom);
                    foreach (Image image in images) {
                        graphics.AddImage(image);
                    }
                }
            }
        }