List of usage examples for com.itextpdf.text.pdf PdfPCell setMinimumHeight
public void setMinimumHeight(float minimumHeight)
From source file:com.solidmaps.webapp.report.EnableCompanyRequerimentFederalPDF.java
private void insertHeaderCell(PdfPTable table, String text, Integer colSpan) { if (text == null) { text = ""; }/* w w w.j a va2 s .co m*/ // create a new cell with the specified Text and Font PdfPCell cell = new PdfPCell(new Phrase(text.trim(), FONT_HEADER)); // set the cell alignment // in case there is no text and you wan to create an empty row if (text.trim().equalsIgnoreCase("")) { cell.setMinimumHeight(10f); } cell.setVerticalAlignment(Element.ALIGN_CENTER); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(colSpan); cell.setBackgroundColor(BaseColor.LIGHT_GRAY); cell.setBorderWidth(2); cell.setPadding(3f); // add the call to the table table.addCell(cell); }
From source file:com.solidmaps.webapp.report.LicenseCivilIncludeProductPDF.java
License:Open Source License
private void insertCell(PdfPTable table, String text, int align, Font font, boolean border) { if (text == null) { text = ""; }//from w w w. jav a 2s . c o m // create a new cell with the specified Text and Font PdfPCell cell = new PdfPCell(new Phrase(text.trim(), font)); // set the cell alignment cell.setHorizontalAlignment(align); // in case there is no text and you wan to create an empty row if (text.trim().equalsIgnoreCase("")) { cell.setMinimumHeight(10f); } if (!border) { cell.setBorder(Rectangle.NO_BORDER); } // add the call to the table table.addCell(cell); }
From source file:com.solidmaps.webapp.report.RequerimentAlterLicenseFederalPDF.java
private void insertCell(PdfPTable table, String text, Integer colSpan) { if (text == null) { text = ""; }/* w w w. j a va2 s .c om*/ // create a new cell with the specified Text and Font PdfPCell cell = new PdfPCell(new Phrase(text.trim(), FONT_PARAGRAPH)); // set the cell alignment // in case there is no text and you wan to create an empty row if (text.trim().equalsIgnoreCase("")) { cell.setMinimumHeight(10f); } cell.setHorizontalAlignment(Element.ALIGN_LEFT); cell.setColspan(colSpan); cell.setPadding(5f); // add the call to the table table.addCell(cell); }
From source file:com.solidmaps.webapp.report.RequerimentAlterLicenseFederalPDF.java
private void insertCellAlteracao(PdfPTable table, String text) { if (text == null) { text = ""; }/* www .j a v a 2 s .c o m*/ // create a new cell with the specified Text and Font PdfPCell cell = new PdfPCell(new Phrase(text.trim(), FONT_HEADER)); // set the cell alignment // in case there is no text and you wan to create an empty row if (text.trim().equalsIgnoreCase("")) { cell.setMinimumHeight(10f); } cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(2); cell.setBackgroundColor(BaseColor.LIGHT_GRAY); // add the call to the table table.addCell(cell); }
From source file:com.solidmaps.webapp.report.RequerimentAlterLicenseFederalPDF.java
private void insertCellAlteracaoOption(PdfPTable table, String number, String text, Boolean selected) { String fullText = ""; if (selected) { fullText += number + " |X|" + " " + text; } else {/*from ww w . j a va 2 s. co m*/ fullText += number + " | |" + " " + text; } if (StringUtils.isBlank(number) && StringUtils.isBlank(text)) { fullText = ""; } // create a new cell with the specified Text and Font PdfPCell cell = new PdfPCell(new Phrase(fullText.trim(), FONT_PARAGRAPH)); // set the cell alignment // in case there is no text and you wan to create an empty row if (fullText.trim().equalsIgnoreCase("")) { cell.setMinimumHeight(10f); } cell.setHorizontalAlignment(Element.ALIGN_LEFT); cell.setColspan(2); cell.setBorder(Rectangle.RIGHT); cell.setPaddingTop(10f); cell.setPaddingBottom(10f); cell.setPaddingLeft(25f); cell.setPaddingRight(25f); // add the call to the table table.addCell(cell); }
From source file:com.solidmaps.webapp.report.RequerimentAlterLicenseFederalPDF.java
private void insertHeaderCell(PdfPTable table, String text, Integer colSpan) { if (text == null) { text = ""; }/*w w w.j ava2 s .com*/ // create a new cell with the specified Text and Font PdfPCell cell = new PdfPCell(new Phrase(text.trim(), FONT_HEADER)); // set the cell alignment // in case there is no text and you wan to create an empty row if (text.trim().equalsIgnoreCase("")) { cell.setMinimumHeight(10f); } cell.setVerticalAlignment(Element.ALIGN_CENTER); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setColspan(colSpan); cell.setBackgroundColor(BaseColor.LIGHT_GRAY); cell.setBorderWidth(2); cell.setPadding(3f); // add the call to the table table.addCell(cell); }
From source file:FormatoPDF.ClasesPDF.PDF1.java
public void CrearPDF1(String[][] tabla, String txt1, String txt2, String txt3, String txt4, String txt5, String txt6, JTable tabla2) { String[][] tabla1 = tabla; float[] medidas1 = { 8.5f, 9.0f, 7.5f, 3.5f, 4.5f, 4.0f }; float[] medidas2 = { 7.5f, 3.5f, 7.0f, 5.5f, 4.5f, 4.5f, 4.5f }; float[] medidas3 = { 6.5f, 20.5f }; JFileChooser dlg = new JFileChooser(); int option = dlg.showSaveDialog(dlg); if (option == JFileChooser.APPROVE_OPTION) { File f = dlg.getSelectedFile(); String f1 = f.toString(); try { BaseColor MiColor = WebColors.getRGBColor("#04B4AE"); TablasPDF tab = new TablasPDF(); ImagenHome img = new ImagenHome(); Document document = new Document(); PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(f1 + ".pdf")); Paragraph saltolinea = new Paragraph(); saltolinea.add("\n"); document.open();/*from ww w .j a va2 s . co m*/ document.add(img.CrearImg()); DatosEncabezado en = new DatosEncabezado(); String[][] valores = new String[4][2]; valores[0][0] = "Dependencia: "; valores[0][1] = txt1; valores[1][0] = "Expediente: "; valores[1][1] = txt2; valores[2][0] = "Sesin: "; valores[2][1] = txt3; valores[3][0] = "Fecha: "; valores[3][1] = txt4; en.Datos(valores, writer); document.add(saltolinea); document.add(saltolinea); document.add(saltolinea); document.add(saltolinea); document.add(saltolinea); document.add(saltolinea); document.add(saltolinea); document.add(saltolinea); document.add(saltolinea); document.add(saltolinea); boolean color = true; PdfPTable tabpdf1 = new PdfPTable(6); PdfPCell cell1 = new PdfPCell( new Paragraph("Sesin:", FontFactory.getFont("arial", 10, Font.BOLD, BaseColor.BLACK))); PdfPCell cell11 = new PdfPCell( new Paragraph(tabla1[0][1], FontFactory.getFont("arial", 10, Font.BOLD, BaseColor.BLACK))); cell1.setBackgroundColor(MiColor); tabpdf1.addCell(cell1); tabpdf1.addCell(cell11); PdfPCell cell2 = new PdfPCell( new Paragraph("Fecha:", FontFactory.getFont("arial", 10, Font.BOLD, BaseColor.BLACK))); PdfPCell cell22 = new PdfPCell( new Paragraph(tabla1[0][3], FontFactory.getFont("arial", 10, Font.BOLD, BaseColor.BLACK))); cell2.setBackgroundColor(MiColor); tabpdf1.addCell(cell2); tabpdf1.addCell(cell22); PdfPCell cell3 = new PdfPCell( new Paragraph("Acuerdo:", FontFactory.getFont("arial", 10, Font.BOLD, BaseColor.BLACK))); PdfPCell cell33 = new PdfPCell( new Paragraph(txt5, FontFactory.getFont("arial", 10, Font.BOLD, BaseColor.BLACK))); cell3.setBackgroundColor(MiColor); tabpdf1.addCell(cell3); tabpdf1.addCell(cell33); document.add(tab.DibujarTablaArre1(6, 6, tabla1, medidas1, color, tabpdf1, 1, "")); document.add(saltolinea); document.add(saltolinea); document.add(saltolinea); document.add(saltolinea); PdfPTable tabpdf2 = new PdfPTable(7); PdfPCell cell1tab2 = new PdfPCell(new Phrase("ESTUDIO DE MERCADO", FontFactory.getFont("arial", 10, Font.BOLD, BaseColor.BLACK))); cell1tab2.setBackgroundColor(MiColor); cell1tab2.setMinimumHeight(30); cell1tab2.setHorizontalAlignment(Element.ALIGN_CENTER); cell1tab2.setColspan(7); cell1tab2.setRowspan(1); cell1tab2.setVerticalAlignment(Element.ALIGN_MIDDLE); tabpdf2.addCell(cell1tab2); PdfPCell cell2tab2 = new PdfPCell(new Phrase("Datos de la empresa ", FontFactory.getFont("arial", 10, Font.BOLD, BaseColor.BLACK))); cell2tab2.setBackgroundColor(MiColor); cell2tab2.setHorizontalAlignment(Element.ALIGN_CENTER); cell2tab2.setColspan(4); cell2tab2.setRowspan(1); cell2tab2.setVerticalAlignment(Element.ALIGN_MIDDLE); tabpdf2.addCell(cell2tab2); PdfPCell cell3tab2 = new PdfPCell(new Phrase("Datos de cotizacin ", FontFactory.getFont("arial", 10, Font.BOLD, BaseColor.BLACK))); cell3tab2.setBackgroundColor(MiColor); cell3tab2.setHorizontalAlignment(Element.ALIGN_CENTER); cell3tab2.setColspan(3); cell3tab2.setRowspan(1); cell3tab2.setVerticalAlignment(Element.ALIGN_MIDDLE); tabpdf2.addCell(cell3tab2); PdfPCell cell4tab2 = new PdfPCell(new Paragraph("Nombre, Denominacin o Razn Social", FontFactory.getFont("arial", 10, Font.BOLD, BaseColor.BLACK))); cell4tab2.setBackgroundColor(MiColor); cell4tab2.setHorizontalAlignment(Element.ALIGN_CENTER); tabpdf2.addCell(cell4tab2); PdfPCell cell5tab2 = new PdfPCell( new Paragraph("RFC", FontFactory.getFont("arial", 10, Font.BOLD, BaseColor.BLACK))); cell5tab2.setBackgroundColor(MiColor); cell5tab2.setHorizontalAlignment(Element.ALIGN_CENTER); tabpdf2.addCell(cell5tab2); PdfPCell cell6tab2 = new PdfPCell(new Paragraph("Representante Legal", FontFactory.getFont("arial", 10, Font.BOLD, BaseColor.BLACK))); cell6tab2.setBackgroundColor(MiColor); cell6tab2.setHorizontalAlignment(Element.ALIGN_CENTER); tabpdf2.addCell(cell6tab2); PdfPCell cell7tab2 = new PdfPCell(new Paragraph("Domicilio Fiscal", FontFactory.getFont("arial", 10, Font.BOLD, BaseColor.BLACK))); cell7tab2.setBackgroundColor(MiColor); cell7tab2.setHorizontalAlignment(Element.ALIGN_CENTER); tabpdf2.addCell(cell7tab2); PdfPCell cell8tab2 = new PdfPCell( new Paragraph("Subtotal", FontFactory.getFont("arial", 10, Font.BOLD, BaseColor.BLACK))); cell8tab2.setBackgroundColor(MiColor); cell8tab2.setHorizontalAlignment(Element.ALIGN_CENTER); tabpdf2.addCell(cell8tab2); PdfPCell cell9tab2 = new PdfPCell( new Paragraph("IVA", FontFactory.getFont("arial", 10, Font.BOLD, BaseColor.BLACK))); cell9tab2.setBackgroundColor(MiColor); cell9tab2.setHorizontalAlignment(Element.ALIGN_CENTER); tabpdf2.addCell(cell9tab2); PdfPCell cell10tab2 = new PdfPCell( new Paragraph("TOTAL", FontFactory.getFont("arial", 10, Font.BOLD, BaseColor.BLACK))); cell10tab2.setBackgroundColor(MiColor); cell10tab2.setHorizontalAlignment(Element.ALIGN_CENTER); tabpdf2.addCell(cell10tab2); document.add(tab.DibujarTabla(7, 5, tabla2, medidas2, tabpdf2)); document.add(saltolinea); document.add(saltolinea); document.add(saltolinea); document.add(saltolinea); PdfPTable tabpdf3 = new PdfPTable(2); PdfPCell cell1tab3 = new PdfPCell( new Phrase("Observaciones:", FontFactory.getFont("arial", 10, Font.BOLD, BaseColor.BLACK))); cell1tab3.setBackgroundColor(MiColor); cell1tab3.setMinimumHeight(60); cell1tab3.setHorizontalAlignment(Element.ALIGN_CENTER); cell1tab3.setVerticalAlignment(Element.ALIGN_MIDDLE); tabpdf3.addCell(cell1tab3); PdfPCell cell2tab3 = new PdfPCell( new Phrase(txt6, FontFactory.getFont("arial", 10, Font.BOLD, BaseColor.BLACK))); cell2tab3.setMinimumHeight(60); cell2tab3.setHorizontalAlignment(Element.ALIGN_CENTER); cell2tab3.setVerticalAlignment(Element.ALIGN_MIDDLE); tabpdf3.addCell(cell2tab3); tabpdf3.setWidths(medidas3); document.add(tabpdf3); document.close(); JOptionPane.showMessageDialog(null, "El archivo se ha guardado", "Exito", JOptionPane.INFORMATION_MESSAGE); File path = new File(f1 + ".pdf"); Desktop.getDesktop().open(path); } catch (Exception e) { JOptionPane.showMessageDialog(null, "Error " + e, "Error", JOptionPane.ERROR_MESSAGE); } } }
From source file:FormatoPDF.ClasesPDF.PDF2.java
public void CrearPDF2(String[][] tabla, String txt1, String txt2, String txt3, String txt4, String txt5, String txt6, String txt7, JTable tabla2, String txt8, String txt9, JTable tabla3, String txt10) { String[][] tabla1 = tabla; float[] medidas1 = { 8.5f, 9.0f, 7.5f, 3.5f, 4.5f, 4.0f }; float[] medidas2 = { 6.5f, 4.5f, 6.0f, 5.5f, 5.5f, 5.5f, 3.0f, 3.0f }; float[] medidas3 = { 6.5f, 3.5f, 3.5f, 3.5f, 2.5f, 3.5f, 6.0f, 4.0f, 4.0f }; float[] medidas4 = { 6.5f, 20.5f }; JFileChooser dlg = new JFileChooser(); int option = dlg.showSaveDialog(dlg); if (option == JFileChooser.APPROVE_OPTION) { File f = dlg.getSelectedFile(); String f1 = f.toString(); try { BaseColor MiColor = WebColors.getRGBColor("#04B4AE"); TablasPDF tab = new TablasPDF(); ImagenHome img = new ImagenHome(); Document document = new Document(); PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(f1 + ".pdf")); Paragraph saltolinea = new Paragraph(); saltolinea.add("\n"); document.open();/*from w w w . j av a 2 s. c o m*/ document.add(img.CrearImg()); DatosEncabezado en = new DatosEncabezado(); String[][] valores = new String[4][2]; valores[0][0] = "Dependencia: "; valores[0][1] = txt1; valores[1][0] = "Expediente: "; valores[1][1] = txt2; valores[2][0] = "Sesin: "; valores[2][1] = txt3; valores[3][0] = "Fecha: "; valores[3][1] = txt4; en.Datos(valores, writer); document.add(saltolinea); document.add(saltolinea); document.add(saltolinea); document.add(saltolinea); document.add(saltolinea); document.add(saltolinea); document.add(saltolinea); document.add(saltolinea); document.add(saltolinea); document.add(saltolinea); boolean color = true; PdfPTable tabpdf1 = new PdfPTable(6); PdfPCell cell1 = new PdfPCell( new Paragraph("Sesin:", FontFactory.getFont("arial", 10, Font.BOLD, BaseColor.BLACK))); PdfPCell cell11 = new PdfPCell( new Paragraph(tabla1[0][1], FontFactory.getFont("arial", 10, Font.BOLD, BaseColor.BLACK))); cell1.setBackgroundColor(MiColor); tabpdf1.addCell(cell1); tabpdf1.addCell(cell11); PdfPCell cell2 = new PdfPCell( new Paragraph("Fecha:", FontFactory.getFont("arial", 10, Font.BOLD, BaseColor.BLACK))); PdfPCell cell22 = new PdfPCell( new Paragraph(tabla1[0][3], FontFactory.getFont("arial", 10, Font.BOLD, BaseColor.BLACK))); cell2.setBackgroundColor(MiColor); tabpdf1.addCell(cell2); tabpdf1.addCell(cell22); PdfPCell cell3 = new PdfPCell( new Paragraph("Acuerdo:", FontFactory.getFont("arial", 10, Font.BOLD, BaseColor.BLACK))); PdfPCell cell33 = new PdfPCell( new Paragraph(txt5, FontFactory.getFont("arial", 10, Font.BOLD, BaseColor.BLACK))); cell3.setBackgroundColor(MiColor); tabpdf1.addCell(cell3); tabpdf1.addCell(cell33); document.add(tab.DibujarTablaArre1(6, 6, tabla1, medidas1, color, tabpdf1, 2, txt6)); document.add(saltolinea); document.add(saltolinea); document.add(saltolinea); PdfPTable tabpdf2 = new PdfPTable(8); tabpdf2.setWidths(medidas2); PdfPCell cell1tab2 = new PdfPCell(new Phrase("Datos de la empresa ", FontFactory.getFont("arial", 8, Font.BOLD, BaseColor.BLACK))); cell1tab2.setBackgroundColor(MiColor); cell1tab2.setHorizontalAlignment(Element.ALIGN_CENTER); cell1tab2.setColspan(4); cell1tab2.setRowspan(2); cell1tab2.setVerticalAlignment(Element.ALIGN_MIDDLE); tabpdf2.addCell(cell1tab2); PdfPCell cell2tab2 = new PdfPCell( new Phrase("", FontFactory.getFont("arial", 8, Font.BOLD, BaseColor.BLACK))); cell2tab2.setBackgroundColor(MiColor); cell2tab2.setHorizontalAlignment(Element.ALIGN_CENTER); cell2tab2.setColspan(2); cell2tab2.setRowspan(1); cell2tab2.setVerticalAlignment(Element.ALIGN_MIDDLE); tabpdf2.addCell(cell2tab2); PdfPCell cell3tab2 = new PdfPCell(new Phrase("Junta de Aclaraciones", FontFactory.getFont("arial", 8, Font.BOLD, BaseColor.BLACK))); cell3tab2.setBackgroundColor(MiColor); cell3tab2.setHorizontalAlignment(Element.ALIGN_CENTER); cell3tab2.setColspan(2); cell3tab2.setRowspan(1); cell3tab2.setVerticalAlignment(Element.ALIGN_MIDDLE); tabpdf2.addCell(cell3tab2); PdfPCell cell4tab2 = new PdfPCell( new Phrase("Fecha:", FontFactory.getFont("arial", 8, Font.BOLD, BaseColor.BLACK))); cell4tab2.setHorizontalAlignment(Element.ALIGN_CENTER); cell4tab2.setBackgroundColor(MiColor); cell4tab2.setColspan(1); cell4tab2.setRowspan(1); cell4tab2.setVerticalAlignment(Element.ALIGN_MIDDLE); tabpdf2.addCell(cell4tab2); PdfPCell cell5tab2 = new PdfPCell( new Phrase(txt7, FontFactory.getFont("arial", 8, Font.BOLD, BaseColor.BLACK))); cell5tab2.setHorizontalAlignment(Element.ALIGN_CENTER); cell5tab2.setColspan(1); cell5tab2.setRowspan(1); cell5tab2.setVerticalAlignment(Element.ALIGN_MIDDLE); tabpdf2.addCell(cell5tab2);/////////// PdfPTable tabpdf3 = new PdfPTable(8); document.add(tabpdf2); PdfPCell cell1tab3 = new PdfPCell(new Phrase("Nombre, Denominacin o Razn Social", FontFactory.getFont("arial", 8, Font.BOLD, BaseColor.BLACK))); cell1tab3.setBackgroundColor(MiColor); cell1tab3.setHorizontalAlignment(Element.ALIGN_CENTER); cell1tab3.setVerticalAlignment(Element.ALIGN_MIDDLE); tabpdf3.addCell(cell1tab3); PdfPCell cell2tab3 = new PdfPCell( new Phrase("RFC", FontFactory.getFont("arial", 8, Font.BOLD, BaseColor.BLACK))); cell2tab3.setBackgroundColor(MiColor); cell2tab3.setHorizontalAlignment(Element.ALIGN_CENTER); cell2tab3.setVerticalAlignment(Element.ALIGN_MIDDLE); tabpdf3.addCell(cell2tab3); PdfPCell cell3tab3 = new PdfPCell(new Phrase("Representante Legal", FontFactory.getFont("arial", 8, Font.BOLD, BaseColor.BLACK))); cell3tab3.setBackgroundColor(MiColor); cell3tab3.setHorizontalAlignment(Element.ALIGN_CENTER); cell3tab3.setVerticalAlignment(Element.ALIGN_MIDDLE); tabpdf3.addCell(cell3tab3); PdfPCell cell4tab3 = new PdfPCell(new Phrase("Domicilio Fiscal", FontFactory.getFont("arial", 8, Font.BOLD, BaseColor.BLACK))); cell4tab3.setBackgroundColor(MiColor); cell4tab3.setHorizontalAlignment(Element.ALIGN_CENTER); cell4tab3.setVerticalAlignment(Element.ALIGN_MIDDLE); tabpdf3.addCell(cell4tab3); PdfPCell cell5tab3 = new PdfPCell(new Phrase("Proveedores sancionados", FontFactory.getFont("arial", 8, Font.BOLD, BaseColor.BLACK))); cell5tab3.setBackgroundColor(MiColor); cell5tab3.setHorizontalAlignment(Element.ALIGN_CENTER); cell5tab3.setVerticalAlignment(Element.ALIGN_MIDDLE); tabpdf3.addCell(cell5tab3); PdfPCell cell6tab3 = new PdfPCell( new Phrase("Pgina web", FontFactory.getFont("arial", 8, Font.BOLD, BaseColor.BLACK))); cell6tab3.setBackgroundColor(MiColor); cell6tab3.setHorizontalAlignment(Element.ALIGN_CENTER); cell6tab3.setVerticalAlignment(Element.ALIGN_MIDDLE); tabpdf3.addCell(cell6tab3); PdfPCell cell7tab3 = new PdfPCell( new Phrase("Asisti", FontFactory.getFont("arial", 8, Font.BOLD, BaseColor.BLACK))); cell7tab3.setBackgroundColor(MiColor); cell7tab3.setHorizontalAlignment(Element.ALIGN_CENTER); cell7tab3.setVerticalAlignment(Element.ALIGN_MIDDLE); tabpdf3.addCell(cell7tab3); PdfPCell cell8tab3 = new PdfPCell( new Phrase("No asisti", FontFactory.getFont("arial", 8, Font.BOLD, BaseColor.BLACK))); cell8tab3.setBackgroundColor(MiColor); cell8tab3.setHorizontalAlignment(Element.ALIGN_CENTER); cell8tab3.setVerticalAlignment(Element.ALIGN_MIDDLE); tabpdf3.addCell(cell8tab3); document.add(tab.DibujarTabla(8, 4, tabla2, medidas2, tabpdf3)); document.add(saltolinea); document.add(saltolinea); document.add(saltolinea); /////////////////////// PdfPTable tabpdf4 = new PdfPTable(9); PdfPCell cell1tab4 = new PdfPCell(new Phrase("Nombre, Denominacin o Razn Social", FontFactory.getFont("arial", 8, Font.BOLD, BaseColor.BLACK))); cell1tab4.setBackgroundColor(MiColor); cell1tab4.setHorizontalAlignment(Element.ALIGN_CENTER); cell1tab4.setColspan(1); cell1tab4.setRowspan(4); cell1tab4.setVerticalAlignment(Element.ALIGN_MIDDLE); tabpdf4.addCell(cell1tab4); PdfPCell cell2tab4 = new PdfPCell(new Phrase("Apertura de Propuestas", FontFactory.getFont("arial", 8, Font.BOLD, BaseColor.BLACK))); cell2tab4.setBackgroundColor(MiColor); cell2tab4.setHorizontalAlignment(Element.ALIGN_CENTER); cell2tab4.setColspan(5); cell2tab4.setRowspan(1); cell2tab4.setVerticalAlignment(Element.ALIGN_MIDDLE); tabpdf4.addCell(cell2tab4); PdfPCell cell3tab4 = new PdfPCell(new Phrase("Notificacin y Lectura de Fallo", FontFactory.getFont("arial", 8, Font.BOLD, BaseColor.BLACK))); cell3tab4.setBackgroundColor(MiColor); cell3tab4.setHorizontalAlignment(Element.ALIGN_CENTER); cell3tab4.setColspan(3); cell3tab4.setRowspan(1); cell3tab4.setVerticalAlignment(Element.ALIGN_MIDDLE); tabpdf4.addCell(cell3tab4); PdfPCell cell4tab4 = new PdfPCell( new Phrase("Fecha:", FontFactory.getFont("arial", 8, Font.BOLD, BaseColor.BLACK))); cell4tab4.setHorizontalAlignment(Element.ALIGN_CENTER); cell4tab4.setBackgroundColor(MiColor); cell4tab4.setColspan(2); cell4tab4.setRowspan(1); cell4tab4.setVerticalAlignment(Element.ALIGN_MIDDLE); tabpdf4.addCell(cell4tab4); PdfPCell cell5tab4 = new PdfPCell( new Phrase(txt8, FontFactory.getFont("arial", 8, Font.BOLD, BaseColor.BLACK))); cell5tab4.setHorizontalAlignment(Element.ALIGN_CENTER); cell5tab4.setColspan(3); cell5tab4.setRowspan(1); cell5tab4.setVerticalAlignment(Element.ALIGN_MIDDLE); tabpdf4.addCell(cell5tab4); PdfPCell cell6tab4 = new PdfPCell( new Phrase("Fecha:", FontFactory.getFont("arial", 8, Font.BOLD, BaseColor.BLACK))); cell6tab4.setHorizontalAlignment(Element.ALIGN_CENTER); cell6tab4.setBackgroundColor(MiColor); cell6tab4.setColspan(1); cell6tab4.setRowspan(1); cell6tab4.setVerticalAlignment(Element.ALIGN_MIDDLE); tabpdf4.addCell(cell6tab4); PdfPCell cell7tab4 = new PdfPCell( new Phrase(txt9, FontFactory.getFont("arial", 8, Font.BOLD, BaseColor.BLACK))); cell7tab4.setHorizontalAlignment(Element.ALIGN_CENTER); cell7tab4.setColspan(2); cell7tab4.setRowspan(1); cell7tab4.setVerticalAlignment(Element.ALIGN_MIDDLE); tabpdf4.addCell(cell7tab4); PdfPCell cell8tab4 = new PdfPCell( new Phrase("Tcnica", FontFactory.getFont("arial", 8, Font.BOLD, BaseColor.BLACK))); cell8tab4.setHorizontalAlignment(Element.ALIGN_CENTER); cell8tab4.setBackgroundColor(MiColor); cell8tab4.setColspan(2); cell8tab4.setRowspan(1); cell8tab4.setVerticalAlignment(Element.ALIGN_MIDDLE); tabpdf4.addCell(cell8tab4); PdfPCell cell9tab4 = new PdfPCell( new Phrase("Econmica ", FontFactory.getFont("arial", 8, Font.BOLD, BaseColor.BLACK))); cell9tab4.setHorizontalAlignment(Element.ALIGN_CENTER); cell9tab4.setBackgroundColor(MiColor); cell9tab4.setColspan(3); cell9tab4.setRowspan(1); cell9tab4.setVerticalAlignment(Element.ALIGN_MIDDLE); tabpdf4.addCell(cell9tab4); PdfPCell cell10tab4 = new PdfPCell(new Phrase("Motivo de desechamiento", FontFactory.getFont("arial", 8, Font.BOLD, BaseColor.BLACK))); cell10tab4.setHorizontalAlignment(Element.ALIGN_CENTER); cell10tab4.setBackgroundColor(MiColor); cell10tab4.setColspan(1); cell10tab4.setRowspan(2); cell10tab4.setVerticalAlignment(Element.ALIGN_MIDDLE); tabpdf4.addCell(cell10tab4); PdfPCell cell11tab4 = new PdfPCell(new Phrase("Empresa Adjudicada", FontFactory.getFont("arial", 8, Font.BOLD, BaseColor.BLACK))); cell11tab4.setHorizontalAlignment(Element.ALIGN_CENTER); cell11tab4.setBackgroundColor(MiColor); cell11tab4.setColspan(1); cell11tab4.setRowspan(2); cell11tab4.setVerticalAlignment(Element.ALIGN_MIDDLE); tabpdf4.addCell(cell11tab4); PdfPCell cell12tab4 = new PdfPCell(new Phrase("Monto Adjudicado", FontFactory.getFont("arial", 8, Font.BOLD, BaseColor.BLACK))); cell12tab4.setHorizontalAlignment(Element.ALIGN_CENTER); cell12tab4.setBackgroundColor(MiColor); cell12tab4.setColspan(1); cell12tab4.setRowspan(2); cell12tab4.setVerticalAlignment(Element.ALIGN_MIDDLE); tabpdf4.addCell(cell12tab4); PdfPCell cell13tab4 = new PdfPCell( new Phrase("Presenta", FontFactory.getFont("arial", 8, Font.BOLD, BaseColor.BLACK))); cell13tab4.setBackgroundColor(MiColor); cell13tab4.setHorizontalAlignment(Element.ALIGN_CENTER); cell13tab4.setVerticalAlignment(Element.ALIGN_MIDDLE); tabpdf4.addCell(cell13tab4); PdfPCell cell14tab4 = new PdfPCell( new Phrase("No presenta", FontFactory.getFont("arial", 8, Font.BOLD, BaseColor.BLACK))); cell14tab4.setBackgroundColor(MiColor); cell14tab4.setHorizontalAlignment(Element.ALIGN_CENTER); cell14tab4.setVerticalAlignment(Element.ALIGN_MIDDLE); tabpdf4.addCell(cell14tab4); PdfPCell cell15tab4 = new PdfPCell( new Phrase("Subtotal ", FontFactory.getFont("arial", 8, Font.BOLD, BaseColor.BLACK))); cell15tab4.setBackgroundColor(MiColor); cell15tab4.setHorizontalAlignment(Element.ALIGN_CENTER); cell15tab4.setVerticalAlignment(Element.ALIGN_MIDDLE); tabpdf4.addCell(cell15tab4); PdfPCell cell16tab4 = new PdfPCell( new Phrase("IVA", FontFactory.getFont("arial", 8, Font.BOLD, BaseColor.BLACK))); cell16tab4.setBackgroundColor(MiColor); cell16tab4.setHorizontalAlignment(Element.ALIGN_CENTER); cell16tab4.setVerticalAlignment(Element.ALIGN_MIDDLE); tabpdf4.addCell(cell16tab4); PdfPCell cell17tab4 = new PdfPCell( new Phrase("Total", FontFactory.getFont("arial", 8, Font.BOLD, BaseColor.BLACK))); cell17tab4.setBackgroundColor(MiColor); cell17tab4.setHorizontalAlignment(Element.ALIGN_CENTER); cell17tab4.setVerticalAlignment(Element.ALIGN_MIDDLE); tabpdf4.addCell(cell17tab4); document.add(tab.DibujarTabla(9, 4, tabla3, medidas3, tabpdf4)); document.add(saltolinea); document.add(saltolinea); document.add(saltolinea); document.add(saltolinea); PdfPTable tabpdf5 = new PdfPTable(2); PdfPCell cell1tab5 = new PdfPCell( new Phrase("Observaciones:", FontFactory.getFont("arial", 10, Font.BOLD, BaseColor.BLACK))); cell1tab5.setBackgroundColor(MiColor); cell1tab5.setMinimumHeight(60); cell1tab5.setHorizontalAlignment(Element.ALIGN_CENTER); cell1tab5.setVerticalAlignment(Element.ALIGN_MIDDLE); tabpdf5.addCell(cell1tab5); PdfPCell cell2tab5 = new PdfPCell( new Phrase(txt10, FontFactory.getFont("arial", 10, Font.BOLD, BaseColor.BLACK))); cell2tab5.setMinimumHeight(60); cell2tab5.setHorizontalAlignment(Element.ALIGN_CENTER); cell2tab5.setVerticalAlignment(Element.ALIGN_MIDDLE); tabpdf5.addCell(cell2tab5); tabpdf5.setWidths(medidas4); document.add(tabpdf5); document.close(); JOptionPane.showMessageDialog(null, "El archivo se ha guardado", "Exito", JOptionPane.INFORMATION_MESSAGE); File path = new File(f1 + ".pdf"); Desktop.getDesktop().open(path); } catch (Exception e) { JOptionPane.showMessageDialog(null, "Error " + e, "Error", JOptionPane.ERROR_MESSAGE); } } }
From source file:Login.ventas.fproyectos.java
/** * Creates new form cliente//from ww w . j a va 2s. c o m * @param user */ public fproyectos(Login user) { Dimension d = Toolkit.getDefaultToolkit().getScreenSize(); @SuppressWarnings("MismatchedReadAndWriteOfArray") String[] fecha = { "Enero", "Febrero", "Marzo", "Abril", "Mayo", "Junio", "Julio", "Agosto", "Septiembre", "Octubre", "Noviembre", "Diciembre" }; initComponents(); Calendar rightNow = Calendar.getInstance(); int ccyy = rightNow.get(Calendar.YEAR); int month = rightNow.get(Calendar.MONTH); setSize(d.width, d.height - 95); this.usuario = user; add(f); f.setLocation(jPanel1.getX(), jPanel1.getY()); add(f3); f3.setLocation(jPanel1.getX(), jPanel1.getY()); add(f4); f4.setLocation(jPanel1.getX(), jPanel1.getY()); add(f5); f5.setLocation(jPanel1.getX(), jPanel1.getY()); add(f2); f2.setLocation(jPanel1.getX(), jPanel1.getY()); f2.getjButton1().addMouseListener(new java.awt.event.MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { try { ServiceHb helper = new ServiceHb(); helper.iniciarTransaccion(); Fcomisiones fc = helper.getFcomisiones(idcliente, idinstalacion); if (helper.getFcomisiones(idcliente, idinstalacion) == null) { fc = new Fcomisiones(); Calendar d = Calendar.getInstance(); fc.setFecha(new java.sql.Date(d.getTime().getTime())); fc.setClientes( (Clientes) helper.obtenerObjeto(Clientes.class, Integer.parseInt(idcliente))); fc.setInstalacion((Instalacion) helper.obtenerObjeto(Instalacion.class, Integer.parseInt(idinstalacion))); fc.setRentabilidad(f2.getjLabel20().getText()); fc.setValor1(f2.getjLabel11().getText().substring(2, f2.getjLabel11().getText().length())); fc.setValor2(f2.getjLabel2().getText().substring(3, f2.getjLabel2().getText().length())); fc.setDiferido(f2.getjLabel4().getText()); fc.setDias(numeroinstala); helper.crearObjeto(fc); helper.confirmarTransaccion(); helper.cerrarSesion(); JOptionPane.showMessageDialog(null, "Comision prepara con fecha " + Funcion.DateFormatSql(d.getTime())); } else { Calendar d = Calendar.getInstance(); fc.setFecha(new java.sql.Date(d.getTime().getTime())); fc.setRentabilidad(f2.getjLabel20().getText()); fc.setValor1(f2.getjLabel11().getText().substring(2, f2.getjLabel11().getText().length())); fc.setValor2(f2.getjLabel2().getText().substring(3, f2.getjLabel2().getText().length())); fc.setDiferido(f2.getjLabel4().getText()); fc.setDias(numeroinstala); helper.actualizarObjeto(fc); helper.confirmarTransaccion(); helper.cerrarSesion(); JOptionPane.showMessageDialog(null, "Actualizado / Comision prepara con fecha " + Funcion.DateFormatSql(d.getTime())); } } catch (Exception io) { System.out.println(io); } } }); f2.getjButton2().addMouseListener(new java.awt.event.MouseAdapter() { @Override @SuppressWarnings("UseSpecificCatch") public void mouseClicked(MouseEvent e) { float ancho = 0; try { Document documento = new Document(PageSize.A4, 0, 0, 0, 0); ancho = documento.getPageSize().getWidth() - 100; FileOutputStream ficheroPdf; PdfWriter writer = null; PdfWriter writer2 = null; String direccion = ""; Calendar now2 = Calendar.getInstance(); try { JFileChooser chooser = new JFileChooser(); chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); //Mostrar la ventana para abrir archivo y recoger la respuesta //En el parmetro del showOpenDialog se indica la ventana // al que estar asociado. Con el valor this se asocia a la // ventana que la abre. int respuesta = chooser.showOpenDialog(null); String cadena = ""; if (respuesta == JFileChooser.APPROVE_OPTION) { direccion = chooser.getSelectedFile().getAbsolutePath(); } Calendar d = Calendar.getInstance(); ficheroPdf = new FileOutputStream(direccion + "/" + idcliente + idinstalacion + ".pdf"); writer = PdfWriter.getInstance(documento, ficheroPdf); } catch (IOException ex) { System.out.println(ex.toString()); } ServiceHb helper = null; try { List<Productos> lt = null; helper = new ServiceHb(); helper.iniciarTransaccion(); PdfPTable tabla; PdfPCell casilla; PdfPTable salto = null; PdfPCell celda; Font fontpersonalizado = FontFactory.getFont("ARIAL", 7, Font.BOLD); Font fontpersonalizado2 = FontFactory.getFont("ARIAL", 7, Font.NORMAL); documento.open(); PdfContentByte canvas = writer.getDirectContent(); fondos(documento, canvas); //Materiales double total = 0; double total2 = 0; double total3 = 0; double total4 = 0; double total5 = 0; tabla = new PdfPTable(6); tabla.setHorizontalAlignment(PdfPTable.ALIGN_CENTER); tabla.setTotalWidth(ancho); tabla.setLockedWidth(true); celda = new PdfPCell(new Paragraph("ADQUISICION DE MATERIALES")); celda.setColspan(6); celda.setHorizontalAlignment(Element.ALIGN_CENTER); celda.setBorder(PdfPCell.NO_BORDER); tabla.addCell(celda); float pagina = documento.getPageSize().getHeight() - 140; final float max = pagina; pagina = pagina - tabla.getRow(0).calculateHeights(); if (ltart != null) { Object nuevo2[] = { "FECHA", "DETALLE", "CANT.", "PRECIO", "SUBTOTAL", "TOTAL DIARIO" }; for (Object obj : nuevo2) { celda = new PdfPCell(new Paragraph((String) obj, new Font(fontpersonalizado))); celda.setBorderColor(new Color(195, 195, 195)); celda.setColspan(1); celda.setHorizontalAlignment(Element.ALIGN_CENTER); tabla.addCell(celda); } pagina = pagina - tabla.getRow(1).calculateHeights(); int tam = 0; double diario = 0; int turno = 0; for (int i = 0; i < ltart.size(); i++) { turno = 0; fact = helper.getFacturafecha(ltart.get(i).getIdfactura()); String fecha = ""; if (fact != null) { fecha = Funcion.DateFormatSql(fact.getFecha()); } if ((i + 1) == ltart.size()) { diario = diario + Double.parseDouble(ltart.get(i).getTotal()); turno = 1; } else { fact2 = helper.getFacturafecha(ltart.get(i + 1).getIdfactura()); String fecha2 = ""; if (fact2 != null) { fecha2 = Funcion.DateFormatSql(fact2.getFecha()); if (fecha.equalsIgnoreCase(fecha2)) { diario = diario + Double.parseDouble(ltart.get(i).getTotal()); } else { diario = diario + Double.parseDouble(ltart.get(i).getTotal()); turno = 1; } } } String uni = "$ " + df.format(Double.parseDouble(ltart.get(i).getUnitario())) .replace(",", "."); String tot = "$ " + df.format(Double.parseDouble(ltart.get(i).getTotal())).replace(",", "."); total = total + Double.parseDouble(ltart.get(i).getTotal()); if (turno == 0) { Object nuevo[] = { fecha, ltart.get(i).getDescripcion(), ltart.get(i).getCantidad(), uni, tot, "" }; for (Object obj : nuevo) { celda = new PdfPCell( new Paragraph((String) obj, new Font(fontpersonalizado2))); if (((String) obj).equalsIgnoreCase("")) { celda.setBorder(Rectangle.RIGHT); } celda.setBorderColor(new Color(195, 195, 195)); celda.setColspan(1); celda.setHorizontalAlignment(Element.ALIGN_CENTER); tabla.addCell(celda); } } else { Object nuevo[] = { fecha, ltart.get(i).getDescripcion(), ltart.get(i).getCantidad(), uni, tot, "$ " + df.format(diario).replace(",", ".") }; int va = 0; for (Object obj : nuevo) { va++; celda = new PdfPCell( new Paragraph((String) obj, new Font(fontpersonalizado2))); if (va == 5) { celda.setBorder(Rectangle.BOTTOM); } celda.setColspan(1); celda.setBorderColor(new Color(195, 195, 195)); celda.setHorizontalAlignment(Element.ALIGN_CENTER); tabla.addCell(celda); } diario = 0; } pagina = pagina - tabla.getRow(tam).getMaxHeights(); tam++; if (pagina < 11) { salto = new PdfPTable(1); casilla = new PdfPCell(new Phrase("", new Font(fontpersonalizado))); casilla.setMinimumHeight(90); casilla.setBorder(PdfPCell.NO_BORDER); salto.addCell(casilla); documento.add(salto); documento.add(tabla); documento.newPage(); fondos(documento, canvas); tabla = new PdfPTable(6); tabla.setHorizontalAlignment(PdfPTable.ALIGN_CENTER); tabla.setTotalWidth(ancho); tabla.setLockedWidth(true); pagina = max; tam = 0; } } } salto = new PdfPTable(1); casilla = new PdfPCell(new Phrase("", new Font(fontpersonalizado))); casilla.setMinimumHeight(90); casilla.setBorder(PdfPCell.NO_BORDER); salto.addCell(casilla); documento.add(salto); celda = new PdfPCell(new Paragraph("Total", new Font(fontpersonalizado2))); celda.setBorderColor(new Color(195, 195, 195)); celda.setColspan(1); celda.setHorizontalAlignment(Element.ALIGN_CENTER); tabla.addCell(celda); celda = new PdfPCell( new Paragraph("Adquisicin de Materiales", new Font(fontpersonalizado2))); celda.setBorderColor(new Color(195, 195, 195)); celda.setColspan(4); celda.setHorizontalAlignment(Element.ALIGN_CENTER); tabla.addCell(celda); celda = new PdfPCell(new Paragraph("$ " + df.format(total).replace(",", "."), new Font(fontpersonalizado2))); celda.setBorderColor(new Color(195, 195, 195)); celda.setColspan(1); celda.setHorizontalAlignment(Element.ALIGN_CENTER); tabla.addCell(celda); documento.add(tabla); documento.newPage(); fondos(documento, canvas); /*Parte 2*/ tabla = new PdfPTable(4); tabla.setHorizontalAlignment(PdfPTable.ALIGN_CENTER); tabla.setTotalWidth(ancho); tabla.setLockedWidth(true); tabla.setWidths(new int[] { 1, 3, 1, 1 }); celda = new PdfPCell(new Paragraph("MANO DE OBRA TECNICOS")); celda.setColspan(4); celda.setHorizontalAlignment(Element.ALIGN_CENTER); celda.setBorder(PdfPCell.NO_BORDER); tabla.addCell(celda); pagina = documento.getPageSize().getHeight() - 140; pagina = pagina - tabla.getRow(0).calculateHeights(); if (list != null) { Object nuevo2[] = { "FECHA", "DETALLE", "CANT.", "SUBTOTAL" }; for (Object obj : nuevo2) { celda = new PdfPCell(new Paragraph((String) obj, new Font(fontpersonalizado))); celda.setBorderColor(new Color(195, 195, 195)); celda.setColspan(1); celda.setHorizontalAlignment(Element.ALIGN_CENTER); tabla.addCell(celda); } pagina = pagina - tabla.getRow(1).calculateHeights(); int tam = 0; double diario = 0; int turno = 0; for (Ctepagar list1 : list) { if (list1.getDetalle().contains("ci:")) { String fecha = list1.getFecha(); String desc = list1.getDetalle(); String[] cadena = desc.split(" "); String result = ""; int contador = 0; for (String n : cadena) { if (n.contains("ci:")) { result = result + ", "; contador++; } else { result = result + n + " "; } } result = result.substring(0, result.length() - 2); String uni = "$ " + df.format(Double.parseDouble(list1.getValor())).replace(",", "."); String tot = "$ " + df.format(Double.parseDouble(list1.getValor())).replace(",", "."); total2 = total2 + Double.parseDouble(list1.getValor()); Object nuevo[] = { fecha, result, "" + contador, tot }; for (Object obj : nuevo) { celda = new PdfPCell( new Paragraph((String) obj, new Font(fontpersonalizado2))); celda.setBorderColor(new Color(195, 195, 195)); celda.setColspan(1); celda.setHorizontalAlignment(Element.ALIGN_CENTER); tabla.addCell(celda); } pagina = pagina - tabla.getRow(tam).getMaxHeights(); tam++; if (pagina < 90) { salto = new PdfPTable(1); casilla = new PdfPCell(new Phrase("", new Font(fontpersonalizado2))); casilla.setMinimumHeight(90); casilla.setBorder(PdfPCell.NO_BORDER); salto.addCell(casilla); documento.add(salto); documento.add(tabla); documento.newPage(); fondos(documento, canvas); tabla = new PdfPTable(4); tabla.setHorizontalAlignment(PdfPTable.ALIGN_CENTER); tabla.setTotalWidth(ancho); tabla.setLockedWidth(true); tabla.setWidths(new int[] { 1, 3, 1, 1 }); pagina = max; tam = 0; } } } } salto = new PdfPTable(1); casilla = new PdfPCell(new Phrase("", new Font(fontpersonalizado))); casilla.setMinimumHeight(90); casilla.setBorder(PdfPCell.NO_BORDER); salto.addCell(casilla); documento.add(salto); celda = new PdfPCell(new Paragraph("Total", new Font(fontpersonalizado2))); celda.setBorderColor(new Color(195, 195, 195)); celda.setColspan(1); celda.setHorizontalAlignment(Element.ALIGN_CENTER); tabla.addCell(celda); celda = new PdfPCell(new Paragraph("Mano de Obra Tcnicos", new Font(fontpersonalizado2))); celda.setBorderColor(new Color(195, 195, 195)); celda.setColspan(2); celda.setHorizontalAlignment(Element.ALIGN_CENTER); tabla.addCell(celda); celda = new PdfPCell(new Paragraph("$ " + df.format(total2).replace(",", "."), new Font(fontpersonalizado2))); celda.setBorderColor(new Color(195, 195, 195)); celda.setColspan(1); celda.setHorizontalAlignment(Element.ALIGN_CENTER); tabla.addCell(celda); documento.add(tabla); documento.newPage(); fondos(documento, canvas); tabla = new PdfPTable(3); tabla.setHorizontalAlignment(PdfPTable.ALIGN_CENTER); tabla.setTotalWidth(ancho); tabla.setLockedWidth(true); tabla.setWidths(new int[] { 1, 3, 1 }); celda = new PdfPCell(new Paragraph("TRANSPORTE")); celda.setColspan(3); celda.setHorizontalAlignment(Element.ALIGN_CENTER); celda.setBorder(PdfPCell.NO_BORDER); tabla.addCell(celda); pagina = documento.getPageSize().getHeight() - 140; pagina = pagina - tabla.getRow(0).calculateHeights(); if (list != null) { Object nuevo2[] = { "FECHA", "DETALLE", "SUBTOTAL" }; for (Object obj : nuevo2) { celda = new PdfPCell(new Paragraph((String) obj, new Font(fontpersonalizado))); celda.setBorderColor(new Color(195, 195, 195)); celda.setColspan(1); celda.setHorizontalAlignment(Element.ALIGN_CENTER); tabla.addCell(celda); } pagina = pagina - tabla.getRow(1).calculateHeights(); int tam = 0; for (Ctepagar list1 : list) { if (list1.getDetalle().contains("Transporte")) { String fecha = list1.getFecha(); String desc = list1.getDetalle(); String result = ""; String uni = "$ " + df.format(Double.parseDouble(list1.getValor())).replace(",", "."); String tot = "$ " + df.format(Double.parseDouble(list1.getValor())).replace(",", "."); total3 = total3 + Double.parseDouble(list1.getValor()); Object nuevo[] = { fecha, desc, tot }; for (Object obj : nuevo) { celda = new PdfPCell( new Paragraph((String) obj, new Font(fontpersonalizado2))); celda.setBorderColor(new Color(195, 195, 195)); celda.setColspan(1); celda.setHorizontalAlignment(Element.ALIGN_CENTER); tabla.addCell(celda); } pagina = pagina - tabla.getRow(tam).getMaxHeights(); tam++; if (pagina < 50) { salto = new PdfPTable(1); casilla = new PdfPCell(new Phrase("", new Font(fontpersonalizado2))); casilla.setMinimumHeight(90); casilla.setBorder(PdfPCell.NO_BORDER); salto.addCell(casilla); documento.add(salto); documento.add(tabla); documento.newPage(); fondos(documento, canvas); tabla = new PdfPTable(3); tabla.setHorizontalAlignment(PdfPTable.ALIGN_CENTER); tabla.setTotalWidth(ancho); tabla.setLockedWidth(true); tabla.setWidths(new int[] { 1, 3, 1 }); pagina = max; tam = 0; } } } } salto = new PdfPTable(1); casilla = new PdfPCell(new Phrase("", new Font(fontpersonalizado))); casilla.setMinimumHeight(90); casilla.setBorder(PdfPCell.NO_BORDER); salto.addCell(casilla); documento.add(salto); celda = new PdfPCell(new Paragraph("Total", new Font(fontpersonalizado2))); celda.setBorderColor(new Color(195, 195, 195)); celda.setColspan(1); celda.setHorizontalAlignment(Element.ALIGN_CENTER); tabla.addCell(celda); celda = new PdfPCell(new Paragraph("Transporte", new Font(fontpersonalizado2))); celda.setBorderColor(new Color(195, 195, 195)); celda.setColspan(1); celda.setHorizontalAlignment(Element.ALIGN_CENTER); tabla.addCell(celda); celda = new PdfPCell(new Paragraph("$ " + df.format(total3).replace(",", "."), new Font(fontpersonalizado2))); celda.setBorderColor(new Color(195, 195, 195)); celda.setColspan(1); celda.setHorizontalAlignment(Element.ALIGN_CENTER); tabla.addCell(celda); documento.add(tabla); documento.newPage(); fondos(documento, canvas); tabla = new PdfPTable(3); tabla.setHorizontalAlignment(PdfPTable.ALIGN_CENTER); tabla.setTotalWidth(ancho); tabla.setLockedWidth(true); tabla.setWidths(new int[] { 1, 3, 1 }); celda = new PdfPCell(new Paragraph("COMBUSTIBLE")); celda.setColspan(3); celda.setHorizontalAlignment(Element.ALIGN_CENTER); celda.setBorder(PdfPCell.NO_BORDER); tabla.addCell(celda); pagina = documento.getPageSize().getHeight() - 140; pagina = pagina - tabla.getRow(0).calculateHeights(); if (list != null) { Object nuevo2[] = { "FECHA", "DETALLE", "SUBTOTAL" }; for (Object obj : nuevo2) { celda = new PdfPCell(new Paragraph((String) obj, new Font(fontpersonalizado))); celda.setBorderColor(new Color(195, 195, 195)); celda.setColspan(1); celda.setHorizontalAlignment(Element.ALIGN_CENTER); tabla.addCell(celda); } pagina = pagina - tabla.getRow(1).calculateHeights(); int tam = 0; for (Ctepagar list1 : list) { if (list1.getDetalle().contains("Combustible")) { String fecha = list1.getFecha(); String desc = list1.getDetalle(); String result = ""; String uni = "$ " + df.format(Double.parseDouble(list1.getValor())).replace(",", "."); String tot = "$ " + df.format(Double.parseDouble(list1.getValor())).replace(",", "."); total4 = total4 + Double.parseDouble(list1.getValor()); Object nuevo[] = { fecha, desc, tot }; for (Object obj : nuevo) { celda = new PdfPCell( new Paragraph((String) obj, new Font(fontpersonalizado2))); celda.setBorderColor(new Color(195, 195, 195)); celda.setColspan(1); celda.setHorizontalAlignment(Element.ALIGN_CENTER); tabla.addCell(celda); } pagina = pagina - tabla.getRow(tam).getMaxHeights(); tam++; if (pagina < 50) { salto = new PdfPTable(1); casilla = new PdfPCell(new Phrase("", new Font(fontpersonalizado))); casilla.setMinimumHeight(90); casilla.setBorder(PdfPCell.NO_BORDER); salto.addCell(casilla); documento.add(salto); documento.add(tabla); documento.newPage(); fondos(documento, canvas); tabla = new PdfPTable(3); tabla.setHorizontalAlignment(PdfPTable.ALIGN_CENTER); tabla.setTotalWidth(ancho); tabla.setLockedWidth(true); tabla.setWidths(new int[] { 1, 3, 1 }); pagina = max; tam = 0; } } } } salto = new PdfPTable(1); casilla = new PdfPCell(new Phrase("", new Font(fontpersonalizado))); casilla.setMinimumHeight(90); casilla.setBorder(PdfPCell.NO_BORDER); salto.addCell(casilla); documento.add(salto); celda = new PdfPCell(new Paragraph("Total", new Font(fontpersonalizado2))); celda.setBorderColor(new Color(195, 195, 195)); celda.setColspan(1); celda.setHorizontalAlignment(Element.ALIGN_CENTER); tabla.addCell(celda); celda = new PdfPCell(new Paragraph("Combustible", new Font(fontpersonalizado2))); celda.setBorderColor(new Color(195, 195, 195)); celda.setColspan(1); celda.setHorizontalAlignment(Element.ALIGN_CENTER); tabla.addCell(celda); celda = new PdfPCell(new Paragraph("$ " + df.format(total4).replace(",", "."), new Font(fontpersonalizado2))); celda.setBorderColor(new Color(195, 195, 195)); celda.setColspan(1); celda.setHorizontalAlignment(Element.ALIGN_CENTER); tabla.addCell(celda); documento.add(tabla); documento.newPage(); fondos(documento, canvas); //Extras tabla = new PdfPTable(3); tabla.setHorizontalAlignment(PdfPTable.ALIGN_CENTER); tabla.setTotalWidth(ancho); tabla.setLockedWidth(true); tabla.setWidths(new int[] { 1, 3, 1 }); celda = new PdfPCell(new Paragraph("EXTRAS")); celda.setColspan(3); celda.setHorizontalAlignment(Element.ALIGN_CENTER); celda.setBorder(PdfPCell.NO_BORDER); tabla.addCell(celda); pagina = documento.getPageSize().getHeight() - 140; pagina = pagina - tabla.getRow(0).calculateHeights(); if (list != null) { Object nuevo2[] = { "FECHA", "DETALLE", "SUBTOTAL" }; for (Object obj : nuevo2) { celda = new PdfPCell(new Paragraph((String) obj, new Font(fontpersonalizado))); celda.setBorderColor(new Color(195, 195, 195)); celda.setColspan(1); celda.setHorizontalAlignment(Element.ALIGN_CENTER); tabla.addCell(celda); } pagina = pagina - tabla.getRow(1).calculateHeights(); int tam = 0; for (Ctepagar list1 : list) { if (!list1.getDetalle().contains("Combustible") && !list1.getDetalle().contains("ci:") && !list1.getDetalle().contains("Transporte")) { String fecha = list1.getFecha(); String desc = list1.getDetalle(); String result = ""; String uni = "$ " + df.format(Double.parseDouble(list1.getValor())).replace(",", "."); String tot = "$ " + df.format(Double.parseDouble(list1.getValor())).replace(",", "."); total5 = total5 + Double.parseDouble(list1.getValor()); Object nuevo[] = { fecha, desc, tot }; for (Object obj : nuevo) { celda = new PdfPCell( new Paragraph((String) obj, new Font(fontpersonalizado2))); celda.setBorderColor(new Color(195, 195, 195)); celda.setColspan(1); celda.setHorizontalAlignment(Element.ALIGN_CENTER); tabla.addCell(celda); } pagina = pagina - tabla.getRow(tam).getMaxHeights(); tam++; if (pagina < 50) { salto = new PdfPTable(1); casilla = new PdfPCell(new Phrase("", new Font(fontpersonalizado))); casilla.setMinimumHeight(90); casilla.setBorder(PdfPCell.NO_BORDER); salto.addCell(casilla); documento.add(salto); documento.add(tabla); documento.newPage(); fondos(documento, canvas); tabla = new PdfPTable(3); tabla.setHorizontalAlignment(PdfPTable.ALIGN_CENTER); tabla.setTotalWidth(ancho); tabla.setLockedWidth(true); tabla.setWidths(new int[] { 1, 3, 1 }); pagina = max; tam = 0; } } } } salto = new PdfPTable(1); casilla = new PdfPCell(new Phrase("", new Font(fontpersonalizado))); casilla.setMinimumHeight(90); casilla.setBorder(PdfPCell.NO_BORDER); salto.addCell(casilla); documento.add(salto); celda = new PdfPCell(new Paragraph("Total", new Font(fontpersonalizado2))); celda.setBorderColor(new Color(195, 195, 195)); celda.setColspan(1); celda.setHorizontalAlignment(Element.ALIGN_CENTER); tabla.addCell(celda); celda = new PdfPCell(new Paragraph("Extra", new Font(fontpersonalizado2))); celda.setBorderColor(new Color(195, 195, 195)); celda.setColspan(1); celda.setHorizontalAlignment(Element.ALIGN_CENTER); tabla.addCell(celda); celda = new PdfPCell(new Paragraph("$ " + df.format(total5).replace(",", "."), new Font(fontpersonalizado2))); celda.setBorderColor(new Color(195, 195, 195)); celda.setColspan(1); celda.setHorizontalAlignment(Element.ALIGN_CENTER); tabla.addCell(celda); documento.add(tabla); documento.newPage(); fondos(documento, canvas); //Final Vendedor tabla = new PdfPTable(3); tabla.setHorizontalAlignment(PdfPTable.ALIGN_CENTER); tabla.setTotalWidth(ancho); tabla.setLockedWidth(true); tabla.setWidths(new int[] { 1, 3, 1 }); celda = new PdfPCell(new Paragraph(nombrecliente)); celda.setColspan(3); celda.setHorizontalAlignment(Element.ALIGN_CENTER); celda.setBorder(PdfPCell.NO_BORDER); tabla.addCell(celda); celda = new PdfPCell(new Paragraph("Venta")); celda.setColspan(3); celda.setHorizontalAlignment(Element.ALIGN_LEFT); celda.setBorder(PdfPCell.NO_BORDER); tabla.addCell(celda); pagina = documento.getPageSize().getHeight() - 140; pagina = pagina - tabla.getRow(0).calculateHeights(); Object nuevo2[] = { "FECHA", "DETALLE", "TOTAL" }; for (Object obj : nuevo2) { celda = new PdfPCell(new Paragraph((String) obj, new Font(fontpersonalizado))); celda.setBorderColor(new Color(195, 195, 195)); celda.setColspan(1); celda.setHorizontalAlignment(Element.ALIGN_CENTER); tabla.addCell(celda); } Object nuevo3[] = { "", nombreinstalacion, totalinstalacion }; for (Object obj : nuevo3) { celda = new PdfPCell(new Paragraph((String) obj, new Font(fontpersonalizado2))); celda.setBorderColor(new Color(195, 195, 195)); celda.setColspan(1); celda.setHorizontalAlignment(Element.ALIGN_CENTER); tabla.addCell(celda); } celda = new PdfPCell(new Paragraph("INVERSION", new Font(fontpersonalizado))); celda.setBorder(PdfPCell.NO_BORDER); celda.setColspan(3); celda.setHorizontalAlignment(Element.ALIGN_CENTER); tabla.addCell(celda); Object nuevo4[] = { "Uso de Materiales", "", "$ " + df.format(total).replace(",", ".") }; for (Object obj : nuevo4) { celda = new PdfPCell(new Paragraph((String) obj, new Font(fontpersonalizado2))); celda.setBorder(PdfPCell.NO_BORDER); celda.setColspan(1); celda.setHorizontalAlignment(Element.ALIGN_CENTER); tabla.addCell(celda); } Object nuevo5[] = { "Mano de obra tcnicos", "", "$ " + df.format(total2).replace(",", ".") }; for (Object obj : nuevo5) { celda = new PdfPCell(new Paragraph((String) obj, new Font(fontpersonalizado2))); celda.setBorder(PdfPCell.NO_BORDER); celda.setColspan(1); celda.setHorizontalAlignment(Element.ALIGN_CENTER); tabla.addCell(celda); } Object nuevo6[] = { "Transporte", "", "$ " + df.format(total3).replace(",", ".") }; for (Object obj : nuevo6) { celda = new PdfPCell(new Paragraph((String) obj, new Font(fontpersonalizado2))); celda.setBorder(PdfPCell.NO_BORDER); celda.setColspan(1); celda.setHorizontalAlignment(Element.ALIGN_CENTER); tabla.addCell(celda); } Object nuevo7[] = { "Combustible", "", "$ " + df.format(total4).replace(",", ".") }; for (Object obj : nuevo7) { celda = new PdfPCell(new Paragraph((String) obj, new Font(fontpersonalizado2))); celda.setBorder(PdfPCell.NO_BORDER); celda.setColspan(1); celda.setHorizontalAlignment(Element.ALIGN_CENTER); tabla.addCell(celda); } Object nuevo71[] = { "Extras", "", "$ " + df.format(total5).replace(",", ".") }; for (Object obj : nuevo71) { celda = new PdfPCell(new Paragraph((String) obj, new Font(fontpersonalizado2))); celda.setBorder(PdfPCell.NO_BORDER); celda.setColspan(1); celda.setHorizontalAlignment(Element.ALIGN_CENTER); tabla.addCell(celda); } Object nuevo8[] = { "Total Inversin", "", "$ " + df.format(total + total2 + total3 + total4).replace(",", ".") }; for (Object obj : nuevo8) { celda = new PdfPCell(new Paragraph((String) obj, new Font(fontpersonalizado2))); celda.setBorder(PdfPCell.NO_BORDER); celda.setColspan(1); celda.setHorizontalAlignment(Element.ALIGN_CENTER); tabla.addCell(celda); } celda = new PdfPCell(new Paragraph("")); celda.setColspan(3); celda.setHorizontalAlignment(Element.ALIGN_LEFT); celda.setBorder(PdfPCell.NO_BORDER); tabla.addCell(celda); Object nuevo9[] = { "Utilidad del proyecto", "", "$ " + df.format(proyectoval - total - total2 - total3 - total4).replace(",", ".") }; for (Object obj : nuevo9) { celda = new PdfPCell(new Paragraph((String) obj, new Font(fontpersonalizado))); celda.setColspan(1); celda.setBorder(PdfPCell.NO_BORDER); celda.setHorizontalAlignment(Element.ALIGN_CENTER); tabla.addCell(celda); } Object nuevo10[] = { "Rentabilidad ", "", df.format(porcent).replace(",", ".") + " %" }; for (Object obj : nuevo10) { celda = new PdfPCell(new Paragraph((String) obj, new Font(fontpersonalizado))); celda.setBorder(PdfPCell.NO_BORDER); celda.setColspan(1); celda.setHorizontalAlignment(Element.ALIGN_CENTER); tabla.addCell(celda); } salto = new PdfPTable(1); casilla = new PdfPCell(new Phrase("", new Font(fontpersonalizado))); casilla.setMinimumHeight(90); casilla.setBorder(PdfPCell.NO_BORDER); salto.addCell(casilla); documento.add(salto); documento.add(tabla); /*Fin Parte 3*/ documento.close(); helper.cerrarSesion(); } catch (Exception ex) { documento.close(); } JOptionPane.showMessageDialog(null, "PDF Generado"); } catch (Exception io) { System.out.println(io); } } }); f.getjTable1().addMouseListener(new java.awt.event.MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { int row = f.getjTable1().getSelectedRow(); int col = f.getjTable1().getSelectedColumn(); if (col == 4) { f2.setVisible(true); f.setVisible(false); idcliente = f.getjTable1().getValueAt(row, 5).toString(); idinstalacion = f.getjTable1().getValueAt(row, 6).toString(); f2.getjLabel15().setText(f.getjTable1().getValueAt(row, 0).toString()); f2.getjLabel8().setText(f.getjTable1().getValueAt(row, 2).toString()); nombrecliente = f.getjTable1().getValueAt(row, 0).toString(); nombreinstalacion = f.getjTable1().getValueAt(row, 2).toString(); updateTablas up = new updateTablas(1); up.start(); } } }); f5.getjComboBox1().addActionListener(new java.awt.event.ActionListener() { @Override public void actionPerformed(ActionEvent e) { DefaultTableModel temp2 = (DefaultTableModel) f5.getjTable2().getModel(); for (int i = temp2.getRowCount() - 1; i >= 0; i--) { temp2.removeRow(i); } f5.setComi(null); f5.setNinstalacion(""); f5.setNcliente(""); f5.setList(null); f5.setId(""); updateTablas up = new updateTablas(4); up.start(); } }); f3.getjTable1().addMouseListener(new java.awt.event.MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { int row = f3.getjTable1().getSelectedRow(); int col = f3.getjTable1().getSelectedColumn(); if (col == 6) { visible(f4); fcomisiones = f3.getjTable1().getValueAt(row, 6).toString(); try { ServiceHb helper = new ServiceHb(); helper.iniciarTransaccion(); Fcomisiones ft = (Fcomisiones) helper.obtenerObjeto(Fcomisiones.class, Integer.parseInt(fcomisiones)); numeroinstala = ft.getDias(); f4.setIdcliente("" + ft.getClientes().getId()); f4.setIdinstalacion("" + ft.getInstalacion().getId()); f4.getDiasint().setText(numeroinstala); helper.cerrarSesion(); } catch (Exception io) { } f4.getjLabel1().setText(fcomisiones); f4.getC1().setText(f3.getjTable1().getValueAt(row, 0).toString()); f4.getC2().setText(f3.getjTable1().getValueAt(row, 1).toString()); double campo1 = Double .parseDouble(f3.getjTable1().getValueAt(row, 3).toString().replace("$ ", "")); double campo2 = Double .parseDouble(f3.getjTable1().getValueAt(row, 4).toString().replace("-$ ", "")); f4.getC3().setText(f3.getjTable1().getValueAt(row, 3).toString()); f4.getC4().setText(f3.getjTable1().getValueAt(row, 4).toString()); f4.getC5().setText(f3.getjTable1().getValueAt(row, 5).toString()); f4.getC6().setText("$ " + df.format((campo1 - campo2)).replace(",", ".")); updateTablas up = new updateTablas(3); up.start(); } } }); setVisible(false); }
From source file:Model.GerarRelatorio.java
private void insertCell(PdfPTable table, String text, int align, int colspan, Font font) { PdfPCell cell = new PdfPCell(new Phrase(text.trim(), font)); cell.setHorizontalAlignment(align);/*from w w w .ja v a 2 s . c om*/ cell.setColspan(colspan); if (text.trim().equalsIgnoreCase("")) { cell.setMinimumHeight(10f); } table.addCell(cell); }