// // public static SimplePersonsList GetInstance(Selection selection, // Rectangle pageSize, // string reportFile) { // // if (instance == null) // instance = new SimplePersonsList(selection, pageSize, reportFile); // else { // instance.selection = selection; // instance.reportFile = reportFile; // } // // if (!this.doc.IsOpen()) // this.doc.Open(); // // return instance; // } public override void MakeReport() { Table t = new Table(3); t.Border = 0; t.DefaultCellBorder = 0; Cell cell = new Cell(); cell.HorizontalAlignment = Element.ALIGN_CENTER; t.DefaultCell = cell; // Default cell Font fuenteTitulo = FontFactory.GetFont(FontFactory.HELVETICA_OBLIQUE, 14, Font.UNDERLINE); cell = new Cell(); Chunk texto = new Chunk("Apellido", fuenteTitulo); cell.Add(texto); t.AddCell(cell); cell = new Cell(); texto = new Chunk("Nombre", fuenteTitulo); cell.Add(texto); t.AddCell(cell); cell = new Cell(); texto = new Chunk("E-Mail", fuenteTitulo); cell.Add(texto); t.AddCell(cell); Font fuenteDatos = FontFactory.GetFont(FontFactory.HELVETICA, 10); foreach (Person p in this.selection.Persons) { cell = new Cell(); texto = new Chunk(p.Surname, fuenteDatos); cell.Add(texto); t.AddCell(cell); cell = new Cell(); texto = new Chunk(p.Name, fuenteDatos); cell.Add(texto); t.AddCell(cell); cell = new Cell(); texto = new Chunk(p.EMail, fuenteDatos); cell.Add(texto); t.AddCell(cell); } this.doc.Add(t); }
// methods to set the membervariables /** * Adds an element to this Cell. * <P> * Remark: you can't add ListItems, Rows, Cells, * JPEGs, GIFs or PNGs to a Cell. * * @param element The Element to add * @throws BadElementException if the method was called with a ListItem, Row or Cell */ /// <summary> /// Adds an element to this Cell. /// </summary> /// <remarks> /// You can't add ListItems, Rows, Cells, /// JPEGs, GIFs or PNGs to a Cell. /// </remarks> /// <param name="element">the Element to add</param> public void AddElement(IElement element) { if (IsTable()) { Table table = (Table)arrayList[0]; Cell tmp = new Cell(element); tmp.Border = NO_BORDER; tmp.Colspan = table.Columns; table.AddCell(tmp); return; } switch (element.Type) { case Element.LISTITEM: case Element.ROW: case Element.CELL: throw new BadElementException("You can't add listitems, rows or cells to a cell."); case Element.JPEG: case Element.IMGRAW: case Element.IMGTEMPLATE: arrayList.Add(element); break; case Element.LIST: if (float.IsNaN(this.Leading)) { leading = ((List)element).TotalLeading; } if (((List)element).IsEmpty()) { return; } arrayList.Add(element); return; case Element.ANCHOR: case Element.PARAGRAPH: case Element.PHRASE: if (float.IsNaN(leading)) { leading = ((Phrase)element).Leading; } if (((Phrase)element).IsEmpty()) { return; } arrayList.Add(element); return; case Element.CHUNK: if (((Chunk)element).IsEmpty()) { return; } arrayList.Add(element); return; case Element.TABLE: Table table = new Table(3); float[] widths = new float[3]; widths[1] = ((Table)element).Width; switch (((Table)element).Alignment) { case Element.ALIGN_LEFT: widths[0] = 0f; widths[2] = 100f - widths[1]; break; case Element.ALIGN_CENTER: widths[0] = (100f - widths[1]) / 2f; widths[2] = widths[0]; break; case Element.ALIGN_RIGHT: widths[0] = 100f - widths[1]; widths[2] = 0f; break; } table.Widths = widths; Cell tmp; if (arrayList.Count == 0) { table.AddCell(Cell.DummyCell); } else { tmp = new Cell(); tmp.Border = NO_BORDER; tmp.Colspan = 3; foreach (IElement ele in arrayList) { tmp.Add(ele); } table.AddCell(tmp); } tmp = new Cell(); tmp.Border = NO_BORDER; table.AddCell(tmp); table.InsertTable((Table)element); tmp = new Cell(); tmp.Border = NO_BORDER; table.AddCell(tmp); table.AddCell(Cell.DummyCell); Clear(); arrayList.Add(table); return; default: arrayList.Add(element); break; } }
// adiciona uma célula com o texto organizado em várias linhas diferentes protected void AddNewCell(iTextSharp.text.Table table, List<string> paragraphs, iTextSharp.text.Font font) { Cell cell = new Cell(); foreach (string paragraph in paragraphs) { iTextSharp.text.Chunk chunk = new iTextSharp.text.Chunk(ConvertNewLines(paragraph), font); Paragraph p = new Paragraph(10, chunk); cell.Add(p); } cell.VerticalAlignment = Element.ALIGN_TOP; cell.HorizontalAlignment = Element.ALIGN_LEFT; table.AddCell(cell); }
// methods to set the membervariables /** * Adds an element to this Cell. * <P> * Remark: you can't add ListItems, Rows, Cells, * JPEGs, GIFs or PNGs to a Cell. * * @param element The Element to add * @throws BadElementException if the method was called with a ListItem, Row or Cell */ /// <summary> /// Adds an element to this Cell. /// </summary> /// <remarks> /// You can't add ListItems, Rows, Cells, /// JPEGs, GIFs or PNGs to a Cell. /// </remarks> /// <param name="element">the Element to add</param> public void AddElement(IElement element) { if (IsTable()) { Table table = (Table) arrayList[0]; Cell tmp = new Cell(element); tmp.Border = NO_BORDER; tmp.Colspan = table.Columns; table.AddCell(tmp); return; } switch (element.Type) { case Element.LISTITEM: case Element.ROW: case Element.CELL: throw new BadElementException("You can't add listitems, rows or cells to a cell."); case Element.JPEG: case Element.IMGRAW: case Element.IMGTEMPLATE: arrayList.Add(element); break; case Element.LIST: if (float.IsNaN(this.Leading)) { leading = ((List) element).Leading; } if (((List) element).Size == 0) return; arrayList.Add(element); return; case Element.ANCHOR: case Element.PARAGRAPH: case Element.PHRASE: if (float.IsNaN(leading)) { leading = ((Phrase) element).Leading; } if (((Phrase) element).IsEmpty()) return; arrayList.Add(element); return; case Element.CHUNK: if (((Chunk) element).IsEmpty()) return; arrayList.Add(element); return; case Element.TABLE: Table table = new Table(3); float[] widths = new float[3]; widths[1] = ((Table)element).WidthPercentage; switch (((Table)element).Alignment) { case Element.ALIGN_LEFT: widths[0] = 0f; widths[2] = 100f - widths[1]; break; case Element.ALIGN_CENTER: widths[0] = (100f - widths[1]) / 2f; widths[2] = widths[0]; break; case Element.ALIGN_RIGHT: widths[0] = 100f - widths[1]; widths[2] = 0f; break; } table.Widths = widths; Cell tmp; if (arrayList.Count == 0) { table.AddCell(Cell.DummyCell); } else { tmp = new Cell(); tmp.Border = NO_BORDER; tmp.Colspan = 3; foreach (IElement ele in arrayList) { tmp.Add(ele); } table.AddCell(tmp); } tmp = new Cell(); tmp.Border = NO_BORDER; table.AddCell(tmp); table.InsertTable((Table)element); tmp = new Cell(); tmp.Border = NO_BORDER; table.AddCell(tmp); table.AddCell(Cell.DummyCell); Clear(); arrayList.Add(table); return; default: arrayList.Add(element); break; } }
private Cell CellCreate(string text, int vAlignment = 1, int hAlignment = 0, int colspan = 1, int type = 0, int font = 10) { BaseFont trArial = BaseFont.CreateFont(@"C:\WINDOWS\Fonts\arial.ttf", BaseFont.IDENTITY_H, BaseFont.NOT_EMBEDDED); iTextSharp.text.Font newFont = new iTextSharp.text.Font(trArial, font, iTextSharp.text.Font.NORMAL); if (type == 0) newFont = new iTextSharp.text.Font(trArial, font, iTextSharp.text.Font.NORMAL); else newFont = new iTextSharp.text.Font(trArial, font, iTextSharp.text.Font.BOLD); Cell cell = new Cell(); cell.Add(new Phrase(text, newFont)); cell.HorizontalAlignment = vAlignment; cell.VerticalAlignment = hAlignment; cell.Colspan = colspan; return cell; }
protected static void SetTitle(Misc.sp_052_displayConfirmationRow row, iTextSharp.text.Table tblMain) { Cell CellTitle = new Cell(); CellTitle.Colspan = 2; CellTitle.Add(GetTitlePhrase("Rebate Form (Confirmation ID " + row.ConfirmationID + ") \n\n")); CellTitle.HorizontalAlignment = Element.ALIGN_CENTER; tblMain.AddCell(CellTitle); }
// public static SimpleAttendanceList GetInstance(Selection selection, // Rectangle pageSize, // string reportFile) { // // if (instance == null) // instance = new SimpleAttendanceList(selection, pageSize, reportFile); // else { // instance.selection = selection; // instance.reportFile = reportFile; // } // // if (!this.doc.IsOpen()) // this.doc.Open(); // // return instance; // } public override void MakeReport() { // Subtitle = Event name Chunk c = new Chunk(this.selection.Events[0].Name, FontFactory.GetFont(FontFactory.HELVETICA, 14, Font.BOLD)); Paragraph par = new Paragraph(c); par.Alignment = Rectangle.ALIGN_CENTER; this.doc.Add(par); // List Table t = new Table(2); t.Border = 0; t.DefaultCellBorder = 0; Cell cell = new Cell(); cell.HorizontalAlignment = Element.ALIGN_CENTER; t.DefaultCell = cell; // Default cell Font fuenteTitulo = FontFactory.GetFont(FontFactory.HELVETICA_OBLIQUE, 14, Font.UNDERLINE); cell = new Cell(); Chunk texto = new Chunk("Nombre y Apellido", fuenteTitulo); cell.Add(texto); t.AddCell(cell); cell = new Cell(); texto = new Chunk("¿Asistió?", fuenteTitulo); cell.Add(texto); t.AddCell(cell); Font fuenteDatos = FontFactory.GetFont(FontFactory.HELVETICA, 10); Font fuenteSi = FontFactory.GetFont(FontFactory.HELVETICA_BOLD, 10); fuenteSi.Color = Color.BLUE; Font fuenteNo = FontFactory.GetFont(FontFactory.HELVETICA_BOLD, 10); fuenteNo.Color = Color.RED; foreach (Person p in this.selection.Persons) { cell = new Cell(); texto = new Chunk(p.Name + " " + p.Surname, fuenteDatos); cell.Add(texto); t.AddCell(cell); cell = new Cell(); if (AttendancesManager.Instance.Attended(p, this.selection.Events[0])) texto = new Chunk("Si", fuenteSi); else texto = new Chunk("No", fuenteNo); cell.Add(texto); t.AddCell(cell); } this.doc.Add(t); }