List of usage examples for com.itextpdf.text Font BOLD
int BOLD
To view the source code for com.itextpdf.text Font BOLD.
Click Source Link
From source file:file.PDFWriter.java
License:Open Source License
/** * Set the font styles for the PDF//from w ww . j av a 2 s.c om */ private void setFontStyles() { lineFont = new Font(FontFamily.TIMES_ROMAN); lineFontUnderline = new Font(FontFamily.TIMES_ROMAN); errorFont = new Font(FontFamily.TIMES_ROMAN); lineFontBold = new Font(FontFamily.TIMES_ROMAN); errorFontBold = new Font(FontFamily.TIMES_ROMAN); lineFontUnderline.setStyle(Font.UNDERLINE); lineFontBold.setStyle(Font.BOLD); errorFont.setStyle(Font.ITALIC); errorFontBold.setStyle(Font.BOLDITALIC); }
From source file:fll.util.PdfUtils.java
License:Open Source License
/** * Create a header cell for a table./*from w w w.ja v a 2 s. c o m*/ */ public static PdfPCell createHeaderCell(final String text) throws BadElementException { final Chunk chunk = new Chunk(text); chunk.getFont().setStyle(Font.BOLD); final PdfPCell cell = createBasicCell(chunk); return cell; }
From source file:forensics_app.SharedModel.java
public static void writePDF(List<List<List>> final_result) { List<List> al = new ArrayList<List>(); Font catFont = new Font(Font.FontFamily.TIMES_ROMAN, 18, Font.BOLD); Font redFont = new Font(Font.FontFamily.TIMES_ROMAN, 12, Font.NORMAL, BaseColor.RED); Font blueFont = new Font(Font.FontFamily.TIMES_ROMAN, 14, Font.NORMAL, BaseColor.BLUE); Font subFont = new Font(Font.FontFamily.TIMES_ROMAN, 16, Font.BOLD); Font smallBold = new Font(Font.FontFamily.TIMES_ROMAN, 12, Font.BOLD); String fileName = System.getProperty("user.home") + "\\Desktop\\" + System.currentTimeMillis() + ".pdf"; Document document = null;// w w w. j ava2 s. c o m document = new Document(); try { PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(fileName)); document.open(); document.add(new Phrase("\n")); document.add(new Paragraph("ForEye Smart Report", redFont)); document.add(new Phrase("\n\n")); for (int z = 0; z < 3; z++) { al = final_result.get(z); switch (z) { case 0: if (al != null) { document.add(new Phrase("\n-> History\n", blueFont)); document.add(new Paragraph("This user interseted in " + al.get(0).get(0) + " by " + String.valueOf(al.get(1).get(0)) + "%", catFont)); document.add(new Phrase("\nthe rest of report\n", subFont)); for (int j = 0; j < al.get(0).size(); j++) { document.add(new Phrase( al.get(0).get(j) + " by " + String.valueOf(al.get(1).get(j)) + "%")); document.add(new Phrase("\n")); } document.add(new Phrase("\n\n")); } break; case 1: if (al != null) { document.add(new Phrase("\n-> Download\n", blueFont)); document.add(new Paragraph("This user interseted in " + al.get(0).get(0) + " by " + String.valueOf(al.get(1).get(0)) + "%", catFont)); document.add(new Phrase("\nthe rest of report\n", subFont)); for (int j = 0; j < al.get(0).size(); j++) { document.add(new Phrase( al.get(0).get(j) + " by " + String.valueOf(al.get(1).get(j)) + "%")); document.add(new Phrase("\n")); } document.add(new Phrase("\n\n")); } break; case 2: if (al != null) { document.add(new Phrase("\n-> Bookmarks\n", blueFont)); document.add(new Paragraph("This user interseted in " + al.get(0).get(0) + " by " + String.valueOf(al.get(1).get(0)) + "%", catFont)); document.add(new Phrase("\nthe rest of report\n", subFont)); for (int j = 0; j < al.get(0).size(); j++) { document.add(new Phrase( al.get(0).get(j) + " by " + String.valueOf(al.get(1).get(j)) + "%")); document.add(new Phrase("\n")); } document.add(new Phrase("\n\n")); } break; } } document.close(); writer.close(); if (Desktop.isDesktopSupported()) { try { File myFile = new File(fileName); Desktop.getDesktop().open(myFile); } catch (IOException ex) { // no application registered for PDFs } } } catch (DocumentException e) { e.printStackTrace(); } catch (FileNotFoundException e) { e.printStackTrace(); } }
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 w w w.j av a2 s .c om*/ 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();//w w w .j a v a 2s . com 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:FormatoPDF.ClasesPDF.TablasPDF.java
public PdfPTable DibujarTabla(int col, int fil, JTable tabla, float medidas[], PdfPTable tab) { try {//w w w . j av a2s.c om tab.setWidths(medidas); for (int i = 0; i < fil; i++) { if (GetDatosTablas.GetData(tabla, i, 0) == null) { break; } for (int j = 0; j < col; j++) { Object obj1 = GetDatosTablas.GetData(tabla, i, j); String value1 = obj1.toString(); PdfPCell cell = new PdfPCell( new Paragraph(value1, FontFactory.getFont("arial", 8, Font.BOLD, BaseColor.BLACK))); tab.addCell(cell); } } } catch (Exception e) { System.out.println("Error " + e); } return tab; }
From source file:FormatoPDF.ClasesPDF.TablasPDF.java
public PdfPTable DibujarTablaArre1(int col, int fil, String[][] tabla, float medidas[], boolean x, PdfPTable tab, int pdf, String ult) { try {//from w w w .ja v a2s . c o m BaseColor MiColor = WebColors.getRGBColor("#04B4AE"); tab.setWidths(medidas); if (pdf == 2) { fil = 7; } for (int i = 1; i < fil; i++) { for (int j = 0; j < col - 2; j++) { if (i == 6) { PdfPCell cell = new PdfPCell(new Phrase("Publicacin de bases: ", FontFactory.getFont("arial", 10, Font.BOLD, BaseColor.BLACK))); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); cell.setBackgroundColor(MiColor); tab.addCell(cell); PdfPCell cell2 = new PdfPCell( new Phrase(ult, FontFactory.getFont("arial", 10, Font.BOLD, BaseColor.BLACK))); cell2.setVerticalAlignment(Element.ALIGN_MIDDLE); cell2.setColspan(5); cell2.setRowspan(1); tab.addCell(cell2); break; } else { Object obj1 = tabla[i][j]; String value1 = obj1.toString(); if (x) { if (j == 0 || j == 2) { PdfPCell cell = new PdfPCell(new Paragraph(value1, FontFactory.getFont("arial", 10, Font.BOLD, BaseColor.BLACK))); cell.setBackgroundColor(MiColor); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); tab.addCell(cell); } else if (j == 3) { PdfPCell cell = new PdfPCell(new Phrase(value1, FontFactory.getFont("arial", 10, Font.BOLD, BaseColor.BLACK))); cell.setColspan(3); cell.setRowspan(1); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); tab.addCell(cell); } else { PdfPCell cell = new PdfPCell(new Phrase(value1, FontFactory.getFont("arial", 10, Font.BOLD, BaseColor.BLACK))); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); tab.addCell(cell); } } else { if (j == 3) { PdfPCell cell = new PdfPCell(new Phrase(value1, FontFactory.getFont("arial", 10, Font.BOLD, BaseColor.BLACK))); cell.setColspan(3); cell.setRowspan(1); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); tab.addCell(cell); } else { PdfPCell cell = new PdfPCell(new Phrase(value1, FontFactory.getFont("arial", 10, Font.BOLD, BaseColor.BLACK))); cell.setVerticalAlignment(Element.ALIGN_MIDDLE); tab.addCell(cell); } } } } } } catch (Exception e) { System.out.println("Error " + e); } return tab; }
From source file:Forms.AddCustomers.java
private void cardBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cardBtnActionPerformed String name = fNameTxt.getText() + " " + lNameTxt.getText(); String cid = cusIdTxt.getText(); Document document = new Document(); Rectangle test = new Rectangle(350, 200); BaseColor color = new BaseColor(63, 72, 204); test.setBackgroundColor(color);/*from w ww .j a va 2 s. c om*/ document.setPageSize(test); File theDir = new File("E:\\CustomerCard"); // if the directory does not exist, create it if (!theDir.exists()) { //System.out.println("creating directory: " + directoryName); boolean result = false; try { theDir.mkdir(); result = true; } catch (SecurityException se) { System.out.println(se.getMessage()); } } try { PdfWriter.getInstance(document, new FileOutputStream("E:\\CustomerCard\\card(" + cid + ").pdf")); document.open(); //Image image; //image = Image.getInstance("api.png"); //document.add(image); document.add(new Paragraph(" Customer Discount Card", FontFactory.getFont(FontFactory.TIMES_BOLD, 16, Font.BOLD, BaseColor.GRAY))); document.add(new Paragraph(" ")); document.add(new Paragraph(" Name : " + name, FontFactory.getFont(FontFactory.TIMES_ROMAN, 12, Font.NORMAL, BaseColor.BLACK))); document.add(new Paragraph(" ")); document.add(new Paragraph(" Card ID: " + cid, FontFactory.getFont(FontFactory.TIMES_ROMAN, 12, Font.NORMAL, BaseColor.BLACK))); document.close(); try { //Runtime.getRuntime().exec("rundll32 url.dll,FileProtocolHandler "+"E:\\CustomerCard\\card("+cid+").pdf"); Runtime.getRuntime().exec("rundll32 url.dll,FileProtocolHandler " + "C:\\Users\\Vidu\\Desktop\\CustomerIDCard\\card(" + cid + ").pdf"); } catch (Exception ex) { Logger.getLogger(SellPage.class.getName()).log(Level.SEVERE, null, ex); } //document.add(new Paragraph(date,FontFactory.getFont(FontFactory.TIMES_ROMAN, 12, Font.NORMAL,BaseColor.BLACK))); fNameTxt.setText(""); lNameTxt.setText(""); cusIdTxt.setText(""); } catch (Exception ex) { ex.printStackTrace(); } }
From source file:Forms.CloseCash.java
private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed String sql = "SELECT * FROM `cash` WHERE 1"; Date dNow = new Date(); SimpleDateFormat ft = new SimpleDateFormat("dd.MM.yyyy"); String date = "" + ft.format(dNow); File theDir = new File("E:\\Reports"); // if the directory does not exist, create it if (!theDir.exists()) { //System.out.println("creating directory: " + directoryName); boolean result = false; try {//from w w w .ja va 2 s. com theDir.mkdir(); result = true; } catch (SecurityException se) { //handle it } } try { Connection con = (Connection) DriverManager.getConnection("jdbc:mysql://localhost:3306/nafis", "root", ""); Statement s = (Statement) con.prepareStatement(sql); ResultSet rs = s.executeQuery(sql); Document document = new Document(PageSize.A5); PdfWriter.getInstance(document, new FileOutputStream("E:\\Reports\\report(" + date + ").pdf")); document.open(); Image image = Image.getInstance("api.png"); document.add(image); document.add(new Paragraph("UNITY POS REPORS", FontFactory.getFont(FontFactory.TIMES_BOLD, 20, Font.BOLD, BaseColor.BLUE))); document.add(new Paragraph(date, FontFactory.getFont(FontFactory.TIMES_ROMAN, 12, Font.NORMAL, BaseColor.BLACK))); document.add(new Paragraph( "--------------------------------------------------------------------------------------")); PdfPTable table = new PdfPTable(4); //table.addCell("Date"); //table.addCell("Cash In/Out"); PdfPCell cell = new PdfPCell(new Phrase("Date")); cell.setBackgroundColor(BaseColor.DARK_GRAY); table.addCell(cell); PdfPCell ce = new PdfPCell(new Phrase("Cash In/Out")); ce.setBackgroundColor(BaseColor.DARK_GRAY); table.addCell(ce); PdfPCell c = new PdfPCell(new Phrase("Cause")); c.setBackgroundColor(BaseColor.DARK_GRAY); table.addCell(c); PdfPCell cel = new PdfPCell(new Phrase("Amount")); cel.setBackgroundColor(BaseColor.DARK_GRAY); table.addCell(cel); document.add(new Paragraph(" ")); document.add(table); float in = 0, out = 0; while (rs.next()) { String dateof = rs.getString(5); String inout = rs.getString(2); String cause = rs.getString(3); String amount = rs.getString(4); if (inout.equalsIgnoreCase("Cash In")) { in = in + Float.parseFloat(amount); } else { out = out + Float.parseFloat(amount); } PdfPTable t = new PdfPTable(4); t.addCell(dateof); t.addCell(inout); t.addCell(cause); t.addCell(amount); document.add(t); } System.out.println("in=" + in + "out=" + out); document.add(new Paragraph(" ")); document.add(new Paragraph("Total Invested: " + out, FontFactory.getFont(FontFactory.TIMES_ROMAN, 12, Font.NORMAL, BaseColor.BLACK))); document.add(new Paragraph("Total Return: " + in, FontFactory.getFont(FontFactory.TIMES_ROMAN, 12, Font.NORMAL, BaseColor.BLACK))); document.add(new Paragraph("Total Earned: " + (in - out), FontFactory.getFont(FontFactory.TIMES_ROMAN, 12, Font.NORMAL, BaseColor.BLACK))); document.add(new Paragraph(" ")); document.add(new Paragraph( "--------------------------------------------------------------------------------------")); document.close(); } catch (Exception ex) { JOptionPane.showMessageDialog(null, "problem in memoo"); } /////////////////////////// //to open pdf invoice try { Runtime.getRuntime() .exec("rundll32 url.dll,FileProtocolHandler " + "E:\\Reports\\report(" + date + ").pdf"); } catch (IOException ex) { Logger.getLogger(SellPage.class.getName()).log(Level.SEVERE, null, ex); } }
From source file:fr.ybonnel.breizhcamppdf.PdfRenderer.java
License:Apache License
private List<Talk> createProgrammePages() throws DocumentException, IOException { List<Talk> talksToExplain = new ArrayList<>(); document.setPageSize(PageSize.A4.rotate()); Font font = new Font(); font.setStyle(Font.BOLD); font.setSize(14);//ww w. ja va 2s. c o m for (String date : service.getDates()) { Set<String> tracksInPage = new HashSet<>(); Map<String, Talk> precedentTalk = new HashMap<>(); PdfPTable table = createBeginningOfPage(font, date); for (String creneau : service.getCreneaux().get(date)) { // Nouvelle page 14h if (creneau.startsWith("14:00") && !tracksInPage.isEmpty()) { document.add(table); addLegend(tracksInPage); table = createBeginningOfPage(font, date); } PdfPCell cellCreneau = new PdfPCell(); cellCreneau.setPaddingBottom(10); Paragraph startTime = new Paragraph(creneau); startTime.setAlignment(Element.ALIGN_CENTER); cellCreneau.addElement(startTime); Paragraph endTime = new Paragraph(getEndTime(date, creneau)); endTime.setAlignment(Element.ALIGN_CENTER); cellCreneau.addElement(endTime); table.addCell(cellCreneau); for (String room : service.getRooms(date)) { PdfPCell cell = new PdfPCell(); cell.setPaddingBottom(10); cell.setHorizontalAlignment(Element.ALIGN_LEFT); Talk talk = service.getTalkByDateAndCreneauxAndRoom(date, creneau, room); if (talk != null) { talksToExplain.add(talk); remplirCellWithTalk(cell, talk); cell.setRowspan(getRowSpan(date, talk)); precedentTalk.put(room, talk); tracksInPage.add(talk.getTrack()); table.addCell(cell); } else { talk = precedentTalk.get(room); if (!(talk != null && talk.getEnd().compareTo(creneau) > 0)) { table.addCell(cell); } } } } document.add(table); addLegend(tracksInPage); } return talksToExplain; }