List of usage examples for com.itextpdf.text.pdf PdfPCell setPaddingTop
public void setPaddingTop(float paddingTop)
From source file:de.aidger.utils.pdf.BalanceReportConverter.java
License:Open Source License
/** * Writes a semester table and adds the groups of that semester to it. * //from w w w . j ava 2 s. c o m * @param semester * The name of the semester to be added. */ @SuppressWarnings("unchecked") private void createSemester(String semester) { balanceReportGroups = new ArrayList<ArrayList>(); try { Font semesterTitleFont = new Font( BaseFont.createFont(BaseFont.HELVETICA_BOLD, BaseFont.CP1252, BaseFont.EMBEDDED), 13); Font semesterNameFont = new Font( BaseFont.createFont(BaseFont.HELVETICA, BaseFont.CP1252, BaseFont.EMBEDDED), 13); PdfPTable finalSemesterTable = new PdfPTable(1); PdfPTable semesterTitleTable = new PdfPTable(new float[] { 0.2f, 0.8f }); PdfPCell semesterCell = new PdfPCell(new Phrase(_("Semester"), semesterTitleFont)); semesterCell.setBorder(0); semesterTitleTable.addCell(semesterCell); semesterCell = new PdfPCell(new Phrase(semester, semesterNameFont)); semesterCell.setBorder(0); semesterTitleTable.addCell(semesterCell); semesterCell = new PdfPCell(semesterTitleTable); semesterCell.setBorder(0); semesterCell.setPaddingTop(7.0f); finalSemesterTable.addCell(semesterCell); PdfPTable contentTable = new PdfPTable(1); /* * As long as there are groups for this Balance report, create new * group tables. */ List<Course> courses = null; if (semester != null) { courses = (new Course()).getCoursesBySemester(semester); } else { courses = new ArrayList<Course>(); List<Course> unsortedCourses = new Course().getAll(); for (Course course : unsortedCourses) { if (course.getSemester() == null) { courses.add(new Course(course)); } } } List<Course> filteredCourses = balanceHelper.filterCourses(courses, filters); for (Course course : filteredCourses) { PdfPTable groupTable = null; if (balanceReportGroups.isEmpty()) { groupTable = createGroup(course); } else { boolean foundGroup = false; for (int i = 0; i <= balanceReportGroups.size() - 1; i++) { if (((ArrayList) balanceReportGroups.get(i)).get(1).equals(course.getGroup())) { foundGroup = true; break; } } if (!foundGroup) { groupTable = createGroup(course); } } } for (int i = 0; i <= balanceReportGroups.size() - 1; i++) { PdfPCell cell = new PdfPCell((PdfPTable) ((ArrayList) balanceReportGroups.get(i)).get(0)); cell.setBorder(0); cell.setPaddingBottom(8.0f); contentTable.addCell(cell); } PdfPCell contentCell = new PdfPCell(contentTable); contentCell.setPaddingLeft(10.0f); contentCell.setBorder(1); finalSemesterTable.addCell(contentCell); finalSemesterTable.setKeepTogether(true); document.add(finalSemesterTable); } catch (Exception e) { Logger.error(e.getMessage()); } }
From source file:de.aidger.utils.pdf.BalanceReportConverter.java
License:Open Source License
/** * Creates a new group table with the title of the group. Adds the table and * its title to the group table vector./*from ww w.ja v a2s. co m*/ * * @param course * The course for which a group shall be created. * @return The PdfPTable of the group. */ @SuppressWarnings("unchecked") private PdfPTable createGroup(Course course) { balanceReportGroupCreator = new BalanceReportGroupCreator(course, calculationMethod); List<Course> courses = null; sums = new ArrayList<Object>(); try { if (course.getSemester() != null) { courses = (new Course()).getCoursesBySemester(course.getSemester()); } else { courses = new ArrayList<Course>(); List<Course> unsortedCourses = new Course().getAll(); for (Course currentCourse : unsortedCourses) { if (currentCourse.getSemester() == null) { courses.add(new Course(currentCourse)); } } } } catch (SienaException e) { UI.displayError(e.toString()); } List<Course> filteredCourses = balanceHelper.filterCourses(courses, filters); ArrayList<Long> addedCourses = new ArrayList<Long>(); addedCourses.add(course.getId()); for (Course filteredCourse : filteredCourses) { if (!addedCourses.contains(filteredCourse.getId()) && filteredCourse.getGroup().equals(course.getGroup())) { balanceReportGroupCreator.addCourse(filteredCourse); addedCourses.add(filteredCourse.getId()); } } ArrayList<Integer> costUnits = new ArrayList<Integer>(); ArrayList<BalanceCourse> balanceCourses = balanceReportGroupCreator.getBalanceCourses(); ArrayList<String> titles = new ArrayList<String>(); String[] courseTitles = { _("Title"), _("Part"), _("Lecturer"), _("Target Audience"), _("Planned AWS"), _("Basic needed AWS") }; for (int i = 0; i < courseTitles.length; i++) { titles.add(courseTitles[i]); } for (Object balanceCourse : balanceCourses) { for (BudgetCost budgetCost : ((BalanceCourse) balanceCourse).getBudgetCosts()) { int budgetCostId = budgetCost.getId(); String budgetCostName = budgetCost.getName(); if (!costUnits.contains(budgetCostId)) { costUnits.add(budgetCostId); titles.add(_("Budget costs from") + " " + budgetCostName); } } } int columnCount = titles.size(); Font tableTitleFont; Font tableContentFont; try { tableContentFont = new Font(BaseFont.createFont(BaseFont.HELVETICA, BaseFont.CP1252, BaseFont.EMBEDDED), 9); tableTitleFont = new Font( BaseFont.createFont(BaseFont.HELVETICA_BOLD, BaseFont.CP1252, BaseFont.EMBEDDED), 9); Font groupTitleFont = new Font( BaseFont.createFont(BaseFont.HELVETICA_BOLD, BaseFont.CP1252, BaseFont.EMBEDDED), 11); Font groupNameFont = new Font( BaseFont.createFont(BaseFont.HELVETICA, BaseFont.CP1252, BaseFont.EMBEDDED), 11); PdfPTable groupTable = new PdfPTable(1); PdfPTable groupNameTable = new PdfPTable(new float[] { 0.2f, 0.8f }); PdfPCell groupTitle = new PdfPCell(new Phrase(_("Group"), groupTitleFont)); groupTitle.setBorder(2); groupNameTable.addCell(groupTitle); PdfPCell groupName = new PdfPCell(new Phrase(course.getGroup(), groupNameFont)); groupName.setBorder(2); groupNameTable.addCell(groupName); PdfPCell groupContent = new PdfPCell(groupNameTable); groupContent.setBorder(0); groupContent.setPaddingTop(3.0f); groupContent.setPaddingBottom(2.0f); groupTable.addCell(groupContent); float[] columnWidths = new float[columnCount]; columnWidths[0] = (200 / columnCount); columnWidths[1] = (50 / columnCount); columnWidths[2] = (100 / columnCount); columnWidths[3] = (150 / columnCount); columnWidths[4] = (100 / columnCount); for (int i = 5; i < columnCount; i++) { columnWidths[i] = (100 / columnCount); } PdfPTable groupContentTable = new PdfPTable(columnWidths); /* * Create the titles of the table entries. */ for (int i = 0; i < titles.size(); i++) { PdfPCell cell = new PdfPCell(new Phrase(titles.get(i), tableTitleFont)); if (i != 0) { cell.setBorder(6); } else { cell.setBorder(2); } groupContentTable.addCell(cell); } PdfPCell cell = new PdfPCell(groupContentTable); cell.setBorder(0); groupTable.addCell(cell); sums.add(_("Sum")); sums.add(""); sums.add(""); sums.add(""); sums.add(0.0); sums.add(0.0); for (Object balanceCourse : balanceCourses) { groupTable.addCell(addRow((BalanceCourse) balanceCourse, columnWidths, costUnits)); } PdfPTable emptyRow = new PdfPTable(columnWidths); PdfPTable sumRow = new PdfPTable(columnWidths); for (int i = 0; i < sums.size(); i++) { cell = new PdfPCell(new Phrase("")); if (i != 0) { cell.setBorder(Rectangle.TOP + Rectangle.LEFT); } else { cell.setBorder(Rectangle.TOP); } emptyRow.addCell(cell); if (i < 4) { cell = new PdfPCell(new Phrase(new Phrase(sums.get(i).toString(), tableContentFont))); } else { /* * Round to the configured precision. */ int decimalPlace = Integer.parseInt(Runtime.getInstance().getOption("rounding", "2")); double rounded = new BigDecimal((Double) sums.get(i)) .setScale(decimalPlace, BigDecimal.ROUND_HALF_EVEN).doubleValue(); cell = new PdfPCell( new Phrase(new BigDecimal(rounded).setScale(2, BigDecimal.ROUND_HALF_EVEN).toString(), tableContentFont)); } if (i != 0) { cell.setBorder(Rectangle.TOP + Rectangle.LEFT); } else { cell.setBorder(Rectangle.TOP); } sumRow.addCell(cell); } cell = new PdfPCell(emptyRow); cell.setBorder(0); groupTable.addCell(cell); cell = new PdfPCell(sumRow); cell.setBorder(0); groupTable.addCell(cell); groupTable.setKeepTogether(true); balanceReportGroups.add(new ArrayList<Object>()); int i = balanceReportGroups.size() - 1; ((ArrayList) balanceReportGroups.get(i)).add(groupTable); ((ArrayList) balanceReportGroups.get(i)).add(course.getGroup()); return groupTable; } catch (DocumentException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } return null; }
From source file:de.aidger.utils.pdf.ControllingConverter.java
License:Open Source License
/** * Creates the table of assistants.//from w ww . j a v a 2 s. c o m */ private void createTable() { try { Font tableTitleFont = new Font( BaseFont.createFont(BaseFont.HELVETICA_BOLD, BaseFont.CP1252, BaseFont.EMBEDDED), 9); String[] courseTitles = { _("Assistant"), _("Planned costs(pre-tax)"), _("Actual costs(pre-tax)"), _("Remark") }; PdfPTable contentTable = new PdfPTable(1); PdfPTable titleTable = new PdfPTable(4); /* * Create the titles of the table entries. */ for (int i = 0; i < courseTitles.length; i++) { PdfPCell cell = new PdfPCell(new Phrase(courseTitles[i], tableTitleFont)); titleTable.addCell(cell); } PdfPCell cell = new PdfPCell(titleTable); cell.setPaddingTop(10.0f); cell.setPaddingBottom(2.0f); cell.setBorder(0); contentTable.addCell(cell); document.add(contentTable); addRows(); } catch (DocumentException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } }
From source file:de.aidger.utils.pdf.ProtocolConverter.java
License:Open Source License
/** * Writes the Table of activities./*from w w w . j a v a 2 s . c o m*/ */ private void writeTable() { try { Font tableTitleFont = new Font( BaseFont.createFont(BaseFont.HELVETICA_BOLD, BaseFont.CP1252, BaseFont.EMBEDDED), 9); String[] courseTitles = { _("Affected assistant"), _("Affected course"), _("Type"), _("Date"), _("Content"), _("Initiator"), _("Processor"), _("Remark") }; PdfPTable contentTable = new PdfPTable(1); PdfPTable titleTable = new PdfPTable(8); /* * Create the titles of the table entries. */ for (int i = 0; i < courseTitles.length; i++) { PdfPCell cell = new PdfPCell(new Phrase(courseTitles[i], tableTitleFont)); if (i != 0) { cell.setBorder(6); } else { cell.setBorder(2); } titleTable.addCell(cell); } PdfPCell cell = new PdfPCell(titleTable); cell.setPaddingTop(10.0f); cell.setBorder(0); contentTable.addCell(cell); document.add(contentTable); } catch (DocumentException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } }
From source file:edu.cornell.mannlib.vitro.webapp.visualization.visutils.PDFDocument.java
License:Open Source License
private void setTableFooterStyle(BaseColor footerBackgroundColor, PdfPCell cell) { cell.setBorderWidth(0.0f);//from w w w .ja va2 s . co m cell.setBackgroundColor(footerBackgroundColor); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setPaddingTop(5f); cell.setPaddingRight(10f); cell.setPaddingBottom(5f); cell.setPaddingLeft(10f); }
From source file:edu.cornell.mannlib.vitro.webapp.visualization.visutils.PDFDocument.java
License:Open Source License
private void setTableBodyStyle(BaseColor bodyBackgroundColor, PdfPCell cell) { cell.setBorderWidth(0.0f);/* w w w . j a v a2 s .c o m*/ cell.setBackgroundColor(bodyBackgroundColor); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setPaddingTop(5f); cell.setPaddingRight(10f); cell.setPaddingBottom(5f); cell.setPaddingLeft(10f); }
From source file:edu.cornell.mannlib.vitro.webapp.visualization.visutils.PDFDocument.java
License:Open Source License
private void setTableHeaderStyle(BaseColor headerBackgroundColor, PdfPCell cell) { cell.setBorderWidth(0.0f);// w ww .ja va 2 s. c o m cell.setBackgroundColor(headerBackgroundColor); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setPaddingTop(5f); cell.setPaddingRight(10f); cell.setPaddingBottom(5f); cell.setPaddingLeft(10f); }
From source file:edu.cornell.mannlib.vitro.webapp.visualization.visutils.PDFDocument.java
License:Open Source License
private void setTableCaptionStyle(BaseColor summaryBackgroundColor, PdfPCell cell) { cell.setBorderWidth(0.0f);/* w w w .ja va 2 s . c o m*/ cell.setBackgroundColor(summaryBackgroundColor); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setPaddingTop(5.0f); cell.setPaddingRight(10.0f); cell.setPaddingBottom(5.0f); cell.setPaddingLeft(10.0f); cell.setColspan(2); }
From source file:es.clinica.veterinaria.albaranes.AlbaranPdf.java
public PdfPTable createTable() throws DocumentException { // a table with three columns int iva = 0, iva2 = 0; DecimalFormat df = new DecimalFormat("0.00"); PdfPTable table = new PdfPTable(5); table.setTotalWidth(new float[] { 55, 150, 200, 70, 70 }); table.setLockedWidth(true);//from ww w .jav a 2s . com // the cell object // we add a cell with colspan 3 PdfPCell cell = new PdfPCell(new Phrase("CANT.")); cell.setColspan(1); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setBackgroundColor(BaseColor.LIGHT_GRAY); cell.setPaddingTop(5); cell.setPaddingBottom(5); table.addCell(cell); cell = new PdfPCell(new Phrase("CONCEPTO")); cell.setColspan(1); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setBackgroundColor(BaseColor.LIGHT_GRAY); cell.setPaddingTop(5); cell.setPaddingBottom(5); table.addCell(cell); cell = new PdfPCell(new Phrase("DESCRIPCIN")); cell.setColspan(1); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setBackgroundColor(BaseColor.LIGHT_GRAY); cell.setPaddingTop(5); cell.setPaddingBottom(5); table.addCell(cell); cell = new PdfPCell(new Phrase("PRECIO")); cell.setColspan(1); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setBackgroundColor(BaseColor.LIGHT_GRAY); cell.setPaddingTop(5); cell.setPaddingBottom(5); table.addCell(cell); cell = new PdfPCell(new Phrase("IMPORTE")); cell.setColspan(1); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setBackgroundColor(BaseColor.LIGHT_GRAY); cell.setPaddingTop(5); cell.setPaddingBottom(5); table.addCell(cell); HashSet<VentaLinea> listVenta = getVenta().getVenta_lineas(); for (VentaLinea vlinea : listVenta) { if (vlinea.getTipo() == 1) { if (vlinea.getProducto().getIva() != null) { iva2 = vlinea.getProducto().getIva().getValor(); // System.out.println("IVA: " +iva2); } } else if (vlinea.getTipo() == 2) { if (vlinea.getServicio().getIva() != null) { iva2 = vlinea.getServicio().getIva().getValor(); // System.out.println("IVA: " +iva2); } } //Para hacer el calculo nos vamos a quedar con el IVA mayor if (iva < iva2) { iva = iva2; } cell = new PdfPCell(new Phrase(vlinea.getCantidad() + "", small)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setPaddingBottom(5); table.addCell(cell); table.addCell(new PdfPCell(new Phrase(vlinea.getNombre(), small))); String descripcion = vlinea.getDescripcion(); if (descripcion == null || "null".equals(descripcion)) { table.addCell(new PdfPCell(new Phrase(" ", small))); // System.out.println("null:" + descripcion); } else { table.addCell(new PdfPCell(new Phrase(descripcion, small))); // System.out.println("!null:" + descripcion); } cell = new PdfPCell(new Phrase(df.format(vlinea.getPvp()) + " ", small)); cell.setHorizontalAlignment(Element.ALIGN_RIGHT); cell.setPaddingBottom(5); table.addCell(cell); cell = new PdfPCell(new Phrase(df.format(vlinea.getPreciototalNoIVA()) + " ", small)); cell.setHorizontalAlignment(Element.ALIGN_RIGHT); cell.setPaddingBottom(5); table.addCell(cell); } cell = new PdfPCell(new Phrase(" ")); cell.setColspan(1); cell.setBorderWidthBottom(0); cell.setBorderWidthLeft(0); cell.setBorder(0); cell.setBorderColorLeft(BaseColor.WHITE); cell.setBorderColorBottom(BaseColor.WHITE); cell.setPaddingBottom(5); table.addCell(cell); table.addCell(cell); table.addCell(cell); cell = new PdfPCell(new Phrase("SUMA")); cell.setColspan(1); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setBackgroundColor(BaseColor.LIGHT_GRAY); cell.setPaddingBottom(5); table.addCell(cell); cell = new PdfPCell(new Phrase(df.format(venta.getCostesinIva()) + " ")); cell.setColspan(1); cell.setHorizontalAlignment(Element.ALIGN_RIGHT); cell.setPaddingBottom(5); table.addCell(cell); /* IVA */ cell = new PdfPCell(new Phrase(" ")); cell.setColspan(1); cell.setBorderWidthBottom(0); cell.setBorderWidthLeft(0); cell.setBorder(0); cell.setBorderColorLeft(BaseColor.WHITE); cell.setBorderColorBottom(BaseColor.WHITE); cell.setPaddingBottom(5); table.addCell(cell); table.addCell(cell); table.addCell(cell); // float costetotal = (float) (venta.getCoste() * (1+(iva*0.01))); cell = new PdfPCell(new Phrase("IVA " + iva + "%")); cell.setColspan(1); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setBackgroundColor(BaseColor.LIGHT_GRAY); cell.setPaddingBottom(5); table.addCell(cell); cell = new PdfPCell(new Phrase(df.format(venta.getIvas()) + " ")); cell.setColspan(1); cell.setHorizontalAlignment(Element.ALIGN_RIGHT); cell.setPaddingBottom(5); table.addCell(cell); /* COSTE TOTAL */ cell = new PdfPCell(new Phrase(" ")); cell.setColspan(1); cell.setBorderWidthBottom(0); cell.setBorderWidthLeft(0); cell.setBorder(0); cell.setBorderColorLeft(BaseColor.WHITE); cell.setBorderColorBottom(BaseColor.WHITE); cell.setPaddingBottom(5); table.addCell(cell); table.addCell(cell); table.addCell(cell); cell = new PdfPCell(new Phrase("TOTAL")); cell.setColspan(1); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setBackgroundColor(BaseColor.LIGHT_GRAY); cell.setPaddingBottom(5); table.addCell(cell); cell = new PdfPCell(new Phrase(df.format(venta.getCoste()) + " ")); cell.setColspan(1); cell.setHorizontalAlignment(Element.ALIGN_RIGHT); cell.setPaddingBottom(5); table.addCell(cell); return table; }
From source file:es.clinica.veterinaria.facturas.FacturaPdf.java
public PdfPTable createTable() throws DocumentException { // a table with three columns int iva = 0, iva2 = 0; DecimalFormat df = new DecimalFormat("0.00"); PdfPTable table = new PdfPTable(6); table.setTotalWidth(new float[] { 50, 65, 150, 150, 65, 70 }); table.setLockedWidth(true);/*from w w w. j av a 2 s . c o m*/ // the cell object // we add a cell with colspan 3 PdfPCell cell = new PdfPCell(new Phrase("CANT.")); cell.setColspan(1); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setBackgroundColor(BaseColor.LIGHT_GRAY); cell.setPaddingTop(5); cell.setPaddingBottom(5); table.addCell(cell); cell = new PdfPCell(new Phrase("FECHA")); cell.setColspan(1); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setBackgroundColor(BaseColor.LIGHT_GRAY); cell.setPaddingTop(5); cell.setPaddingBottom(5); table.addCell(cell); cell = new PdfPCell(new Phrase("CONCEPTO")); cell.setColspan(1); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setBackgroundColor(BaseColor.LIGHT_GRAY); cell.setPaddingTop(5); cell.setPaddingBottom(5); table.addCell(cell); cell = new PdfPCell(new Phrase("DESCRIPCIN")); cell.setColspan(1); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setBackgroundColor(BaseColor.LIGHT_GRAY); cell.setPaddingTop(5); cell.setPaddingBottom(5); table.addCell(cell); cell = new PdfPCell(new Phrase("PRECIO")); cell.setColspan(1); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setBackgroundColor(BaseColor.LIGHT_GRAY); cell.setPaddingTop(5); cell.setPaddingBottom(5); table.addCell(cell); cell = new PdfPCell(new Phrase("IMPORTE")); cell.setColspan(1); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setBackgroundColor(BaseColor.LIGHT_GRAY); cell.setPaddingTop(5); cell.setPaddingBottom(5); table.addCell(cell); HashSet<Venta> ventas = this.getFactura().getVentas(); for (Venta venta : ventas) { HashSet<VentaLinea> listVenta = venta.getVenta_lineas(); for (VentaLinea vlinea : listVenta) { if (vlinea.getTipo() == 1) { if (vlinea.getProducto().getIva() != null) { iva2 = vlinea.getProducto().getIva().getValor(); // System.out.println("IVA: " +iva2); } } else if (vlinea.getTipo() == 2) { if (vlinea.getServicio().getIva() != null) { iva2 = vlinea.getServicio().getIva().getValor(); // System.out.println("IVA: " +iva2); } } //Para hacer el calculo nos vamos a quedar con el IVA mayor if (iva < iva2) { iva = iva2; } cell = new PdfPCell(new Phrase(vlinea.getCantidad() + "", small)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setPaddingBottom(5); table.addCell(cell); cell = new PdfPCell( new Phrase(new SimpleDateFormat("dd-MM-yyyy").format(vlinea.getFecha()), small)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setPaddingBottom(5); table.addCell(cell); if (vlinea.getTipo() == 2) { //Servicio table.addCell(new PdfPCell(new Phrase(vlinea.getNombre(), small))); String descripcion = vlinea.getDescripcion(); if (descripcion == null || "null".equals(descripcion)) { table.addCell(new PdfPCell(new Phrase(" ", small))); // System.out.println("null:" + descripcion); } else { table.addCell(new PdfPCell(new Phrase(descripcion, small))); // System.out.println("!null:" + descripcion); } } else if (vlinea.getTipo() == 1) { //Producto //Si el producto es Tratamiento if (vlinea.getProducto().getFamilia().isTratamiento()) { table.addCell(new PdfPCell(new Phrase("Tratamiento", small))); table.addCell(new PdfPCell(new Phrase("", small))); } else { table.addCell(new PdfPCell(new Phrase(vlinea.getNombre(), small))); String descripcion = vlinea.getDescripcion(); if (descripcion == null || "null".equals(descripcion)) { table.addCell(new PdfPCell(new Phrase(" ", small))); // System.out.println("null:" + descripcion); } else { table.addCell(new PdfPCell(new Phrase(descripcion, small))); // System.out.println("!null:" + descripcion); } } } cell = new PdfPCell(new Phrase(df.format(vlinea.getPvp()) + " ", small)); cell.setHorizontalAlignment(Element.ALIGN_RIGHT); cell.setPaddingBottom(5); table.addCell(cell); cell = new PdfPCell(new Phrase(df.format(vlinea.getPreciototalNoIVA()) + " ", small)); cell.setHorizontalAlignment(Element.ALIGN_RIGHT); cell.setPaddingBottom(5); table.addCell(cell); } } cell = new PdfPCell(new Phrase(" ")); cell.setColspan(1); cell.setBorderWidthBottom(0); cell.setBorderWidthLeft(0); cell.setBorder(0); cell.setBorderColorLeft(BaseColor.WHITE); cell.setBorderColorBottom(BaseColor.WHITE); cell.setPaddingBottom(5); table.addCell(cell); table.addCell(cell); table.addCell(cell); table.addCell(cell); cell = new PdfPCell(new Phrase("SUMA")); cell.setColspan(1); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setBackgroundColor(BaseColor.LIGHT_GRAY); cell.setPaddingBottom(5); table.addCell(cell); cell = new PdfPCell(new Phrase(df.format(factura.getCoste()) + " ", smallBold)); cell.setColspan(1); cell.setHorizontalAlignment(Element.ALIGN_RIGHT); cell.setPaddingBottom(5); table.addCell(cell); /* IVA */ cell = new PdfPCell(new Phrase(" ")); cell.setColspan(1); cell.setBorderWidthBottom(0); cell.setBorderWidthLeft(0); cell.setBorder(0); cell.setBorderColorLeft(BaseColor.WHITE); cell.setBorderColorBottom(BaseColor.WHITE); cell.setPaddingBottom(5); table.addCell(cell); table.addCell(cell); table.addCell(cell); table.addCell(cell); float costetotal = (float) (factura.getCostetotal()); cell = new PdfPCell(new Phrase("IVA " + iva + "%")); cell.setColspan(1); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setBackgroundColor(BaseColor.LIGHT_GRAY); cell.setPaddingBottom(5); table.addCell(cell); cell = new PdfPCell(new Phrase(df.format(factura.getIvas()) + " ", smallBold)); cell.setColspan(1); cell.setHorizontalAlignment(Element.ALIGN_RIGHT); cell.setPaddingBottom(5); table.addCell(cell); /* COSTE TOTAL */ cell = new PdfPCell(new Phrase(" ")); cell.setColspan(1); cell.setBorderWidthBottom(0); cell.setBorderWidthLeft(0); cell.setBorder(0); cell.setBorderColorLeft(BaseColor.WHITE); cell.setBorderColorBottom(BaseColor.WHITE); cell.setPaddingBottom(5); table.addCell(cell); table.addCell(cell); table.addCell(cell); table.addCell(cell); cell = new PdfPCell(new Phrase("TOTAL")); cell.setColspan(1); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setBackgroundColor(BaseColor.LIGHT_GRAY); cell.setPaddingBottom(5); table.addCell(cell); cell = new PdfPCell(new Phrase(df.format(costetotal) + " ", smallBold)); cell.setColspan(1); cell.setHorizontalAlignment(Element.ALIGN_RIGHT); cell.setPaddingBottom(5); table.addCell(cell); return table; }