List of usage examples for com.itextpdf.text Section add
@Override public boolean add(final Element element)
Paragraph
, List
, Table
or another Section
to this Section
. From source file:org.tvd.thptty.management.util.Report.java
private PdfPTable createTable(Section subCatPart) throws BadElementException { int countCell = cellTitles.length; PdfPTable table = new PdfPTable(countCell); for (int i = 0; i < countCell; i++) { PdfPCell cx = new PdfPCell(new Phrase(cellTitles[i])); cx.setHorizontalAlignment(Element.ALIGN_CENTER); table.addCell(cx);/*from w ww . j a v a2 s . c o m*/ } table.setHeaderRows(1); java.util.List<TYStudent> students = ActionUtil.getStudentsInClass(courses, tyClass.getClassId()); for (int i = 0; i < students.size(); i++) { TYStudent student = students.get(i); student.setFullName(student.getStudentFirstName() + " " + student.getStudentLastName()); table.addCell(student.getFullName()); System.out.println("\n" + student.getFullName() + "\n"); float points[] = TYServiceUtil.getPointStudentByPTPF(courses, semester, student.getStudentId(), tySubject.getSubjectId(), WebKeys.SPEAK_POINT, 1); String pointString = TYServiceUtil.floatsToPointString(points); table.addCell(pointString); points = TYServiceUtil.getPointStudentByPTPF(courses, semester, student.getStudentId(), tySubject.getSubjectId(), WebKeys.WRITE_POINT, 1); pointString = TYServiceUtil.floatsToPointString(points); table.addCell(pointString); points = TYServiceUtil.getPointStudentByPTPF(courses, semester, student.getStudentId(), tySubject.getSubjectId(), WebKeys.WRITE_POINT, 2); pointString = TYServiceUtil.floatsToPointString(points); table.addCell(pointString); points = TYServiceUtil.getPointStudentByPTPF(courses, semester, student.getStudentId(), tySubject.getSubjectId(), WebKeys.WRITE_POINT, 3); pointString = TYServiceUtil.floatsToPointString(points); table.addCell(pointString); java.util.List<TYStudentPoint> studentPointSubjects = TYServiceUtil.getStudentAVGPointBySubject(courses, semester, student.getStudentId(), tySubject.getSubjectId()); float avgPointSubject = 0; if (studentPointSubjects.size() > 0) avgPointSubject = TYServiceUtil.getCutFloat(studentPointSubjects.get(0).getPoint(), 2); pointString = "" + avgPointSubject; table.addCell(pointString); } subCatPart.add(table); return table; }
From source file:others.pdfWriter.java
private static void addContent(Document document) throws DocumentException { Anchor anchor = new Anchor("First Chapter", catFont); anchor.setName("First Chapter"); // Second parameter is the number of the chapter Chapter catPart = new Chapter(new Paragraph(anchor), 1); Paragraph subPara = new Paragraph("Subcategory 1", subFont); Section subCatPart = catPart.addSection(subPara); subCatPart.add(new Paragraph("Hello")); subPara = new Paragraph("Subcategory 2", subFont); subCatPart = catPart.addSection(subPara); subCatPart.add(new Paragraph("Paragraph 1")); subCatPart.add(new Paragraph("Paragraph 2")); subCatPart.add(new Paragraph("Paragraph 3")); // add a list createList(subCatPart);/*from w ww . ja v a 2s .c o m*/ Paragraph paragraph = new Paragraph(); addEmptyLine(paragraph, 5); subCatPart.add(paragraph); // add a table // createTableExercicios(subCatPart); // now add all this to the document document.add(catPart); // Next section anchor = new Anchor("Second Chapter", catFont); anchor.setName("Second Chapter"); // Second parameter is the number of the chapter catPart = new Chapter(new Paragraph(anchor), 1); subPara = new Paragraph("Subcategory", subFont); subCatPart = catPart.addSection(subPara); subCatPart.add(new Paragraph("This is a very important message")); // now add all this to the document document.add(catPart); }
From source file:our.isaacmayur.expensemanager.GenerateReport.java
private static void createTable(Section catPart) throws BadElementException { PdfPTable table = new PdfPTable(4); // t.setBorderColor(BaseColor.GRAY); // t.setPadding(4); // t.setSpacing(4); // t.setBorderWidth(1); for (int i = 0; i < category.size(); i++) { Log.e("category...", category.get(i)); Log.e("mode...", mode.get(i)); Log.e("amt...", "amt" + amount.get(i)); Log.e("date2...", "date" + date.get(i)); }//from w w w . j ava 2s .c om PdfPCell c1 = new PdfPCell(new Phrase("Category Name")); c1.setHorizontalAlignment(Element.ALIGN_CENTER); table.addCell(c1); c1 = new PdfPCell(new Phrase("Amount Spent (Rs)")); c1.setHorizontalAlignment(Element.ALIGN_CENTER); table.addCell(c1); c1 = new PdfPCell(new Phrase("Date")); c1.setHorizontalAlignment(Element.ALIGN_CENTER); table.addCell(c1); c1 = new PdfPCell(new Phrase("Payment Mode")); c1.setHorizontalAlignment(Element.ALIGN_CENTER); table.addCell(c1); table.setHeaderRows(1); /* * table.addCell("pay"); table.addCell("hell"); table.addCell("to"); * table.addCell("to"); table.addCell("to"); * * table.addCell("2.1"); table.addCell("2.2"); table.addCell("2.3"); */ // code to add rows dynamically...remember the multiple for (int i = 0; i < category.size(); i++) { table.addCell(category.get(i)); table.addCell(amount.get(i) + ""); table.addCell(date.get(i)); table.addCell(mode.get(i)); } catPart.add(table); Log.e("meta", "table"); }
From source file:pdf.PDFdescriptiva.java
private static void agregarContenido(Document document, String titulo, String[][] arreglo, Integer N, String[] variables) throws DocumentException { agregarTabla(document, titulo, arreglo); Anchor anchor = new Anchor("Datos", catFont); anchor.setName("Datos"); Chapter catPart = new Chapter(new Paragraph(anchor), 1); Paragraph subPara = new Paragraph("Variables", subFont); Section subCatPart = catPart.addSection(subPara); subCatPart.add(new Paragraph("N: " + N)); subCatPart.add(new Paragraph("Maximo: " + variables[0])); subCatPart.add(new Paragraph("Minimo: " + variables[1])); subCatPart.add(new Paragraph("Rango: " + variables[2])); subCatPart.add(new Paragraph("Intervalos: " + variables[3])); subCatPart.add(new Paragraph("Amplitud: " + variables[4])); subCatPart.add(new Paragraph("Rango Ampliado: " + variables[5])); subCatPart.add(new Paragraph("Dif Rangos: " + variables[6])); subCatPart.add(new Paragraph("LIPI: " + variables[7])); subCatPart.add(new Paragraph("LSUI: " + variables[8])); subCatPart.add(new Paragraph("Desv Media: " + variables[9])); subCatPart.add(new Paragraph("Varianza: " + variables[10])); subCatPart.add(new Paragraph("Desv Estandar: " + variables[11])); subCatPart.add(new Paragraph("Media: " + variables[12])); subCatPart.add(new Paragraph("Mediana: " + variables[13])); subCatPart.add(new Paragraph("Moda: " + variables[14])); document.add(catPart);/*from w ww .ja v a 2s. c o m*/ }
From source file:pdf.PDFdescriptiva.java
private static void tablaPrediccion(Section subCatPart, Double Y, Double li, Double ls) throws DocumentException { PdfPTable table = new PdfPTable(3); PdfPCell c1 = new PdfPCell(new Phrase("Y estimada")); c1.setHorizontalAlignment(Element.ALIGN_CENTER); table.addCell(c1);/*from w w w. java 2 s . c o m*/ c1 = new PdfPCell(new Phrase("Li")); c1.setHorizontalAlignment(Element.ALIGN_CENTER); table.addCell(c1); c1 = new PdfPCell(new Phrase("Ls")); c1.setHorizontalAlignment(Element.ALIGN_CENTER); table.addCell(c1); table.setHeaderRows(1); table.addCell(Y + ""); table.addCell(li + ""); table.addCell(ls + ""); subCatPart.add(table); }
From source file:pdf.PDFmultiple.java
private static void agregarContenido(Document document, String titulo, String[][] arreglo, Integer N, Double b0, Double b1, Double b2, Double Se, Double[] prediccion) throws DocumentException { agregarTabla(document, titulo, arreglo); Anchor anchor = new Anchor("Datos", catFont); anchor.setName("Datos"); Chapter catPart = new Chapter(new Paragraph(anchor), 1); Paragraph subPara = new Paragraph("Variables", subFont); Section subCatPart = catPart.addSection(subPara); subCatPart.add(new Paragraph("N: " + N)); subCatPart.add(new Paragraph("K: 2")); subCatPart.add(new Paragraph("b0: " + b0)); subCatPart.add(new Paragraph("b1: " + b1)); subCatPart.add(new Paragraph("b2: " + b2)); subCatPart.add(new Paragraph("Se: " + Se)); Paragraph espacio = new Paragraph(); addEmptyLine(espacio, 1);//from www . j a v a 2 s .co m subCatPart.add(espacio); subPara = new Paragraph("Predicciones", subFont); subCatPart = catPart.addSection(subPara); if (prediccion[0] != null && prediccion[1] != null && prediccion[2] != null && prediccion[3] != null && prediccion[4] != null && prediccion[5] != null) { subCatPart.add(new Paragraph("X1: " + prediccion[0])); subCatPart.add(new Paragraph("X2: " + prediccion[1])); subCatPart.add(new Paragraph("Efectividad: " + prediccion[2])); addEmptyLine(espacio, 1); subCatPart.add(espacio); tablaPrediccion(subCatPart, prediccion[3], prediccion[4], prediccion[5]); } else { subCatPart.add(new Paragraph("No se realiz ninguna prediccion.")); } document.add(catPart); }
From source file:pdf.PDFsimple.java
private static void agregarContenido(Document document, String titulo, String[][] arreglo, Integer N, Double b0, Double b1, Double Se, Double dx, Double dy, Double dxy, Double r, Double[] prediccion) throws DocumentException { agregarTabla(document, titulo, arreglo); Anchor anchor = new Anchor("Datos", catFont); anchor.setName("Datos"); Chapter catPart = new Chapter(new Paragraph(anchor), 1); //comentario/*from ww w.j ava2 s.c o m*/ Paragraph subPara = new Paragraph("Variables", subFont); Section subCatPart = catPart.addSection(subPara); subCatPart.add(new Paragraph("N: " + N)); subCatPart.add(new Paragraph("K: 1")); subCatPart.add(new Paragraph("b0: " + b0)); subCatPart.add(new Paragraph("b1: " + b1)); subCatPart.add(new Paragraph("Se: " + Se)); subCatPart.add(new Paragraph("DX: " + dx)); subCatPart.add(new Paragraph("DY: " + dy)); subCatPart.add(new Paragraph("DXY: " + dxy)); subCatPart.add(new Paragraph("R: " + r)); Paragraph espacio = new Paragraph(); addEmptyLine(espacio, 1); subCatPart.add(espacio); subPara = new Paragraph("Predicciones", subFont); subCatPart = catPart.addSection(subPara); if (prediccion[0] != null && prediccion[1] != null && prediccion[2] != null && prediccion[3] != null && prediccion[4] != null) { subCatPart.add(new Paragraph("X: " + prediccion[0])); subCatPart.add(new Paragraph("Efectividad: " + prediccion[1])); addEmptyLine(espacio, 1); subCatPart.add(espacio); tablaPrediccion(subCatPart, prediccion[2], prediccion[3], prediccion[4]); } else { subCatPart.add(new Paragraph("No se realiz ninguna prediccion.")); } document.add(catPart); }
From source file:PdfCreation.PdfTableWriter.java
public Section addTable(JTable table) { DefaultTableModel model = (DefaultTableModel) table.getModel(); Section ourTableSection = new Chapter(0) .addSection(this.newParagraph("Information Table", true, false, false)); ourTableSection.add(new Paragraph(" ")); PdfPTable ourTable = new PdfPTable(model.getColumnCount() + 1); int count = 1; ourTable.addCell(new Phrase(" ", FontFactory.getFont(FontFactory.HELVETICA, 8, Font.BOLD))); for (int i = 0; i < model.getColumnCount(); i++) { Phrase phrase = new Phrase(model.getColumnName(i).toString(), FontFactory.getFont(FontFactory.HELVETICA, 8, Font.BOLD)); ourTable.addCell(new PdfPCell(phrase)); }//from w ww . j a v a 2 s .c om for (int i = 0; i < model.getRowCount(); i++) { ourTable.addCell(new Phrase("" + count++, FontFactory.getFont(FontFactory.HELVETICA, 8))); for (int j = 0; j < model.getColumnCount(); j++) { Phrase phrase = new Phrase(model.getValueAt(i, j).toString(), FontFactory.getFont(FontFactory.HELVETICA, 8)); ourTable.addCell(phrase); } } ourTableSection.add(ourTable); return ourTableSection; }
From source file:pdfcreator.Main.java
private static void createTable(Section subCatPart) throws BadElementException { PdfPTable table = new PdfPTable(3); PdfPCell c1 = new PdfPCell(new Phrase("Table Header 1")); c1.setHorizontalAlignment(Element.ALIGN_CENTER); table.addCell(c1);/*from w ww . j a v a2 s . co m*/ c1 = new PdfPCell(new Phrase("Table Header 2")); c1.setHorizontalAlignment(Element.ALIGN_CENTER); table.addCell(c1); c1 = new PdfPCell(new Phrase("Table Header 3")); c1.setHorizontalAlignment(Element.ALIGN_CENTER); table.addCell(c1); table.setHeaderRows(1); table.addCell("1.0"); table.addCell("1.1"); table.addCell("1.2"); table.addCell("2.1"); table.addCell("2.2"); table.addCell("2.3"); subCatPart.add(table); }
From source file:pdfgen.pdf_generation_try5.java
public void addContent(Document document) throws DocumentException { Anchor anchor = new Anchor("Chapter 1: used for various paragraphs", catFont); anchor.setName("First Chapter"); // Second parameter is the number of the chapter Chapter catPart = new Chapter(new Paragraph(anchor), 1); Paragraph subPara = new Paragraph("Subcategory 1", subFont); Section subCatPart = catPart.addSection(subPara); subCatPart.add(new Paragraph("Hello")); subPara = new Paragraph("Subcategory 2", subFont); subCatPart = catPart.addSection(subPara); subCatPart.add(new Paragraph("Paragraph 1")); subCatPart.add(new Paragraph("Paragraph 2")); subCatPart.add(new Paragraph("Paragraph 3")); // add a list createList(subCatPart);/* w w w . j a v a 2 s.c o m*/ Paragraph paragraph = new Paragraph(); addEmptyLine(paragraph, 5); subCatPart.add(paragraph); // add a table createTable(subCatPart); // now add all this to the document document.add(catPart); // Next section anchor = new Anchor("Second Chapter : only for checking", catFont); anchor.setName("Second Chapter"); // Second parameter is the number of the chapter catPart = new Chapter(new Paragraph(anchor), 1); subPara = new Paragraph("Subcategory", subFont); subCatPart = catPart.addSection(subPara); subCatPart.add(new Paragraph("This is a very important message")); // now add all this to the document document.add(catPart); }