List of usage examples for com.itextpdf.text Paragraph add
@Override public boolean add(Element o)
Element
to the Paragraph
. From source file:fll.web.report.RankingReport.java
License:Open Source License
private void outputCategory(final Paragraph para, final TeamRanking teamRanks, final String category, boolean useQuartiles) { para.add(new Chunk(category + ": ", RANK_TITLE_FONT)); final CategoryRank catRank = teamRanks.getRankForCategory(category); final int rank = catRank.getRank(); if (CategoryRank.NO_SHOW_RANK == rank) { para.add(new Chunk("No Show", RANK_VALUE_FONT)); } else {/*from w w w . ja va 2 s . c o m*/ final double percentage = (double) rank / catRank.getNumTeams(); if (useQuartiles) { para.add(new Chunk( String.format("%s in %s", convertPercentageToQuartile(percentage), catRank.getGroup()), RANK_VALUE_FONT)); } else { para.add(new Chunk( String.format("%d out of %d teams in %s", rank, catRank.getNumTeams(), catRank.getGroup()), RANK_VALUE_FONT)); } } para.add(Chunk.NEWLINE); }
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();//w ww . ja v a 2 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.ja va 2 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, 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:fr.ensicaen.yousign.GenerePDF.java
public void genere() { try {/* w w w.ja va 2 s . c o m*/ OutputStream file = new FileOutputStream(util.generePDFFilenameToUse()); Document document = new Document(); PdfWriter.getInstance(document, file); document.open(); // // Affichage du logo, de la date et l'heure et avec ou sans frais // document.add(addEntete()); // // Caractristiques du missionnaire (table: nom, prenom, courriel = 1re colonne, adresse = 2me colonne // PdfPTable tableIdentite = new PdfPTable(2); tableIdentite.setWidthPercentage(100); PdfPCell nomCell = new PdfPCell( new Phrase(new Chunk("Nom: " + util.getOrdreMission().getNomMissionnaire() + "\n" + "Prenom: " + util.getOrdreMission().getPrenomMissionnaire() + "\n\n" + "Courriel: " + util.getOrdreMission().getEmailMissionnaire(), fontItemSection))); nomCell.setBorder(Rectangle.NO_BORDER); tableIdentite.addCell(nomCell); Chunk adresseChunk = new Chunk("Adresse: " + "\n" + util.getOrdreMission().getRueMissionnaire() + "\n" + util.getOrdreMission().getCodepostalMissionnaire() + " " + util.getOrdreMission().getVilleMissionnaire() + "\n" + util.getOrdreMission().getPaysMissionnaire(), fontItemSection); PdfPCell adresseCell = new PdfPCell(new Phrase(adresseChunk)); adresseCell.setBorder(Rectangle.NO_BORDER); tableIdentite.addCell(adresseCell); Paragraph identite; identite = new Paragraph(); addEmptyLine(identite, 1); identite.add(tableIdentite); document.add(identite); // // Numero IBAN // Paragraph iban = new Paragraph(); addEmptyLine(iban, 1); iban.add(new Chunk("Numro IBAN: " + util.getOrdreMission().getIban1() + " " + util.getOrdreMission().getIban2() + " " + util.getOrdreMission().getIban3() + " " + util.getOrdreMission().getIban4() + " " + util.getOrdreMission().getIban5() + " " + util.getOrdreMission().getIban6() + " " + util.getOrdreMission().getIban7(), fontItemSection)); document.add(iban); // // Motif de la mission // Paragraph mission = new Paragraph(); addEmptyLine(mission, 1); mission.add( new Chunk("Motif de la mission: " + util.getOrdreMission().getMotifMission(), fontItemSection)); addEmptyLine(mission, 1); // // Dtails de la mission (lieu, dates, ...) // PdfPTable tableMission = new PdfPTable(7); tableMission.setWidthPercentage(100); float[] columnWidths = { 1f, 2f, 1.5f, 1f, 2f, 1.5f, 1f }; tableMission.setWidths(columnWidths); PdfPCell cell; // // Ligne d'entete du tableau des dtails de la mission // tableMission.addCell(""); cell = new PdfPCell(new Phrase("Lieu de dpart")); cell.setHorizontalAlignment(Element.ALIGN_CENTER); tableMission.addCell(cell); cell = new PdfPCell(new Phrase("Date")); cell.setHorizontalAlignment(Element.ALIGN_CENTER); tableMission.addCell(cell); cell = new PdfPCell(new Phrase("Heure")); cell.setHorizontalAlignment(Element.ALIGN_CENTER); tableMission.addCell(cell); cell = new PdfPCell(new Phrase("Lieu d'arrive")); cell.setHorizontalAlignment(Element.ALIGN_CENTER); tableMission.addCell(cell); cell = new PdfPCell(new Phrase("Date")); cell.setHorizontalAlignment(Element.ALIGN_CENTER); tableMission.addCell(cell); cell = new PdfPCell(new Phrase("Heure")); cell.setHorizontalAlignment(Element.ALIGN_CENTER); tableMission.addCell(cell); // // description du voyage aller // tableMission.addCell("Aller"); cell = new PdfPCell(new Phrase(util.getOrdreMission().getLieuDepartAller())); cell.setHorizontalAlignment(Element.ALIGN_CENTER); tableMission.addCell(cell); cell = new PdfPCell(new Phrase(util.getOrdreMission().getDateDepartAller())); cell.setHorizontalAlignment(Element.ALIGN_CENTER); tableMission.addCell(cell); cell = new PdfPCell(new Phrase(util.getOrdreMission().getHeureDepartAller() + ":" + util.getOrdreMission().getMinuteDepartAller())); cell.setHorizontalAlignment(Element.ALIGN_CENTER); tableMission.addCell(cell); cell = new PdfPCell(new Phrase(util.getOrdreMission().getLieuArriveeAller())); cell.setHorizontalAlignment(Element.ALIGN_CENTER); tableMission.addCell(cell); cell = new PdfPCell(new Phrase(util.getOrdreMission().getDateArriveeAller())); cell.setHorizontalAlignment(Element.ALIGN_CENTER); tableMission.addCell(cell); cell = new PdfPCell(new Phrase(util.getOrdreMission().getHeureArriveeAller() + ":" + util.getOrdreMission().getMinuteArriveeAller())); cell.setHorizontalAlignment(Element.ALIGN_CENTER); tableMission.addCell(cell); // // Description du voyage retour // tableMission.addCell("Retour"); cell = new PdfPCell(new Phrase(util.getOrdreMission().getLieuDepartRetour())); cell.setHorizontalAlignment(Element.ALIGN_CENTER); tableMission.addCell(cell); cell = new PdfPCell(new Phrase(util.getOrdreMission().getDateDepartRetour())); cell.setHorizontalAlignment(Element.ALIGN_CENTER); tableMission.addCell(cell); cell = new PdfPCell(new Phrase(util.getOrdreMission().getHeureDepartRetour() + ":" + util.getOrdreMission().getMinuteDepartRetour())); cell.setHorizontalAlignment(Element.ALIGN_CENTER); tableMission.addCell(cell); cell = new PdfPCell(new Phrase(util.getOrdreMission().getLieuArriveeRetour())); cell.setHorizontalAlignment(Element.ALIGN_CENTER); tableMission.addCell(cell); cell = new PdfPCell(new Phrase(util.getOrdreMission().getDateArriveeRetour())); cell.setHorizontalAlignment(Element.ALIGN_CENTER); tableMission.addCell(cell); cell = new PdfPCell(new Phrase(util.getOrdreMission().getHeureArriveeRetour() + ":" + util.getOrdreMission().getMinuteArriveeRetour())); cell.setHorizontalAlignment(Element.ALIGN_CENTER); tableMission.addCell(cell); mission.add(tableMission); document.add(mission); // // Moyens de transport // Paragraph moyensTransport = new Paragraph(); addEmptyLine(moyensTransport, 1); moyensTransport.add(new Chunk("Moyens de transport utiliss\n", fontTitleSection)); if (util.use("Passager")) { moyensTransport.add(new Chunk("Pas de frais de transport comme passager de la voiture de: " + util.getOrdreMission().getNomConducteur() + "\n", fontItemSection)); } if (util.use("Train")) { moyensTransport.add(new Chunk("Train: Classe: " + util.getOrdreMission().getTrainClasse() + " Prix des billets: " + util.getOrdreMission().getTrainPrixBillet() + " Bon de commande: " + util.getOrdreMission().getTrainBonCommande() + " Carte affaire: " + util.getOrdreMission().getTrainCarteAffaire() + "\n", fontItemSection)); } if (util.use("Avion_Bateau")) { moyensTransport.add(new Chunk( "Avion ou Bateau: Classe: " + util.getOrdreMission().getAvionBateauClasse() + " Prix des billets: " + util.getOrdreMission().getAvionBateauPrixBillet() + " Bon de commande: " + util.getOrdreMission().getAvionBateauBonCommande() + " Carte affaire: " + util.getOrdreMission().getAvionBateauCarteAffaire() + "\n", fontItemSection)); } if (util.use("Vehicule_Service")) { moyensTransport.add(new Chunk( "Voiture de service: " + util.getOrdreMission().getVehiculeService() + " Nombre de kilomtres: " + util.getOrdreMission().getVehiculeServiceNombreKilometres() + "\n", fontItemSection)); moyensTransport.add(new Chunk( "Nom des passagers: " + util.getOrdreMission().getVehiculeServiceNomPassagers() + "\n", fontItemSection)); } if (util.use("Vehicule_Personnel")) { moyensTransport.add(new Chunk( "En vertu du dcret No 2006-781 du 3 juillet 2006: je soussign, " + util.getOrdreMission().getPrenomMissionnaire() + " " + util.getOrdreMission().getNomMissionnaire() + ", sollicite l'autorisation ", fontItemSection)); moyensTransport.add(new Chunk("d'utiliser mon vhicule de marque " + util.getOrdreMission().getVehiculePersonnelMarque() + ", de puissance " + util.getOrdreMission().getVehiculePersonnelPuissance() + ", d'immatriculation: " + util.getOrdreMission().getVehiculePersonnelImmatriculation(), fontItemSection)); moyensTransport.add(new Chunk( ", de date d'acquisition " + util.getOrdreMission().getVehiculePersonnelDateAcquisition() + " pour me rendre " + util.getOrdreMission().getLieuArriveeAller(), fontItemSection)); moyensTransport.add(new Chunk(" et dclare avoir souscrit auprs de " + util.getOrdreMission().getVehiculePersonnelNomAssureur() + " une police d'assurance garantissant de manire illimite ma responsabilit personnelle aux termes ", fontItemSection)); moyensTransport.add(new Chunk( "des articles 1382, 1383, 1384 du Code Civil, ainsi qu'ventuellement la responsabilit de l'Etat, y compris le cas o celle-ci est engage vis--vis des personnes transportes. ", fontItemSection)); moyensTransport .add(new Chunk("Cette police comprend l'assurance contentieuse.\n", fontItemSection)); moyensTransport.add(new Chunk( "DECLARATION COMPLEMENTAIRE: je certifie avoir contract l'assurance complmentaire couvrant tous les risques non compris dans l'assurance obligatoire.\n", fontItemSection)); } addEmptyLine(moyensTransport, 1); if (util.use("taxi")) { moyensTransport.add( new Chunk("Le Directeur autorise le remboursement d'un taxi " + "\n", fontItemSection)); } if (util.use("vehicule_location")) { moyensTransport .add(new Chunk("Le Directeur autorise le remboursement d'un vhicule de location " + "\n", fontItemSection)); } if (util.use("Vehicule_Service") || util.use("Vehicule_Personnel") || util.use("vehicule_location")) { moyensTransport .add(new Chunk( "\nJustication de l'utilisation du vhicule personnel ou de la location:" + util.getOrdreMission().getVehiculeJustificatif() + "\n", fontItemSection)); moyensTransport.add( new Chunk("\nJe certifie tre en possession du permis de conduire depuis plus d'un an\n", fontBoldItemSection)); } document.add(moyensTransport); // // Frais annexe // Paragraph fraisAnnexe = new Paragraph(); addEmptyLine(fraisAnnexe, 1); fraisAnnexe.add(new Chunk("Frais Annexe\n", fontTitleSection)); fraisAnnexe.add(new Chunk("Frais d'inscription: " + util.getOrdreMission().getFraisInscription() + " Montant: " + util.getOrdreMission().getMontantInscription() + " ", fontItemSection)); document.add(fraisAnnexe); Paragraph avance = new Paragraph(); addEmptyLine(avance, 1); avance.add(new Chunk("Avance: ", fontTitleSection)); avance.add(new Chunk(util.getOrdreMission().getAvance(), fontItemSection)); document.add(avance); // // Informations financieres // Paragraph finance = new Paragraph(); addEmptyLine(finance, 1); finance.add(new Chunk("Informations financires\n", fontTitleSection)); finance.add(new Chunk("Centre financier: " + util.getOrdreMission().getCentreFinancier() + " Projet ou eOTP: " + util.getOrdreMission().getProjet() + "\n", fontItemSection)); finance.add(new Chunk("Responsable financier: " + util.getOrdreMission().getPrenomResponsableFinancier() + " " + util.getOrdreMission().getNomResponsableFinancier() + "\n", fontItemSection)); finance.add( new Chunk("Autorit hirarchique: " + util.getOrdreMission().getPrenomAutoriteHierarchique() + " " + util.getOrdreMission().getNomAutoriteHierarchique(), fontItemSection)); document.add(finance); // // Informations complementaires eventuelles // if (util.getOrdreMission().getInformationsComplementaires() != null) { Paragraph informationsComplementaires = new Paragraph(); informationsComplementaires.add(new Chunk("\nInformations complementaires: ", fontTitleSection)); informationsComplementaires .add(new Chunk(util.getOrdreMission().getInformationsComplementaires(), fontItemSection)); document.add(informationsComplementaires); } document.close(); file.close(); } catch (DocumentException | IOException e) { System.err .println("Erreur a la generation du fichier " + util.getPdfFileName() + ": " + e.getMessage()); } }
From source file:fr.ensicaen.yousign.GenerePDF.java
private Paragraph addEntete() { Paragraph paragraph = new Paragraph(); PdfPTable table = new PdfPTable(2); table.setWidthPercentage(100);//w w w. j a v a 2s. c om try { // // Affichage du logo // PdfPCell logoCell = new PdfPCell(Image.getInstance(YousignConfig.LOGO), false); // false: le logo ne remplit pas toute la cellule logoCell.setBorder(Rectangle.NO_BORDER); table.addCell(logoCell); // // Affichage de la date et du titre // Date date = new Date(); DateFormat format_fr = DateFormat.getDateInstance(DateFormat.FULL, Locale.FRENCH); PdfPCell titleCell = new PdfPCell(new Phrase( new Chunk(format_fr.format(date) + "\n\n" + title + util.getOrdreMission().getNumeroMission() + "\n" + util.getOrdreMission().getFrais(), fontItemTitleSection))); titleCell.setBorder(Rectangle.NO_BORDER); titleCell.setHorizontalAlignment(Element.ALIGN_CENTER); titleCell.setVerticalAlignment(Element.ALIGN_MIDDLE); table.addCell(titleCell); } catch (BadElementException | IOException ex) { Logger.getLogger(GenerePDF.class.getName()).log(Level.SEVERE, null, ex); } paragraph.add(table); return paragraph; }
From source file:fr.ensicaen.yousign.GenerePDF.java
private void addEmptyLine(Paragraph paragraph, int number) { for (int i = 0; i < number; i++) paragraph.add(new Paragraph(" ")); }
From source file:fr.ybonnel.breizhcamppdf.PdfRenderer.java
License:Apache License
private PdfPCell createHeaderCell(String content) { Paragraph paragraph = new Paragraph(); Font font = new Font(); font.setColor(BaseColor.WHITE);/* w w w . j a v a2s . c o m*/ paragraph.setFont(font); paragraph.add(new Phrase(content)); PdfPCell cell = new PdfPCell(paragraph); cell.setPaddingBottom(10); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setBackgroundColor(BaseColor.GRAY); return cell; }
From source file:fr.ybonnel.breizhcamppdf.PdfRenderer.java
License:Apache License
private PdfPTable createBeginningOfPage(Font font, String date) throws DocumentException { Paragraph titre; document.newPage();//from w w w. j a va 2 s . c o m titre = new Paragraph(); titre.setFont(font); titre.setAlignment(Paragraph.ALIGN_CENTER); titre.add(new Phrase("Programme du " + date)); document.add(titre); float[] relativeWidth = new float[service.getRooms(date).size() + 1]; Arrays.fill(relativeWidth, 1f); relativeWidth[0] = 0.5f; PdfPTable table = new PdfPTable(relativeWidth); table.setWidthPercentage(100); table.setSpacingBefore(10); table.setSpacingAfter(20); table.addCell(createHeaderCell("Heure")); for (String room : service.getRooms(date)) { table.addCell(createHeaderCell(room)); } return table; }
From source file:fr.ybonnel.breizhcamppdf.PdfRenderer.java
License:Apache License
private void remplirCellWithTalk(PdfPCell cell, Talk talk) throws DocumentException, IOException { Image image = AvatarService.INSTANCE.getImage( PdfRenderer.class.getResource("/formats/" + talk.getFormat().replaceAll(" ", "") + ".png")); float[] widths = { 0.15f, 0.85f }; PdfPTable table = new PdfPTable(widths); table.setWidthPercentage(100f);/* ww w . j a va 2 s. co m*/ table.getDefaultCell().setBorder(Rectangle.NO_BORDER); table.addCell(image); PdfPCell subCell = new PdfPCell(); Chunk chunk = new Chunk(talk.getTitle(), talkFont); chunk.setLocalGoto("talk" + talk.getId()); Paragraph titleTalk = new Paragraph(); titleTalk.add(chunk); titleTalk.setAlignment(Paragraph.ALIGN_CENTER); subCell.addElement(titleTalk); Paragraph track = new Paragraph(new Phrase(talk.getTrack(), themeFont)); track.setAlignment(Paragraph.ALIGN_CENTER); subCell.addElement(track); TalkDetail detail = TalkService.INSTANCE.getTalkDetail(talk); if (detail != null) { for (Speaker speaker : detail.getSpeakers()) { Paragraph speakerText = new Paragraph(speaker.getFullname(), speakerFont); speakerText.setAlignment(Paragraph.ALIGN_CENTER); subCell.addElement(speakerText); } } subCell.setBorder(Rectangle.NO_BORDER); table.addCell(subCell); cell.setBackgroundColor(mapTrack.get(talk.getTrack())); cell.addElement(table); }
From source file:fr.ybonnel.breizhcamppdf.RoomPdfRenderer.java
License:Apache License
private PdfPTable createBeginningOfPage(Font font, String date, String room) throws DocumentException { Paragraph titre; document.newPage();//from w ww .java 2s . co m titre = new Paragraph(); titre.setFont(font); titre.setAlignment(Paragraph.ALIGN_CENTER); titre.add(new Phrase("Programme du " + date + " - " + room)); titre.setSpacingAfter(20); document.add(titre); float[] relativeWidth = new float[2]; Arrays.fill(relativeWidth, 1f); relativeWidth[0] = 0.2f; PdfPTable table = new PdfPTable(relativeWidth); table.setWidthPercentage(100); table.setSpacingBefore(10); table.setSpacingAfter(20); table.addCell(createHeaderCell("Heure")); table.addCell(createHeaderCell("")); return table; }