/** * @param rectangle * @param spacing * @return a rectangle */ public static SimpleCell GetDimensionlessInstance(Rectangle rectangle, float spacing) { SimpleCell cell = new SimpleCell(CELL); cell.CloneNonPositionParameters(rectangle); cell.Spacing = spacing * 2; return(cell); }
/** * Creates a PdfPCell with these attributes. * @param rowAttributes * @return a PdfPCell based on these attributes. */ public PdfPCell CreatePdfPCell(SimpleCell rowAttributes) { PdfPCell cell = new PdfPCell(); cell.Border = NO_BORDER; SimpleCell tmp = new SimpleCell(CELL); tmp.Spacing_left = spacing_left; tmp.Spacing_right = spacing_right; tmp.Spacing_top = spacing_top; tmp.Spacing_bottom = spacing_bottom; tmp.CloneNonPositionParameters(rowAttributes); tmp.SoftCloneNonPositionParameters(this); cell.CellEvent = tmp; cell.HorizontalAlignment = rowAttributes.horizontalAlignment; cell.VerticalAlignment = rowAttributes.verticalAlignment; cell.UseAscender = rowAttributes.useAscender; cell.UseBorderPadding = rowAttributes.useBorderPadding; cell.UseDescender = rowAttributes.useDescender; cell.Colspan = colspan; if (horizontalAlignment != Element.ALIGN_UNDEFINED) cell.HorizontalAlignment = horizontalAlignment; if (verticalAlignment != Element.ALIGN_UNDEFINED) cell.VerticalAlignment = verticalAlignment; if (useAscender) cell.UseAscender = useAscender; if (useBorderPadding) cell.UseBorderPadding = useBorderPadding; if (useDescender) cell.UseDescender = useDescender; float p; float sp_left = spacing_left; if (float.IsNaN(sp_left)) sp_left = 0f; float sp_right = spacing_right; if (float.IsNaN(sp_right)) sp_right = 0f; float sp_top = spacing_top; if (float.IsNaN(sp_top)) sp_top = 0f; float sp_bottom = spacing_bottom; if (float.IsNaN(sp_bottom)) sp_bottom = 0f; p = padding_left; if (float.IsNaN(p)) p = 0f; cell.PaddingLeft = p + sp_left; p = padding_right; if (float.IsNaN(p)) p = 0f; cell.PaddingRight = p + sp_right; p = padding_top; if (float.IsNaN(p)) p = 0f; cell.PaddingTop = p + sp_top; p = padding_bottom; if (float.IsNaN(p)) p = 0f; cell.PaddingBottom = p + sp_bottom; foreach (IElement element in content) { cell.AddElement(element); } return cell; }
/** * Creates a PdfPCell with these attributes. * @param rowAttributes * @return a PdfPCell based on these attributes. */ public PdfPCell CreatePdfPCell(SimpleCell rowAttributes) { PdfPCell cell = new PdfPCell(); cell.Border = NO_BORDER; SimpleCell tmp = new SimpleCell(CELL); tmp.Spacing_left = spacing_left; tmp.Spacing_right = spacing_right; tmp.Spacing_top = spacing_top; tmp.Spacing_bottom = spacing_bottom; tmp.CloneNonPositionParameters(rowAttributes); tmp.SoftCloneNonPositionParameters(this); cell.CellEvent = tmp; cell.HorizontalAlignment = rowAttributes.horizontalAlignment; cell.VerticalAlignment = rowAttributes.verticalAlignment; cell.UseAscender = rowAttributes.useAscender; cell.UseBorderPadding = rowAttributes.useBorderPadding; cell.UseDescender = rowAttributes.useDescender; cell.Colspan = colspan; if (horizontalAlignment != Element.ALIGN_UNDEFINED) { cell.HorizontalAlignment = horizontalAlignment; } if (verticalAlignment != Element.ALIGN_UNDEFINED) { cell.VerticalAlignment = verticalAlignment; } if (useAscender) { cell.UseAscender = useAscender; } if (useBorderPadding) { cell.UseBorderPadding = useBorderPadding; } if (useDescender) { cell.UseDescender = useDescender; } float p; float sp_left = spacing_left; if (float.IsNaN(sp_left)) { sp_left = 0f; } float sp_right = spacing_right; if (float.IsNaN(sp_right)) { sp_right = 0f; } float sp_top = spacing_top; if (float.IsNaN(sp_top)) { sp_top = 0f; } float sp_bottom = spacing_bottom; if (float.IsNaN(sp_bottom)) { sp_bottom = 0f; } p = padding_left; if (float.IsNaN(p)) { p = 0f; } cell.PaddingLeft = p + sp_left; p = padding_right; if (float.IsNaN(p)) { p = 0f; } cell.PaddingRight = p + sp_right; p = padding_top; if (float.IsNaN(p)) { p = 0f; } cell.PaddingTop = p + sp_top; p = padding_bottom; if (float.IsNaN(p)) { p = 0f; } cell.PaddingBottom = p + sp_bottom; foreach (IElement element in content) { cell.AddElement(element); } return(cell); }
/** * Create a PdfPTable based on this Table object. * @return a PdfPTable object * @throws BadElementException */ public PdfPTable CreatePdfPTable() { if (!convert2pdfptable) { throw new BadElementException("No error, just an old style table"); } AutoFillEmptyCells = true; Complete(); PdfPTable pdfptable = new PdfPTable(widths); pdfptable.ElementComplete = complete; if (NotAddedYet) pdfptable.SkipFirstHeader = true; SimpleTable t_evt = new SimpleTable(); t_evt.CloneNonPositionParameters(this); t_evt.Cellspacing = cellspacing; pdfptable.TableEvent = t_evt; pdfptable.HeaderRows = lastHeaderRow + 1; pdfptable.SplitLate = cellsFitPage; pdfptable.KeepTogether = tableFitsPage; if (!float.IsNaN(offset)) { pdfptable.SpacingBefore = offset; } pdfptable.HorizontalAlignment = alignment; if (locked) { pdfptable.TotalWidth = width; pdfptable.LockedWidth = true; } else { pdfptable.WidthPercentage = width; } foreach (Row row in this) { IElement cell; PdfPCell pcell; for (int i = 0; i < row.Columns; i++) { if ((cell = (IElement)row.GetCell(i)) != null) { if (cell is Table) { pcell = new PdfPCell(((Table)cell).CreatePdfPTable()); } else if (cell is Cell) { pcell = ((Cell)cell).CreatePdfPCell(); pcell.Padding = cellpadding + cellspacing / 2f; SimpleCell c_evt = new SimpleCell(SimpleCell.CELL); c_evt.CloneNonPositionParameters((Cell)cell); c_evt.Spacing = cellspacing * 2f; pcell.CellEvent = c_evt; } else { pcell = new PdfPCell(); } pdfptable.AddCell(pcell); } } } return pdfptable; }
/** * @param rectangle * @param spacing * @return a rectangle */ public static SimpleCell GetDimensionlessInstance(Rectangle rectangle, float spacing) { SimpleCell cell = new SimpleCell(CELL); cell.CloneNonPositionParameters(rectangle); cell.Spacing = spacing * 2; return cell; }