List of usage examples for com.itextpdf.text BaseColor BaseColor
public BaseColor(final float red, final float green, final float blue)
From source file:GUI.Framenewventa.java
private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed if (jLabel17.getText().toString().equals("-")) { JOptionPane.showMessageDialog(rootPane, "DEBE SELECCIONAR UN CLIENTE"); } else {// ww w .j a va 2 s.co m try { setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); funciones f = new funciones(); String dia = (Calendar.getInstance().getTime().getDate() < 10) ? "0" + Calendar.getInstance().getTime().getDate() : Calendar.getInstance().getTime().getDate() + ""; String mes = f.get_mesMay((Calendar.getInstance().getTime().getMonth() + 1)); String anio = (Calendar.getInstance().getTime().getYear() + 1900) + ""; String nombre = "COTIZACION TIENDA ULTIMO ROUND"; String rut_socio = ""; int mon = 0; String arch = Calendar.getInstance().getTimeInMillis() + "_" + nombre + ".pdf"; DateFormat dateFormat = new SimpleDateFormat("yyyyMMdd"); Date date = new Date(); String stringToEncrypt = nombre.trim() + dateFormat.format(date); int encryptedString = stringToEncrypt.trim().hashCode(); String aRemplazar = Integer.toString(encryptedString); String remplazado = aRemplazar.replace("-", ""); String url = f.getRutaCotizacion() + arch; FileOutputStream archivo = new FileOutputStream(url); int deuda = Integer.parseInt("1"); String palabra = f.Convertir(deuda + "", false); palabra = palabra.substring(0, palabra.length() - 2); if (palabra.split(" ")[palabra.split(" ").length - 1].equals("millones") | palabra.split(" ")[palabra.split(" ").length - 1].equals("milln")) { palabra = palabra + "de pesos"; } else { palabra = palabra + "pesos"; } Document documento = new Document(PageSize.LETTER); PdfWriter.getInstance(documento, archivo); documento.open(); try { Image im = Image.getInstance(f.getRutaCotizacion() + "headerword.png"); im.setAlignment(Image.ALIGN_CENTER); im.scaleToFit(600, 400); documento.add(im); } catch (Exception e) { setCursor(Cursor.getDefaultCursor()); JOptionPane.showConfirmDialog(null, "HA OCURRIDO UN ERROR AL INTENTAR AGREGAR EL ENCABEZADO.", "ERROR", JOptionPane.PLAIN_MESSAGE, JOptionPane.ERROR_MESSAGE); } int linea = 0; Font fuente = new Font(); fuente.setStyle(Font.UNDERLINE | Font.BOLD); fuente.setSize(11); fuente.setColor(BaseColor.BLACK); documento.add(new Paragraph(" ")); Paragraph fecha = new Paragraph(dia + " de " + mes.toLowerCase() + " de " + anio + "\n", FontFactory.getFont("times new roman", 8, Font.NORMAL, BaseColor.BLACK)); fecha.setAlignment(Paragraph.ALIGN_RIGHT); documento.add(fecha); Paragraph obp = new Paragraph("ULTIMO ROUND\n", FontFactory.getFont("times new roman", 8, Font.NORMAL, BaseColor.BLACK)); obp.setAlignment(Paragraph.ALIGN_RIGHT); documento.add(obp); Paragraph codigo = new Paragraph("COD." + remplazado, FontFactory.getFont("times new roman", 8, Font.NORMAL, BaseColor.BLACK)); codigo.setAlignment(Paragraph.ALIGN_RIGHT); documento.add(codigo); Paragraph space = new Paragraph("\n", FontFactory.getFont("times new roman", 10, Font.BOLD, BaseColor.BLACK)); space.setAlignment(Paragraph.ALIGN_LEFT); documento.add(space); Paragraph origen = new Paragraph("ESTIMADO CLIENTE: " + jLabel13.getText() + "\n", FontFactory.getFont("times new roman", 10, Font.NORMAL, BaseColor.BLACK)); origen.setAlignment(Paragraph.ALIGN_LEFT); documento.add(origen); Paragraph origen2 = new Paragraph("EMAIL: " + jLabel15.getText() + "\n", FontFactory.getFont("times new roman", 10, Font.NORMAL, BaseColor.BLACK)); origen2.setAlignment(Paragraph.ALIGN_LEFT); documento.add(origen2); Paragraph a = new Paragraph(nombre, FontFactory.getFont("times new roman", 10, Font.NORMAL, BaseColor.BLACK)); a.setAlignment(Paragraph.ALIGN_LEFT); documento.add(a); Paragraph rut = new Paragraph(rut_socio, FontFactory.getFont("times new roman", 10, Font.NORMAL, BaseColor.BLACK)); rut.setAlignment(Paragraph.ALIGN_LEFT); documento.add(rut); Paragraph ref = new Paragraph("REF:COTIZACION POR PRODUCTOS TIENDA ULTIMO ROUND\n", FontFactory.getFont("times new roman", 10, Font.BOLD, BaseColor.BLACK)); ref.setAlignment(Paragraph.ALIGN_RIGHT); documento.add(ref); documento.add(space); int numerocheque = 0; int montofinal = 0; String montostring = ""; String detalle = ""; String monto = jLabel22.getText(); String montoaux = monto.replace(".", ""); deuda = Integer.parseInt(montoaux); palabra = f.Convertir(deuda + "", false); System.out.println(palabra); palabra = palabra.replaceAll("0", ""); System.out.println(palabra); Paragraph e = new Paragraph( "Junto con saludarlo, adjunto la cotizacin detallada de los siguientes productos" + " por el monto de $" + monto + ".- ( " + palabra + "pesos IVA INCLUIDO) ,segn detalle:\n\n", FontFactory.getFont("times new roman", 11, Font.NORMAL, BaseColor.BLACK)); e.setAlignment(Paragraph.ALIGN_LEFT); documento.add(e); documento.add(new Paragraph(" ")); // ACA DEBE IR LA TABLA //special font sizes Font bfBold10 = new Font(Font.FontFamily.TIMES_ROMAN, 10, Font.BOLD, new BaseColor(0, 0, 0)); Font bf10 = new Font(Font.FontFamily.TIMES_ROMAN, 10); //specify column widths //create PDF table with the given widths documento.add(new Paragraph(" ")); float[] colsWidth = { 1.5f, 1.5f, 1.5f, 1.5f, 1.5f }; PdfPTable tabla = new PdfPTable(5); tabla.setWidths(colsWidth); String[] titulos = { "PRODUCTO", "VALOR PRODUCTO", "TIPO", "MARCA", "TALLA" }; tabla.setWidthPercentage(100); PdfPCell celda; for (int k = 0; k < titulos.length; k++) { celda = new PdfPCell(new Paragraph(titulos[k], FontFactory.getFont("times new roman", 10, java.awt.Font.BOLD, BaseColor.BLACK))); celda.setHorizontalAlignment(Element.ALIGN_CENTER); tabla.addCell(celda); } int var = 0; int w = 0; for (w = 0; w < jTable1.getRowCount(); w++) { celda = new PdfPCell(new Paragraph(jTable1.getValueAt(w, 1).toString(), FontFactory .getFont("times new roman", 10, java.awt.Font.ROMAN_BASELINE, BaseColor.BLACK))); celda.setHorizontalAlignment(Element.ALIGN_CENTER); tabla.addCell(celda); celda = new PdfPCell(new Paragraph(jTable1.getValueAt(w, 7).toString(), FontFactory .getFont("times new roman", 10, java.awt.Font.ROMAN_BASELINE, BaseColor.BLACK))); celda.setHorizontalAlignment(Element.ALIGN_CENTER); tabla.addCell(celda); celda = new PdfPCell(new Paragraph(jTable1.getValueAt(w, 4).toString(), FontFactory .getFont("times new roman", 10, java.awt.Font.ROMAN_BASELINE, BaseColor.BLACK))); celda.setHorizontalAlignment(Element.ALIGN_CENTER); tabla.addCell(celda); celda = new PdfPCell(new Paragraph(jTable1.getValueAt(w, 3).toString(), FontFactory .getFont("times new roman", 10, java.awt.Font.ROMAN_BASELINE, BaseColor.BLACK))); celda.setHorizontalAlignment(Element.ALIGN_CENTER); tabla.addCell(celda); celda = new PdfPCell(new Paragraph(jTable1.getValueAt(w, 2).toString(), FontFactory .getFont("times new roman", 10, java.awt.Font.ROMAN_BASELINE, BaseColor.BLACK))); celda.setHorizontalAlignment(Element.ALIGN_CENTER); tabla.addCell(celda); } celda = new PdfPCell(new Paragraph("", FontFactory.getFont("times new roman", 10, java.awt.Font.ROMAN_BASELINE, BaseColor.BLACK))); celda.setHorizontalAlignment(Element.ALIGN_CENTER); tabla.addCell(celda); celda = new PdfPCell(new Paragraph("", FontFactory.getFont("times new roman", 10, java.awt.Font.ROMAN_BASELINE, BaseColor.BLACK))); celda.setHorizontalAlignment(Element.ALIGN_CENTER); tabla.addCell(celda); celda = new PdfPCell(new Paragraph("", FontFactory.getFont("times new roman", 10, java.awt.Font.ROMAN_BASELINE, BaseColor.BLACK))); celda.setHorizontalAlignment(Element.ALIGN_CENTER); tabla.addCell(celda); celda = new PdfPCell(new Paragraph("", FontFactory.getFont("times new roman", 10, java.awt.Font.BOLD, BaseColor.BLACK))); celda.setHorizontalAlignment(Element.ALIGN_CENTER); tabla.addCell(celda); celda = new PdfPCell(new Paragraph("", FontFactory.getFont("times new roman", 10, java.awt.Font.ROMAN_BASELINE, BaseColor.BLACK))); celda.setHorizontalAlignment(Element.ALIGN_CENTER); tabla.addCell(celda); celda = new PdfPCell(new Paragraph("", FontFactory.getFont("times new roman", 10, java.awt.Font.ROMAN_BASELINE, BaseColor.BLACK))); celda.setHorizontalAlignment(Element.ALIGN_CENTER); tabla.addCell(celda); celda = new PdfPCell(new Paragraph("", FontFactory.getFont("times new roman", 10, java.awt.Font.ROMAN_BASELINE, BaseColor.BLACK))); celda.setHorizontalAlignment(Element.ALIGN_CENTER); tabla.addCell(celda); celda = new PdfPCell(new Paragraph("", FontFactory.getFont("times new roman", 10, java.awt.Font.ROMAN_BASELINE, BaseColor.BLACK))); celda.setHorizontalAlignment(Element.ALIGN_CENTER); tabla.addCell(celda); celda = new PdfPCell(new Paragraph("MONTO NETO", FontFactory.getFont("times new roman", 10, java.awt.Font.BOLD, BaseColor.BLACK))); celda.setHorizontalAlignment(Element.ALIGN_CENTER); tabla.addCell(celda); celda = new PdfPCell(new Paragraph(monto, FontFactory.getFont("times new roman", 10, java.awt.Font.ROMAN_BASELINE, BaseColor.BLACK))); celda.setHorizontalAlignment(Element.ALIGN_CENTER); tabla.addCell(celda); celda = new PdfPCell(new Paragraph("", FontFactory.getFont("times new roman", 10, java.awt.Font.ROMAN_BASELINE, BaseColor.BLACK))); celda.setHorizontalAlignment(Element.ALIGN_CENTER); tabla.addCell(celda); celda = new PdfPCell(new Paragraph("", FontFactory.getFont("times new roman", 10, java.awt.Font.ROMAN_BASELINE, BaseColor.BLACK))); celda.setHorizontalAlignment(Element.ALIGN_CENTER); tabla.addCell(celda); celda = new PdfPCell(new Paragraph("", FontFactory.getFont("times new roman", 10, java.awt.Font.ROMAN_BASELINE, BaseColor.BLACK))); celda.setHorizontalAlignment(Element.ALIGN_CENTER); tabla.addCell(celda); celda = new PdfPCell(new Paragraph("IVA TOTAL", FontFactory.getFont("times new roman", 10, java.awt.Font.BOLD, BaseColor.BLACK))); celda.setHorizontalAlignment(Element.ALIGN_CENTER); tabla.addCell(celda); double iva2 = Float.parseFloat(monto) * (0.19); iva2 = Math.round(iva2); celda = new PdfPCell(new Paragraph(Double.toString(iva2), FontFactory.getFont("times new roman", 10, java.awt.Font.ROMAN_BASELINE, BaseColor.BLACK))); celda.setHorizontalAlignment(Element.ALIGN_CENTER); tabla.addCell(celda); celda = new PdfPCell(new Paragraph("", FontFactory.getFont("times new roman", 10, java.awt.Font.ROMAN_BASELINE, BaseColor.BLACK))); celda.setHorizontalAlignment(Element.ALIGN_CENTER); tabla.addCell(celda); celda = new PdfPCell(new Paragraph("", FontFactory.getFont("times new roman", 10, java.awt.Font.ROMAN_BASELINE, BaseColor.BLACK))); celda.setHorizontalAlignment(Element.ALIGN_CENTER); tabla.addCell(celda); celda = new PdfPCell(new Paragraph("", FontFactory.getFont("times new roman", 10, java.awt.Font.ROMAN_BASELINE, BaseColor.BLACK))); celda.setHorizontalAlignment(Element.ALIGN_CENTER); tabla.addCell(celda); celda = new PdfPCell(new Paragraph("VALOR TOTAL", FontFactory.getFont("times new roman", 10, java.awt.Font.BOLD, BaseColor.BLACK))); celda.setHorizontalAlignment(Element.ALIGN_CENTER); tabla.addCell(celda); int valortotal = Integer.parseInt(monto); ; celda = new PdfPCell(new Paragraph(Integer.toString(valortotal), FontFactory.getFont("times new roman", 10, java.awt.Font.ROMAN_BASELINE, BaseColor.BLACK))); celda.setHorizontalAlignment(Element.ALIGN_CENTER); tabla.addCell(celda); documento.add(tabla); //FOOOTER documento.add(space); Paragraph despido = new Paragraph("Quedando a vuestra disposicin, saluda atentamente a Ud.,\n", FontFactory.getFont("times new roman", 10, Font.NORMAL, BaseColor.BLACK)); despido.setAlignment(Paragraph.ALIGN_LEFT); documento.add(despido); documento.add(space); Paragraph firma2 = new Paragraph("TIENDA ULTIMO ROUND\n", FontFactory.getFont("times new roman", 10, Font.NORMAL, BaseColor.BLACK)); firma2.setAlignment(Paragraph.ALIGN_RIGHT); documento.add(firma2); documento.add(space); documento.add(space); documento.add(space); Paragraph firma3 = new Paragraph("Cotizacin vlida por siete das\n", FontFactory.getFont("times new roman", 10, Font.NORMAL, BaseColor.BLACK)); firma3.setAlignment(Paragraph.ALIGN_CENTER); documento.add(firma3); documento.add(space); documento.add(space); try { Image im = Image.getInstance(f.getRutaCotizacion() + "footerword.png"); im.setAlignment(Image.ALIGN_CENTER); im.scaleToFit(600, 500); documento.add(im); } catch (Exception ex) { setCursor(Cursor.getDefaultCursor()); JOptionPane.showConfirmDialog(null, "HA OCURRIDO UN ERROR AL INTENTAR AGREGAR EL PIE DE PAGINA.", "ERROR", JOptionPane.PLAIN_MESSAGE, JOptionPane.ERROR_MESSAGE); } documento.close(); setCursor(Cursor.getDefaultCursor()); JOptionPane.showConfirmDialog(null, "REALIZADO CORRECTAMENTE", "INFORMACIN", JOptionPane.PLAIN_MESSAGE, JOptionPane.INFORMATION_MESSAGE); } catch (Exception ex) { setCursor(Cursor.getDefaultCursor()); JOptionPane.showConfirmDialog(null, "ERROR" + ex.getMessage(), "ERROR", JOptionPane.PLAIN_MESSAGE, JOptionPane.ERROR_MESSAGE); } } }
From source file:GUI.frameNewVentaKit.java
private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed if (jLabel17.getText().toString().equals("-")) { JOptionPane.showMessageDialog(rootPane, "DEBE SELECCIONAR UN CLIENTE"); } else {/* w w w. ja v a2s .co m*/ try { setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); funciones f = new funciones(); String dia = (Calendar.getInstance().getTime().getDate() < 10) ? "0" + Calendar.getInstance().getTime().getDate() : Calendar.getInstance().getTime().getDate() + ""; String mes = f.get_mesMay((Calendar.getInstance().getTime().getMonth() + 1)); String anio = (Calendar.getInstance().getTime().getYear() + 1900) + ""; String nombre = "COTIZACION TIENDA ULTIMO ROUND"; String rut_socio = ""; int mon = 0; String arch = Calendar.getInstance().getTimeInMillis() + "_" + nombre + ".pdf"; DateFormat dateFormat = new SimpleDateFormat("yyyyMMdd"); Date date = new Date(); String stringToEncrypt = nombre.trim() + dateFormat.format(date); int encryptedString = stringToEncrypt.trim().hashCode(); String aRemplazar = Integer.toString(encryptedString); String remplazado = aRemplazar.replace("-", ""); String url = f.getRutaCotizacion() + arch; FileOutputStream archivo = new FileOutputStream(url); int deuda = Integer.parseInt("1"); String palabra = f.Convertir(deuda + "", false); palabra = palabra.substring(0, palabra.length() - 2); if (palabra.split(" ")[palabra.split(" ").length - 1].equals("millones") | palabra.split(" ")[palabra.split(" ").length - 1].equals("milln")) { palabra = palabra + "de pesos"; } else { palabra = palabra + "pesos"; } Document documento = new Document(PageSize.LETTER); PdfWriter.getInstance(documento, archivo); documento.open(); try { Image im = Image.getInstance(f.getRutaCotizacion() + "headerword.png"); im.setAlignment(Image.ALIGN_CENTER); im.scaleToFit(600, 400); documento.add(im); } catch (Exception e) { setCursor(Cursor.getDefaultCursor()); JOptionPane.showConfirmDialog(null, "HA OCURRIDO UN ERROR AL INTENTAR AGREGAR EL ENCABEZADO.", "ERROR", JOptionPane.PLAIN_MESSAGE, JOptionPane.ERROR_MESSAGE); } int linea = 0; Font fuente = new Font(); fuente.setStyle(Font.UNDERLINE | Font.BOLD); fuente.setSize(11); fuente.setColor(BaseColor.BLACK); documento.add(new Paragraph(" ")); Paragraph fecha = new Paragraph(dia + " de " + mes.toLowerCase() + " de " + anio + "\n", FontFactory.getFont("times new roman", 8, Font.NORMAL, BaseColor.BLACK)); fecha.setAlignment(Paragraph.ALIGN_RIGHT); documento.add(fecha); Paragraph obp = new Paragraph("ULTIMO ROUND\n", FontFactory.getFont("times new roman", 8, Font.NORMAL, BaseColor.BLACK)); obp.setAlignment(Paragraph.ALIGN_RIGHT); documento.add(obp); Paragraph codigo = new Paragraph("COD." + remplazado, FontFactory.getFont("times new roman", 8, Font.NORMAL, BaseColor.BLACK)); codigo.setAlignment(Paragraph.ALIGN_RIGHT); documento.add(codigo); Paragraph space = new Paragraph("\n", FontFactory.getFont("times new roman", 10, Font.BOLD, BaseColor.BLACK)); space.setAlignment(Paragraph.ALIGN_LEFT); documento.add(space); Paragraph origen = new Paragraph("ESTIMADO CLIENTE: " + jLabel13.getText() + "\n", FontFactory.getFont("times new roman", 10, Font.NORMAL, BaseColor.BLACK)); origen.setAlignment(Paragraph.ALIGN_LEFT); documento.add(origen); Paragraph origen2 = new Paragraph("EMAIL: " + jLabel15.getText() + "\n", FontFactory.getFont("times new roman", 10, Font.NORMAL, BaseColor.BLACK)); origen2.setAlignment(Paragraph.ALIGN_LEFT); documento.add(origen2); Paragraph a = new Paragraph(nombre, FontFactory.getFont("times new roman", 10, Font.NORMAL, BaseColor.BLACK)); a.setAlignment(Paragraph.ALIGN_LEFT); documento.add(a); Paragraph rut = new Paragraph(rut_socio, FontFactory.getFont("times new roman", 10, Font.NORMAL, BaseColor.BLACK)); rut.setAlignment(Paragraph.ALIGN_LEFT); documento.add(rut); Paragraph ref = new Paragraph("REF:COTIZACION POR PRODUCTOS TIENDA ULTIMO ROUND\n", FontFactory.getFont("times new roman", 10, Font.BOLD, BaseColor.BLACK)); ref.setAlignment(Paragraph.ALIGN_RIGHT); documento.add(ref); documento.add(space); int numerocheque = 0; int montofinal = 0; String montostring = ""; String detalle = ""; String monto = jLabel22.getText(); String montoaux = monto.replace(".", ""); deuda = Integer.parseInt(montoaux); palabra = f.Convertir(deuda + "", false); System.out.println(palabra); palabra = palabra.replaceAll("0", ""); System.out.println(palabra); Paragraph e = new Paragraph( "Junto con saludarlo, adjunto la cotizacin detallada de los siguientes productos" + " por el monto de $" + monto + ".- ( " + palabra + "pesos IVA INCLUIDO) ,segn detalle:\n\n", FontFactory.getFont("times new roman", 11, Font.NORMAL, BaseColor.BLACK)); e.setAlignment(Paragraph.ALIGN_LEFT); documento.add(e); documento.add(new Paragraph(" ")); // ACA DEBE IR LA TABLA //special font sizes Font bfBold10 = new Font(Font.FontFamily.TIMES_ROMAN, 10, Font.BOLD, new BaseColor(0, 0, 0)); Font bf10 = new Font(Font.FontFamily.TIMES_ROMAN, 10); //specify column widths //create PDF table with the given widths documento.add(new Paragraph(" ")); float[] colsWidth = { 1.5f, 1.5f, 1.5f, 1.5f, 1.5f }; PdfPTable tabla = new PdfPTable(5); tabla.setWidths(colsWidth); String[] titulos = { "PRODUCTO", "VALOR PRODUCTO", "TIPO", "MARCA", "TALLA" }; tabla.setWidthPercentage(100); PdfPCell celda; for (int k = 0; k < titulos.length; k++) { celda = new PdfPCell(new Paragraph(titulos[k], FontFactory.getFont("times new roman", 10, java.awt.Font.BOLD, BaseColor.BLACK))); celda.setHorizontalAlignment(Element.ALIGN_CENTER); tabla.addCell(celda); } int var = 0; int w = 0; for (w = 0; w < jTable1.getRowCount(); w++) { celda = new PdfPCell(new Paragraph(jTable1.getValueAt(w, 1).toString(), FontFactory .getFont("times new roman", 10, java.awt.Font.ROMAN_BASELINE, BaseColor.BLACK))); celda.setHorizontalAlignment(Element.ALIGN_CENTER); tabla.addCell(celda); celda = new PdfPCell(new Paragraph(jTable1.getValueAt(w, 7).toString(), FontFactory .getFont("times new roman", 10, java.awt.Font.ROMAN_BASELINE, BaseColor.BLACK))); celda.setHorizontalAlignment(Element.ALIGN_CENTER); tabla.addCell(celda); celda = new PdfPCell(new Paragraph(jTable1.getValueAt(w, 4).toString(), FontFactory .getFont("times new roman", 10, java.awt.Font.ROMAN_BASELINE, BaseColor.BLACK))); celda.setHorizontalAlignment(Element.ALIGN_CENTER); tabla.addCell(celda); celda = new PdfPCell(new Paragraph(jTable1.getValueAt(w, 3).toString(), FontFactory .getFont("times new roman", 10, java.awt.Font.ROMAN_BASELINE, BaseColor.BLACK))); celda.setHorizontalAlignment(Element.ALIGN_CENTER); tabla.addCell(celda); celda = new PdfPCell(new Paragraph(jTable1.getValueAt(w, 2).toString(), FontFactory .getFont("times new roman", 10, java.awt.Font.ROMAN_BASELINE, BaseColor.BLACK))); celda.setHorizontalAlignment(Element.ALIGN_CENTER); tabla.addCell(celda); } celda = new PdfPCell(new Paragraph("", FontFactory.getFont("times new roman", 10, java.awt.Font.ROMAN_BASELINE, BaseColor.BLACK))); celda.setHorizontalAlignment(Element.ALIGN_CENTER); tabla.addCell(celda); celda = new PdfPCell(new Paragraph("", FontFactory.getFont("times new roman", 10, java.awt.Font.ROMAN_BASELINE, BaseColor.BLACK))); celda.setHorizontalAlignment(Element.ALIGN_CENTER); tabla.addCell(celda); celda = new PdfPCell(new Paragraph("", FontFactory.getFont("times new roman", 10, java.awt.Font.ROMAN_BASELINE, BaseColor.BLACK))); celda.setHorizontalAlignment(Element.ALIGN_CENTER); tabla.addCell(celda); celda = new PdfPCell(new Paragraph("", FontFactory.getFont("times new roman", 10, java.awt.Font.BOLD, BaseColor.BLACK))); celda.setHorizontalAlignment(Element.ALIGN_CENTER); tabla.addCell(celda); celda = new PdfPCell(new Paragraph("", FontFactory.getFont("times new roman", 10, java.awt.Font.ROMAN_BASELINE, BaseColor.BLACK))); celda.setHorizontalAlignment(Element.ALIGN_CENTER); tabla.addCell(celda); celda = new PdfPCell(new Paragraph("", FontFactory.getFont("times new roman", 10, java.awt.Font.ROMAN_BASELINE, BaseColor.BLACK))); celda.setHorizontalAlignment(Element.ALIGN_CENTER); tabla.addCell(celda); celda = new PdfPCell(new Paragraph("", FontFactory.getFont("times new roman", 10, java.awt.Font.ROMAN_BASELINE, BaseColor.BLACK))); celda.setHorizontalAlignment(Element.ALIGN_CENTER); tabla.addCell(celda); celda = new PdfPCell(new Paragraph("", FontFactory.getFont("times new roman", 10, java.awt.Font.ROMAN_BASELINE, BaseColor.BLACK))); celda.setHorizontalAlignment(Element.ALIGN_CENTER); tabla.addCell(celda); celda = new PdfPCell(new Paragraph("MONTO NETO", FontFactory.getFont("times new roman", 10, java.awt.Font.BOLD, BaseColor.BLACK))); celda.setHorizontalAlignment(Element.ALIGN_CENTER); tabla.addCell(celda); celda = new PdfPCell(new Paragraph(monto, FontFactory.getFont("times new roman", 10, java.awt.Font.ROMAN_BASELINE, BaseColor.BLACK))); celda.setHorizontalAlignment(Element.ALIGN_CENTER); tabla.addCell(celda); celda = new PdfPCell(new Paragraph("", FontFactory.getFont("times new roman", 10, java.awt.Font.ROMAN_BASELINE, BaseColor.BLACK))); celda.setHorizontalAlignment(Element.ALIGN_CENTER); tabla.addCell(celda); celda = new PdfPCell(new Paragraph("", FontFactory.getFont("times new roman", 10, java.awt.Font.ROMAN_BASELINE, BaseColor.BLACK))); celda.setHorizontalAlignment(Element.ALIGN_CENTER); tabla.addCell(celda); celda = new PdfPCell(new Paragraph("", FontFactory.getFont("times new roman", 10, java.awt.Font.ROMAN_BASELINE, BaseColor.BLACK))); celda.setHorizontalAlignment(Element.ALIGN_CENTER); tabla.addCell(celda); celda = new PdfPCell(new Paragraph("IVA TOTAL", FontFactory.getFont("times new roman", 10, java.awt.Font.BOLD, BaseColor.BLACK))); celda.setHorizontalAlignment(Element.ALIGN_CENTER); tabla.addCell(celda); double iva2 = Float.parseFloat(monto) * (0.19); iva2 = Math.round(iva2); celda = new PdfPCell(new Paragraph(Double.toString(iva2), FontFactory.getFont("times new roman", 10, java.awt.Font.ROMAN_BASELINE, BaseColor.BLACK))); celda.setHorizontalAlignment(Element.ALIGN_CENTER); tabla.addCell(celda); celda = new PdfPCell(new Paragraph("", FontFactory.getFont("times new roman", 10, java.awt.Font.ROMAN_BASELINE, BaseColor.BLACK))); celda.setHorizontalAlignment(Element.ALIGN_CENTER); tabla.addCell(celda); celda = new PdfPCell(new Paragraph("", FontFactory.getFont("times new roman", 10, java.awt.Font.ROMAN_BASELINE, BaseColor.BLACK))); celda.setHorizontalAlignment(Element.ALIGN_CENTER); tabla.addCell(celda); celda = new PdfPCell(new Paragraph("", FontFactory.getFont("times new roman", 10, java.awt.Font.ROMAN_BASELINE, BaseColor.BLACK))); celda.setHorizontalAlignment(Element.ALIGN_CENTER); tabla.addCell(celda); celda = new PdfPCell(new Paragraph("VALOR TOTAL", FontFactory.getFont("times new roman", 10, java.awt.Font.BOLD, BaseColor.BLACK))); celda.setHorizontalAlignment(Element.ALIGN_CENTER); tabla.addCell(celda); int valortotal = Integer.parseInt(monto); celda = new PdfPCell(new Paragraph(Integer.toString(valortotal), FontFactory.getFont("times new roman", 10, java.awt.Font.ROMAN_BASELINE, BaseColor.BLACK))); celda.setHorizontalAlignment(Element.ALIGN_CENTER); tabla.addCell(celda); documento.add(tabla); //FOOOTER documento.add(space); Paragraph despido = new Paragraph("Quedando a vuestra disposicin, saluda atentamente a Ud.,\n", FontFactory.getFont("times new roman", 10, Font.NORMAL, BaseColor.BLACK)); despido.setAlignment(Paragraph.ALIGN_LEFT); documento.add(despido); documento.add(space); Paragraph firma2 = new Paragraph("TIENDA ULTIMO ROUND\n", FontFactory.getFont("times new roman", 10, Font.NORMAL, BaseColor.BLACK)); firma2.setAlignment(Paragraph.ALIGN_RIGHT); documento.add(firma2); documento.add(space); documento.add(space); documento.add(space); Paragraph firma3 = new Paragraph("Cotizacin vlida por siete das\n", FontFactory.getFont("times new roman", 10, Font.NORMAL, BaseColor.BLACK)); firma3.setAlignment(Paragraph.ALIGN_CENTER); documento.add(firma3); documento.add(space); documento.add(space); try { Image im = Image.getInstance(f.getRutaCotizacion() + "footerword.png"); im.setAlignment(Image.ALIGN_CENTER); im.scaleToFit(600, 500); documento.add(im); } catch (Exception ex) { setCursor(Cursor.getDefaultCursor()); JOptionPane.showConfirmDialog(null, "HA OCURRIDO UN ERROR AL INTENTAR AGREGAR EL PIE DE PAGINA.", "ERROR", JOptionPane.PLAIN_MESSAGE, JOptionPane.ERROR_MESSAGE); } documento.close(); setCursor(Cursor.getDefaultCursor()); JOptionPane.showConfirmDialog(null, "REALIZADO CORRECTAMENTE", "INFORMACIN", JOptionPane.PLAIN_MESSAGE, JOptionPane.INFORMATION_MESSAGE); } catch (Exception ex) { setCursor(Cursor.getDefaultCursor()); JOptionPane.showConfirmDialog(null, "ERROR" + ex.getMessage(), "ERROR", JOptionPane.PLAIN_MESSAGE, JOptionPane.ERROR_MESSAGE); } } }
From source file:mkl.testarea.itext5.pdfcleanup.StrictPdfCleanUpProcessor.java
License:Open Source License
/** * Extracts locations from the concrete annotation. * Note: annotation can consist not only of one area specified by the RECT entry, but also of multiple areas specified * by the QuadPoints entry in the annotation dictionary. *///from w w w . j a va 2s. c o m private List<PdfCleanUpLocation> extractLocationsFromRedactAnnot(int page, int annotIndex, PdfDictionary annotDict) { List<PdfCleanUpLocation> locations = new ArrayList<PdfCleanUpLocation>(); List<Rectangle> markedRectangles = new ArrayList<Rectangle>(); PdfArray quadPoints = annotDict.getAsArray(PdfName.QUADPOINTS); if (quadPoints.size() != 0) { markedRectangles.addAll(translateQuadPointsToRectangles(quadPoints)); } else { PdfArray annotRect = annotDict.getAsArray(PdfName.RECT); markedRectangles .add(new Rectangle(annotRect.getAsNumber(0).floatValue(), annotRect.getAsNumber(1).floatValue(), annotRect.getAsNumber(2).floatValue(), annotRect.getAsNumber(3).floatValue())); } clippingRects.put(annotIndex, markedRectangles); BaseColor cleanUpColor = null; PdfArray ic = annotDict.getAsArray(PdfName.IC); if (ic != null) { cleanUpColor = new BaseColor(ic.getAsNumber(0).floatValue(), ic.getAsNumber(1).floatValue(), ic.getAsNumber(2).floatValue()); } PdfStream ro = annotDict.getAsStream(PdfName.RO); if (ro != null) { cleanUpColor = null; } for (Rectangle rect : markedRectangles) { locations.add(new PdfCleanUpLocation(page, rect, cleanUpColor)); } return locations; }
From source file:Model.Emprestimo.java
private void resultado() { Document documento = new Document(); Livro l;/* w ww . ja va 2s. c om*/ try { PdfWriter.getInstance(documento, new FileOutputStream("Emprestimo" + id() + ".pdf")); } catch (DocumentException ex) { Logger.getLogger(Emprestimo.class.getName()).log(Level.SEVERE, null, ex); } catch (FileNotFoundException ex) { Logger.getLogger(Emprestimo.class.getName()).log(Level.SEVERE, null, ex); } documento.open(); try { Paragraph pa = new Paragraph(); Font fonte = new Font(Font.FontFamily.TIMES_ROMAN, 28, Font.BOLD, new BaseColor(0, 0, 225)); pa.setFont(fonte); pa.setAlignment(Element.ALIGN_CENTER); pa.setSpacingAfter(50); pa.add("Emprestimo"); documento.add(pa); fonte = new Font(Font.FontFamily.TIMES_ROMAN, 12, Font.BOLD, new BaseColor(0, 0, 0)); pa = new Paragraph(); pa.setFont(fonte); pa.setAlignment(Element.ALIGN_LEFT); pa.add("id: " + Integer.toString(id())); documento.add(pa); pa = new Paragraph(); pa.setFont(fonte); pa.setAlignment(Element.ALIGN_LEFT); pa.add("ra: " + Integer.toString(this.getRa())); documento.add(pa); String lin = ""; String[] h = this.Livros.split("/"); for (int c = 0; c < h.length; c++) { l = new Livro(); l.consultar(Integer.parseInt(h[c])); lin = lin + l.getNome() + "\n"; } pa = new Paragraph(); pa.setFont(fonte); pa.setAlignment(Element.ALIGN_LEFT); pa.add("Livros: " + lin); documento.add(pa); pa = new Paragraph(); pa.setFont(fonte); pa.setAlignment(Element.ALIGN_LEFT); pa.add("Data de Realizao: " + this.dataR); documento.add(pa); pa = new Paragraph(); pa.setFont(fonte); pa.setAlignment(Element.ALIGN_LEFT); pa.add("Data de Devoluo: " + this.dataD); documento.add(pa); } catch (DocumentException ex) { Logger.getLogger(Emprestimo.class.getName()).log(Level.SEVERE, null, ex); } documento.close(); }
From source file:Model.MyFontSelector.java
License:Open Source License
/** * Inicializa as fontes//from ww w. ja v a2 s . c o m * Initialize the fonts * @param baseFontList A List with the BaseFonts */ private void initFonts(ArrayList<BaseFont> baseFontList) { FontSelector fontSelectorTitle = new FontSelector(); FontSelector fontSelectorBlue = new FontSelector(); FontSelector fontSelectorGreen = new FontSelector(); FontSelector fontSelectorRed = new FontSelector(); FontSelector fontSelectorBlack = new FontSelector(); for (BaseFont bf : baseFontList) { Font TITLE = new Font(bf, 16, Font.BOLD, BaseColor.BLACK); Font BLUE = new Font(bf, 14, Font.NORMAL, BaseColor.BLUE); Font GREEN = new Font(bf, 14, Font.NORMAL, new BaseColor(8, 138, 75)); Font RED = new Font(bf, 14, Font.NORMAL, BaseColor.RED); Font BLACK = new Font(bf, 14, Font.NORMAL, BaseColor.BLACK); fontSelectorTitle.addFont(TITLE); fontSelectorBlue.addFont(BLUE); fontSelectorGreen.addFont(GREEN); fontSelectorRed.addFont(RED); fontSelectorBlack.addFont(BLACK); } fontSelectors.put("TITLE", fontSelectorTitle); fontSelectors.put("BLUE", fontSelectorBlue); fontSelectors.put("GREEN", fontSelectorGreen); fontSelectors.put("RED", fontSelectorRed); fontSelectors.put("BLACK", fontSelectorBlack); }
From source file:model.PDFModel.java
License:Open Source License
public PdfPTable createTablePDFTable(int counter, String raportDate) { JTable resultTable = query.getProductsInTablePDFTable(raportDate, counter); PdfPTable[] tableTable = new PdfPTable[11]; PdfPCell cell, productNameCell, paymentCell, countCell, priceCell; tableTable[counter] = new PdfPTable(4); tableTable[counter].setSpacingBefore(5f); tableTable[counter].setSpacingAfter(5f); totalTablePayment[counter] = 0.00;//from ww w. j a va2 s . c o m if (resultTable != null) { DefaultTableModel resultTableModel = (DefaultTableModel) resultTable.getModel(); if (resultTableModel.getRowCount() > 0) { cell = new PdfPCell(new Phrase("Stolik " + (counter))); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setBackgroundColor(new BaseColor(80, 255, 50)); tableTable[counter].addCell(cell); cell = new PdfPCell(); cell.setBorder(Rectangle.NO_BORDER); tableTable[counter].addCell(cell); cell = new PdfPCell(); cell.setBorder(Rectangle.NO_BORDER); tableTable[counter].addCell(cell); cell = new PdfPCell(); cell.setBorder(Rectangle.NO_BORDER); tableTable[counter].addCell(cell); cell = new PdfPCell(new Phrase("Produkt")); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setBackgroundColor(new BaseColor(80, 172, 8)); tableTable[counter].addCell(cell); cell = new PdfPCell(new Phrase("Ilosc")); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setBackgroundColor(new BaseColor(80, 172, 8)); tableTable[counter].addCell(cell); cell = new PdfPCell(new Phrase("Cena jednostkowa")); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setBackgroundColor(new BaseColor(80, 172, 8)); tableTable[counter].addCell(cell); cell = new PdfPCell(new Phrase("Zaplata")); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setBackgroundColor(new BaseColor(80, 172, 8)); tableTable[counter].addCell(cell); for (int i = 0; i < resultTableModel.getRowCount(); i++) { productNameCell = new PdfPCell(new Phrase(resultTableModel.getValueAt(i, 0).toString(), FontFactory.getFont(FontFactory.defaultEncoding, 10, Font.NORMAL, BaseColor.BLACK))); productNameCell.setHorizontalAlignment(Element.ALIGN_CENTER); productNameCell.setBackgroundColor(new BaseColor(80, 135, 8)); tableTable[counter].addCell(productNameCell); countCell = new PdfPCell(new Phrase(String.valueOf(resultTableModel.getValueAt(i, 2)))); countCell.setHorizontalAlignment(Element.ALIGN_CENTER); tableTable[counter].addCell(countCell); double payment = Double.parseDouble(resultTableModel.getValueAt(i, 1).toString()) * Double.parseDouble(resultTableModel.getValueAt(i, 2).toString()); totalTablePayment[counter] += payment; paymentCell = new PdfPCell(new Phrase(String.valueOf(resultTableModel.getValueAt(i, 1)))); paymentCell.setHorizontalAlignment(Element.ALIGN_CENTER); tableTable[counter].addCell(paymentCell); priceCell = new PdfPCell(new Phrase(String.valueOf(payment))); priceCell.setHorizontalAlignment(Element.ALIGN_CENTER); priceCell.setBackgroundColor(new BaseColor(255, 160, 160)); tableTable[counter].addCell(priceCell); } } } if (totalTablePayment[counter] > 0.00) { cell = new PdfPCell(); cell.setBorder(Rectangle.NO_BORDER); tableTable[counter].addCell(cell); cell = new PdfPCell(); cell.setBorder(Rectangle.NO_BORDER); tableTable[counter].addCell(cell); cell = new PdfPCell(new Phrase("SUMA:", FontFactory.getFont(FontFactory.defaultEncoding, 12, Font.NORMAL, BaseColor.BLACK))); cell.setBorder(Rectangle.NO_BORDER); cell.setHorizontalAlignment(Element.ALIGN_RIGHT); tableTable[counter].addCell(cell); cell = new PdfPCell(new Phrase(String.valueOf(totalTablePayment[counter]), FontFactory.getFont(FontFactory.defaultEncoding, 12, Font.BOLD, BaseColor.BLACK))); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setBackgroundColor(new BaseColor(255, 50, 50)); tableTable[counter].addCell(cell); } return tableTable[counter]; }
From source file:model.PDFModel.java
License:Open Source License
public PdfPTable createDailyTable(String date) throws DocumentException { PdfPTable dailyTable = new PdfPTable(3); PdfPCell cell;//from w w w . ja v a 2s . c o m dailyTable.setSpacingBefore(5f); cell = new PdfPCell(new Phrase("Stolik dnia")); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setBackgroundColor(new BaseColor(80, 172, 8)); dailyTable.addCell(cell); cell = new PdfPCell(new Phrase("Potrawa dnia")); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setBackgroundColor(new BaseColor(80, 172, 8)); dailyTable.addCell(cell); cell = new PdfPCell(new Phrase("Suma rachunkw")); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setBackgroundColor(new BaseColor(80, 172, 8)); dailyTable.addCell(cell); double theBestTableEarnings = 0.00; int theBestTableNumber = 0; for (int i = 1; i < totalTablePayment.length; i++) { if (theBestTableEarnings < totalTablePayment[i]) { theBestTableEarnings = totalTablePayment[i]; theBestTableNumber = i; } } cell = new PdfPCell(new Phrase("Stolik " + String.valueOf(theBestTableNumber))); cell.setHorizontalAlignment(Element.ALIGN_CENTER); dailyTable.addCell(cell); cell = new PdfPCell(new Phrase(query.getDailyBestSellingProduct(date))); cell.setHorizontalAlignment(Element.ALIGN_CENTER); dailyTable.addCell(cell); cell = new PdfPCell(new Phrase(query.getDailyTakings(date))); cell.setHorizontalAlignment(Element.ALIGN_CENTER); dailyTable.addCell(cell); return dailyTable; }
From source file:net.atomique.ksar.export.FilePDF.java
License:Open Source License
public void onEndPage(PdfWriter writer, Document document) { try {/*from w w w.j a v a 2 s. co m*/ int pageNumber = writer.getPageNumber(); String text = "Page " + pageNumber + "/" + total_pages; String hostName = mysar.myparser.gethostName(); String date = mysar.myparser.getDate(); pdfcb.beginText(); pdfcb.setFontAndSize(bf, 10); pdfcb.setColorFill(new BaseColor(0x00, 0x00, 0x00)); if (pageNumber > 1) { pdfcb.showTextAligned(PdfContentByte.ALIGN_LEFT, hostName, pdfmargins, pdfheight - pdfmargins, 0); pdfcb.showTextAligned(PdfContentByte.ALIGN_RIGHT, date, pdfwidth - pdfmargins, pdfheight - pdfmargins, 0); } pdfcb.showTextAligned(PdfContentByte.ALIGN_RIGHT, text, pdfwidth - pdfmargins, pdfmargins - 5, 0); pdfcb.endText(); } catch (Exception e) { throw new ExceptionConverter(e); } }
From source file:net.atomique.ksar.export.FilePDF.java
License:Open Source License
private void IndexPage(Document document) { try {/* w w w . java 2 s . com*/ float pdfCenter = ((pdfwidth - pdfmargins) / 2); String title = "SAR Statistics"; String t_date = "on " + mysar.myparser.getDate(); String hostName = "for " + mysar.myparser.gethostName(); String osType = mysar.myparser.getOstype(); String graphStart = mysar.myparser.getStartOfGraph().toString(); String graphEnd = mysar.myparser.getEndOfGraph().toString(); pdfcb.beginText(); pdfcb.setFontAndSize(bf, 40); pdfcb.setColorFill(new BaseColor(0x00, 0x00, 0x00)); pdfcb.showTextAligned(PdfContentByte.ALIGN_CENTER, title, pdfCenter, 500, 0); pdfcb.setFontAndSize(bf, 32); pdfcb.showTextAligned(PdfContentByte.ALIGN_CENTER, hostName + " (" + osType + ")", pdfCenter, 400, 0); pdfcb.showTextAligned(PdfContentByte.ALIGN_CENTER, t_date, pdfCenter, 300, 0); pdfcb.setFontAndSize(bf, 20); pdfcb.showTextAligned(PdfContentByte.ALIGN_CENTER, graphStart, pdfCenter, 200, 0); pdfcb.showTextAligned(PdfContentByte.ALIGN_CENTER, graphEnd, pdfCenter, 150, 0); pdfcb.endText(); document.newPage(); } catch (Exception de) { log.error("IndexPage Exception", de); } }
From source file:nl.avans.C3.BusinessLogic.InvoiceService.java
public void generateInvoice(String invoiceBSN, int[] behandelCode) throws DocumentException, FileNotFoundException, ClientNotFoundException, ParseException { Date date = new Date(); String dt = new SimpleDateFormat("yyyy-MM-dd").format(date); String fileId = "invoice-" + dt + "-" + invoiceBSN; String companyName = companyService.getInsuranceCompany().getName(); String companyAddress = companyService.getInsuranceCompany().getAddress(); String companyPostalCode = companyService.getInsuranceCompany().getPostalCode(); String companyCity = companyService.getInsuranceCompany().getCity(); String companyKVK = Integer.toString(companyService.getInsuranceCompany().getKVK()); String companyIBAN = "NL91ABNA0417164300"; Client client = clientService.findClientByBSN(Integer.parseInt(invoiceBSN)); String clientFirstName = client.getFirstName(); String clientLastName = client.getLastName(); String clientAddress = client.getAddress(); String clientPostalCode = client.getPostalCode(); String clientCity = client.getCity(); boolean incasso = client.isIncasso(); Date date2 = new Date(); String dt2 = new SimpleDateFormat("dd-MM-yyyy").format(date2); String currentDate = dt2;/* ww w . j a v a 2 s. c om*/ SimpleDateFormat sdf = new SimpleDateFormat("dd-MM-yyyy"); Calendar c = Calendar.getInstance(); c.setTime(sdf.parse(dt2)); c.add(Calendar.MONTH, 1); dt2 = sdf.format(c.getTime()); String expirationDate = dt2; String invoiceNumber = dt + "-" + invoiceBSN; Font bfBold12 = new Font(FontFamily.TIMES_ROMAN, 12, Font.BOLD, new BaseColor(0, 0, 0)); Font bf12 = new Font(FontFamily.TIMES_ROMAN, 12); // Creating new file Document doc = new Document(); // Trying to parse the data to a new PDF PdfWriter.getInstance(doc, new FileOutputStream("generatedfiles/invoice/" + fileId + ".pdf")); // Opening the file doc.open(); // Parsing the order details to the PDF doc.add(new Paragraph(companyName + "\n" + companyAddress + "\n" + companyPostalCode + " " + companyCity + "\n\n" + "KVK: " + companyKVK + "\nIBAN: " + companyIBAN + "\n\n\n" + clientFirstName + " " + clientLastName + "\n" + clientAddress + "\n" + clientPostalCode + " " + clientCity + "\n\n" + "Factuurdatum: " + currentDate + "\nVerloopdatum: " + expirationDate + "\n\n\n" + "Factuurnummer: " + invoiceNumber + "\n\n\n\n")); float[] columnWidths = { 2f, 2f, 2f, 2f, 2f }; PdfPTable table = new PdfPTable(columnWidths); table.setWidthPercentage(100f); insertCell(table, "Behandelcode", Element.ALIGN_LEFT, 1, bfBold12); insertCell(table, "Behandelingnaam", Element.ALIGN_LEFT, 1, bfBold12); insertCell(table, "Aantal sessies", Element.ALIGN_LEFT, 1, bfBold12); insertCell(table, "Sessieduur", Element.ALIGN_LEFT, 1, bfBold12); insertCell(table, "Tarief", Element.ALIGN_LEFT, 1, bfBold12); table.setHeaderRows(1); List<Treatment> treatments = getTreatments(behandelCode); for (int i = 0; i < treatments.size(); i++) { insertCell(table, "" + treatments.get(i).getBehandelCode(), Element.ALIGN_LEFT, 1, bf12); insertCell(table, "" + treatments.get(i).getBehandelingNaam(), Element.ALIGN_LEFT, 1, bf12); insertCell(table, "" + treatments.get(i).getAantalSessies(), Element.ALIGN_LEFT, 1, bf12); insertCell(table, "" + treatments.get(i).getSessieDuur(), Element.ALIGN_LEFT, 1, bf12); insertCell(table, "" + treatments.get(i).getTariefBehandeling(), Element.ALIGN_RIGHT, 1, bf12); } //totaalbedrag zonder eigen risico double totaalBedrag = getTotaalBedrag(behandelCode); insertCell(table, "Totaalbedrag: ", Element.ALIGN_RIGHT, 4, bfBold12); insertCell(table, "" + totaalBedrag, Element.ALIGN_RIGHT, 1, bfBold12); //lege row insertCell(table, "", Element.ALIGN_RIGHT, 5, bf12); //huidig eigen risico double excess = insuranceContractService.getInsuranceContractByBSN(Integer.parseInt(invoiceBSN)) .getExcess(); insertCell(table, "Huidig eigen risico: ", Element.ALIGN_RIGHT, 4, bf12); insertCell(table, "" + excess, Element.ALIGN_RIGHT, 1, bf12); //totaal te betalen bedrag double teBetalenBedrag; double newExcess = excess - totaalBedrag; insertCell(table, "Te betalen bedrag: ", Element.ALIGN_RIGHT, 4, bfBold12); if (excess > 0) { if (excess > totaalBedrag) { insuranceContractService.updateInsuranceContractExcess(newExcess, insuranceContractService .getInsuranceContractByBSN(Integer.parseInt(invoiceBSN)).getInsuranceContractID()); insertCell(table, "" + totaalBedrag, Element.ALIGN_RIGHT, 1, bfBold12); teBetalenBedrag = totaalBedrag; } else { insuranceContractService.updateInsuranceContractExcess(0.00, insuranceContractService .getInsuranceContractByBSN(Integer.parseInt(invoiceBSN)).getInsuranceContractID()); insertCell(table, "" + excess, Element.ALIGN_RIGHT, 1, bfBold12); teBetalenBedrag = excess; } } else { insertCell(table, "0.0", Element.ALIGN_RIGHT, 1, bfBold12); teBetalenBedrag = 0.00; } Paragraph paragraph = new Paragraph(""); paragraph.add(table); doc.add(paragraph); doc.add(new Paragraph("\n\n")); if (newExcess > 0) { doc.add(new Paragraph("U heeft nog " + newExcess + " eigen risico over.")); } else { doc.add(new Paragraph("U heeft nog 0.0 eigen risico over.")); } doc.add(new Paragraph("\n\n")); if (incasso == false) { if (teBetalenBedrag > 0) { doc.add(new Paragraph("We verzoeken u vriendelijk het bovenstaande bedrag van " + teBetalenBedrag + " voor " + expirationDate + " te voldoen op onze bankrekening onder vermelding van het factuurnummer " + invoiceNumber + ". Voor vragen kunt u contact opnemen per e-mail.")); } else { doc.add(new Paragraph( "Omdat uw eigen risico op is worden er geen kosten in rekening gebracht voor de bovenstaande behandelingen.")); } } else { doc.add(new Paragraph( "Het geld zal binnen 10 werkdagen van uw rekening afgeschreven worden door middel van een automatische incasso.")); } // Closing the file doc.close(); }