List of usage examples for com.itextpdf.text.pdf PdfWriter setPageEvent
public void setPageEvent(final PdfPageEvent event)
PdfPageEvent
for this document. From source file:org.spinsuite.print.ReportPrintData.java
License:Open Source License
/** * Create a PDF File/*from ww w. j av a 2 s . com*/ * @author Yamel Senih, ysenih@erpcya.com, ERPCyA http://www.erpcya.com 02/04/2014, 22:52:09 * @param outFile * @throws FileNotFoundException * @throws DocumentException * @return void */ private void createPDF(File outFile) throws FileNotFoundException, DocumentException { Document document = new Document(PageSize.LETTER); PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(outFile)); PDFHeaderAndFooter event = new PDFHeaderAndFooter(); writer.setPageEvent(event); document.open(); // document.addAuthor(ctx.getResources().getString(R.string.app_name)); document.addCreationDate(); // Paragraph title = new Paragraph(m_reportQuery.getInfoReport().getName()); // Set Font title.getFont().setStyle(Font.BOLD); // Set Alignment title.setAlignment(Paragraph.ALIGN_CENTER); // Add Title document.add(title); // Add New Line document.add(Chunk.NEWLINE); // Parameters ProcessInfoParameter[] param = m_pi.getParameter(); // Get Parameter if (param != null) { // boolean isFirst = true; // Iterate for (ProcessInfoParameter para : param) { // Get SQL Name String name = para.getInfo(); StringBuffer textParameter = new StringBuffer(); if (para.getParameter() == null && para.getParameter_To() == null) continue; else { // Add Parameters Title if (isFirst) { Paragraph titleParam = new Paragraph( ctx.getResources().getString(R.string.msg_ReportParameters)); // Set Font titleParam.getFont().setStyle(Font.BOLDITALIC); // Add to Document document.add(titleParam); isFirst = false; } // Add Parameters Name if (para.getParameter() != null && para.getParameter_To() != null) { // From and To is filled // textParameter.append(name).append(" => ").append(para.getDisplayValue()).append(" <= ") .append(para.getDisplayValue_To()); } else if (para.getParameter() != null) { // Only From // textParameter.append(name).append(" = ").append(para.getDisplayValue()); } else if (para.getParameter_To() != null) { // Only To // textParameter.append(name).append(" <= ").append(para.getDisplayValue_To()); } } // Add to Document Paragraph viewParam = new Paragraph(textParameter.toString()); document.add(viewParam); } } document.add(Chunk.NEWLINE); // InfoReportField[] columns = m_reportQuery.getColumns(); // Add Table PdfPTable table = new PdfPTable(columns.length); table.setSpacingBefore(4); // Add Header PdfPCell headerCell = new PdfPCell(new Phrase(m_reportQuery.getInfoReport().getName())); headerCell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER); headerCell.setColspan(columns.length); // Add to Table table.addCell(headerCell); // Add Header // Decimal and Date Format DecimalFormat[] cDecimalFormat = new DecimalFormat[columns.length]; SimpleDateFormat[] cDateFormat = new SimpleDateFormat[columns.length]; for (int i = 0; i < columns.length; i++) { InfoReportField column = columns[i]; // Only Numeric if (DisplayType.isNumeric(column.DisplayType)) cDecimalFormat[i] = DisplayType.getNumberFormat(ctx, column.DisplayType, column.FormatPattern); // Only Date else if (DisplayType.isDate(column.DisplayType)) cDateFormat[i] = DisplayType.getDateFormat(ctx, column.DisplayType, column.FormatPattern); // Phrase phrase = new Phrase(column.PrintName); PdfPCell cell = new PdfPCell(phrase); if (column.FieldAlignmentType.equals(InfoReportField.FIELD_ALIGNMENT_TYPE_TRAILING_RIGHT)) cell.setHorizontalAlignment(PdfPCell.ALIGN_RIGHT); else if (column.FieldAlignmentType.equals(InfoReportField.FIELD_ALIGNMENT_TYPE_CENTER)) cell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER); else cell.setHorizontalAlignment(PdfPCell.ALIGN_UNDEFINED); // table.addCell(cell); } // Add Detail for (int row = 0; row < m_data.size(); row++) { // Get Row RowPrintData rPrintData = m_data.get(row); // Iterate for (int col = 0; col < columns.length; col++) { InfoReportField column = columns[col]; ColumnPrintData cPrintData = rPrintData.get(col); Phrase phrase = null; PdfPCell cell = new PdfPCell(); // String value = cPrintData.getValue(); // Only Values if (value != null) { if (DisplayType.isNumeric(column.DisplayType)) { // Number // Format DecimalFormat decimalFormat = cDecimalFormat[col]; // Format if (decimalFormat != null) value = decimalFormat.format(DisplayType.getNumber(value)); // Set Value cell.setHorizontalAlignment(PdfPCell.ALIGN_RIGHT); } else if (DisplayType.isDate(column.DisplayType)) { // Is Date SimpleDateFormat dateFormat = cDateFormat[col]; if (dateFormat != null && value.trim().length() > 0) { long date = Long.parseLong(value); value = dateFormat.format(new Date(date)); } } } // Set Value phrase = new Phrase(value); // if (column.FieldAlignmentType.equals(InfoReportField.FIELD_ALIGNMENT_TYPE_TRAILING_RIGHT)) cell.setHorizontalAlignment(PdfPCell.ALIGN_RIGHT); else if (column.FieldAlignmentType.equals(InfoReportField.FIELD_ALIGNMENT_TYPE_CENTER)) cell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER); else cell.setHorizontalAlignment(PdfPCell.ALIGN_UNDEFINED); // Set Font if (rPrintData.isFunctionRow()) { // Set Function Value if (cPrintData.getFunctionValue() != null && cPrintData.getFunctionValue().length() > 0) phrase = new Phrase(cPrintData.getFunctionValue()); // Set Font phrase.getFont().setStyle(Font.BOLDITALIC); } // Add to Table cell.setPhrase(phrase); table.addCell(cell); } } // Add Table to Document document.add(table); // New Line document.add(Chunk.NEWLINE); // Add Footer StringBuffer footerText = new StringBuffer(Env.getContext("#SUser")); footerText.append("("); footerText.append(Env.getContext("#AD_Role_Name")); footerText.append("@"); footerText.append(Env.getContext("#AD_Client_Name")); footerText.append("."); footerText.append(Env.getContext("#AD_Org_Name")); footerText.append("{").append(Build.MANUFACTURER).append(".").append(Build.MODEL).append("}) "); // Date SimpleDateFormat pattern = DisplayType.getDateFormat(ctx, DisplayType.DATE_TIME); footerText.append(" ").append(ctx.getResources().getString(R.string.Date)).append(" = "); footerText.append(pattern.format(new Date())); // Paragraph footer = new Paragraph(footerText.toString()); footer.setAlignment(Paragraph.ALIGN_CENTER); // Set Font footer.getFont().setSize(8); // Add Footer document.add(footer); // Close Document document.close(); }
From source file:org.spinsuite.view.report.ReportPrintData.java
License:Open Source License
/** * Create a PDF File/* ww w. j av a 2s. c om*/ * @author <a href="mailto:yamelsenih@gmail.com">Yamel Senih</a> 02/04/2014, 22:52:09 * @param outFile * @throws FileNotFoundException * @throws DocumentException * @return void */ private void createPDF(File outFile) throws FileNotFoundException, DocumentException { Document document = new Document(PageSize.LETTER); PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(outFile)); PDFHeaderAndFooter event = new PDFHeaderAndFooter(); writer.setPageEvent(event); document.open(); // document.addAuthor(ctx.getResources().getString(R.string.app_name)); document.addCreationDate(); // Paragraph title = new Paragraph(m_reportQuery.getInfoReport().getName()); // Set Font title.getFont().setStyle(Font.BOLD); // Set Alignment title.setAlignment(Paragraph.ALIGN_CENTER); // Add Title document.add(title); // Add New Line document.add(Chunk.NEWLINE); // Parameters ProcessInfoParameter[] param = m_pi.getParameter(); // Get Parameter if (param != null) { // boolean isFirst = true; // Iterate for (ProcessInfoParameter para : param) { // Get SQL Name String name = para.getInfo(); StringBuffer textParameter = new StringBuffer(); if (para.getParameter() == null && para.getParameter_To() == null) continue; else { // Add Parameters Title if (isFirst) { Paragraph titleParam = new Paragraph( ctx.getResources().getString(R.string.msg_ReportParameters)); // Set Font titleParam.getFont().setStyle(Font.BOLDITALIC); // Add to Document document.add(titleParam); isFirst = false; } // Add Parameters Name if (para.getParameter() != null && para.getParameter_To() != null) { // From and To is filled // textParameter.append(name).append(" => ").append(para.getDisplayValue()).append(" <= ") .append(para.getDisplayValue_To()); } else if (para.getParameter() != null) { // Only From // textParameter.append(name).append(" = ").append(para.getDisplayValue()); } else if (para.getParameter_To() != null) { // Only To // textParameter.append(name).append(" <= ").append(para.getDisplayValue_To()); } } // Add to Document Paragraph viewParam = new Paragraph(textParameter.toString()); document.add(viewParam); } } document.add(Chunk.NEWLINE); // InfoReportField[] columns = m_reportQuery.getColumns(); // Add Table PdfPTable table = new PdfPTable(columns.length); table.setSpacingBefore(4); // Add Header PdfPCell headerCell = new PdfPCell(new Phrase(m_reportQuery.getInfoReport().getName())); headerCell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER); headerCell.setColspan(columns.length); // Add to Table table.addCell(headerCell); // Add Header // Decimal and Date Format DecimalFormat[] cDecimalFormat = new DecimalFormat[columns.length]; SimpleDateFormat[] cDateFormat = new SimpleDateFormat[columns.length]; for (int i = 0; i < columns.length; i++) { InfoReportField column = columns[i]; // Only Numeric if (DisplayType.isNumeric(column.DisplayType)) cDecimalFormat[i] = DisplayType.getNumberFormat(ctx, column.DisplayType, column.FormatPattern); // Only Date else if (DisplayType.isDate(column.DisplayType)) cDateFormat[i] = DisplayType.getDateFormat(ctx, column.DisplayType, column.FormatPattern); // Phrase phrase = new Phrase(column.PrintName); PdfPCell cell = new PdfPCell(phrase); if (column.FieldAlignmentType.equals(InfoReportField.FIELD_ALIGNMENT_TYPE_TRAILING_RIGHT)) cell.setHorizontalAlignment(PdfPCell.ALIGN_RIGHT); else if (column.FieldAlignmentType.equals(InfoReportField.FIELD_ALIGNMENT_TYPE_CENTER)) cell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER); else cell.setHorizontalAlignment(PdfPCell.ALIGN_UNDEFINED); // table.addCell(cell); } // Add Detail for (int row = 0; row < m_data.size(); row++) { // Get Row RowPrintData rPrintData = m_data.get(row); // Iterate for (int col = 0; col < columns.length; col++) { InfoReportField column = columns[col]; ColumnPrintData cPrintData = rPrintData.get(col); Phrase phrase = null; PdfPCell cell = new PdfPCell(); // String value = cPrintData.getValue(); if (DisplayType.isNumeric(column.DisplayType)) { // Number // Format DecimalFormat decimalFormat = cDecimalFormat[col]; // Format if (decimalFormat != null) value = decimalFormat.format(DisplayType.getNumber(value)); // Set Value cell.setHorizontalAlignment(PdfPCell.ALIGN_RIGHT); } else if (DisplayType.isDate(column.DisplayType)) { // Is Date SimpleDateFormat dateFormat = cDateFormat[col]; if (dateFormat != null) { long date = Long.getLong(value, 0); value = dateFormat.format(new Date(date)); } } // Set Value phrase = new Phrase(value); // if (column.FieldAlignmentType.equals(InfoReportField.FIELD_ALIGNMENT_TYPE_TRAILING_RIGHT)) cell.setHorizontalAlignment(PdfPCell.ALIGN_RIGHT); else if (column.FieldAlignmentType.equals(InfoReportField.FIELD_ALIGNMENT_TYPE_CENTER)) cell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER); else cell.setHorizontalAlignment(PdfPCell.ALIGN_UNDEFINED); // Set Font if (rPrintData.isFunctionRow()) { // Set Function Value if (cPrintData.getFunctionValue() != null && cPrintData.getFunctionValue().length() > 0) phrase = new Phrase(cPrintData.getFunctionValue()); // Set Font phrase.getFont().setStyle(Font.BOLDITALIC); } // Add to Table cell.setPhrase(phrase); table.addCell(cell); } } // Add Table to Document document.add(table); // New Line document.add(Chunk.NEWLINE); // Add Footer StringBuffer footerText = new StringBuffer(Env.getContext(ctx, "#SUser")); footerText.append("("); footerText.append(Env.getContext(ctx, "#AD_Role_Name")); footerText.append("@"); footerText.append(Env.getContext(ctx, "#AD_Client_Name")); footerText.append("."); footerText.append(Env.getContext(ctx, "#AD_Org_Name")); footerText.append("{").append(Build.MANUFACTURER).append(".").append(Build.MODEL).append("}) "); // Date SimpleDateFormat pattern = DisplayType.getDateFormat(ctx, DisplayType.DATE_TIME); footerText.append(" ").append(ctx.getResources().getString(R.string.Date)).append(" = "); footerText.append(pattern.format(new Date())); // Paragraph footer = new Paragraph(footerText.toString()); footer.setAlignment(Paragraph.ALIGN_CENTER); // Set Font footer.getFont().setSize(8); // Add Footer document.add(footer); // Close Document document.close(); }
From source file:PDF.Reportes.java
public void reportesPDF(HttpServletResponse response, int tr, ServletContext d, String usuario, String contra, String horario, int opc) { String reporteT = ""; try {//ww w. ja v a 2 s . co m Document reporte = new Document(); Calendar cal = Calendar.getInstance(); Paragraph intro = new Paragraph(); intro.setAlignment(Element.ALIGN_CENTER); String linea = "/Imagenes/rallita.png"; String absolute_url_linea = d.getRealPath(linea); Image linea_div = Image.getInstance(absolute_url_linea); Paragraph vacio = new Paragraph(" ", FontFactory.getFont("arial", 10)); vacio.setAlignment(Element.ALIGN_CENTER); if (tr == 0) { PdfWriter writer = PdfWriter.getInstance(reporte, response.getOutputStream()); Rectangle rect = new Rectangle(30, 30, 550, 800); writer.setBoxSize("art", rect); HeaderFooterPageEvent event = new HeaderFooterPageEvent("header_pdf.png"); writer.setPageEvent(event); reporte.open(); reporte.add(vacio); reporte.add(vacio); ArrayList<JFreeChart> graf = grafica(usuario, contra); if (graf == null) { intro = new Paragraph( "Lo sentimos, por el momento an no existe informacin para este reporte.", FontFactory.getFont("arial", 18)); reporte.add(intro); } else { for (int i = 0; i < graf.size(); i++) { BufferedImage bufferedImage = graf.get(i).createBufferedImage(500, 300); Image chart = Image.getInstance(writer, bufferedImage, 1.0f); reporte.add(vacio); reporte.add(chart); } } reporteT = "Estadsticas de registros."; } if (tr == 1) { PdfWriter writer = PdfWriter.getInstance(reporte, response.getOutputStream()); Rectangle rect = new Rectangle(30, 30, 550, 800); writer.setBoxSize("art", rect); HeaderFooterPageEvent event = new HeaderFooterPageEvent("header_pdf.png"); writer.setPageEvent(event); reporte.open(); reporte.add(linea_div); Paragraph creador = new Paragraph("Instituto Tecnolgico de Toluca\n" + "\n" + "Centro de Cmputo\n" + "\n" + "Coordinacin de Desarrollo de Sistemas", FontFactory.getFont("arial", 10)); reporte.add(creador); reporte.add(linea_div); intro = new Paragraph("Sin alta en CENEVAL " + cal.get(Calendar.YEAR), FontFactory.getFont("arial", 18)); intro.setAlignment(Element.ALIGN_CENTER); reporte.add(intro); reporte.add(vacio); reporte.add(vacio); reporte.add(noaltaCen(usuario, contra)); reporteT = "Sin alta en CENEVAL."; } if (tr == 2) { PdfWriter writer = PdfWriter.getInstance(reporte, response.getOutputStream()); Rectangle rect = new Rectangle(30, 30, 550, 800); writer.setBoxSize("art", rect); HeaderFooterPageEvent event = new HeaderFooterPageEvent("header_pdf.png"); writer.setPageEvent(event); reporte.open(); reporte.add(linea_div); Paragraph creador = new Paragraph("Instituto Tecnolgico de Toluca\n" + "\n" + "Centro de Cmputo\n" + "\n" + "Coordinacin de Desarrollo de Sistemas", FontFactory.getFont("arial", 10)); reporte.add(creador); reporte.add(linea_div); intro = new Paragraph("Estatus Prefichas " + cal.get(Calendar.YEAR), FontFactory.getFont("arial", 18)); intro.setAlignment(Element.ALIGN_CENTER); reporte.add(intro); reporte.add(vacio); reporte.add(vacio); reporte.add(statusfichas(usuario, contra)); reporteT = "Estatus prefichas"; } if (tr == 3) { PdfWriter writer = PdfWriter.getInstance(reporte, response.getOutputStream()); Rectangle rect = new Rectangle(30, 30, 550, 800); writer.setBoxSize("art", rect); HeaderFooterPageEvent event = new HeaderFooterPageEvent("header_pdf.png"); writer.setPageEvent(event); reporte.open(); reporte.add(linea_div); Paragraph creador = new Paragraph("Instituto Tecnolgico de Toluca\n" + "\n" + "Centro de Cmputo\n" + "\n" + "Coordinacin de Desarrollo de Sistemas", FontFactory.getFont("arial", 10)); reporte.add(creador); reporte.add(linea_div); intro = new Paragraph("Pre proceso concluido " + cal.get(Calendar.YEAR), FontFactory.getFont("arial", 18)); intro.setAlignment(Element.ALIGN_CENTER); reporte.add(intro); reporte.add(vacio); reporte.add(vacio); reporte.add(procesoCon(usuario, contra)); reporteT = "Pre proceso concluido"; } if (tr == 4) { PdfWriter writer = PdfWriter.getInstance(reporte, response.getOutputStream()); ArrayList<PdfPTable> tables = firmasAspAula(usuario, contra, horario, opc); Rectangle rect = new Rectangle(30, 30, 550, 800); writer.setBoxSize("art", rect); HeaderFooterPageEvent2 event = new HeaderFooterPageEvent2("ficha-pdf.png"); writer.setPageEvent(event); reporte.open(); if (tables.size() != 1) { PdfPTable tableH = tables.get(tables.size() - 1); tableH.writeSelectedRows(0, -1, 10, 720, writer.getDirectContent()); } else { reporte.add(tables.get(0)); } reporte.add(vacio); reporte.add(vacio); reporte.add(vacio); for (int i = 0; i < tables.size(); i++) { if (i + 1 != tables.size()) { reporte.add(tables.get(i)); if (i + 2 != tables.size()) { reporte.newPage(); } } } reporteT = "Firmas Aspirantes_" + horario; } if (tr == 5) { PdfWriter writer = PdfWriter.getInstance(reporte, response.getOutputStream()); ArrayList<PdfPTable> tables = tablaAspAula(usuario, contra, horario, opc); Rectangle rect = new Rectangle(30, 30, 550, 800); writer.setBoxSize("art", rect); HeaderFooterPageEvent2 event = new HeaderFooterPageEvent2("ficha-pdf.png"); writer.setPageEvent(event); reporte.open(); if (tables.size() != 1) { PdfPTable tableH = tables.get(tables.size() - 1); tableH.writeSelectedRows(0, -1, 10, 720, writer.getDirectContent()); } else { reporte.add(tables.get(0)); } reporte.add(vacio); reporte.add(vacio); reporte.add(vacio); for (int i = 0; i < tables.size(); i++) { if (i + 1 != tables.size()) { reporte.add(tables.get(i)); if (i + 2 != tables.size()) { reporte.newPage(); } } } reporteT = "Aspirantes por aula horario_" + horario; } reporte.addTitle("Reportes_" + reporteT); reporte.addSubject("Instituto Tecnolgico de Toluca"); reporte.addKeywords("Instituto Tecnolgico de Toluca"); reporte.addAuthor("Coordinacion de desarrollo de sistemas"); reporte.addCreator("Centro de Cmputo ITT"); //Asignamos el manejador de eventos al escritor. reporte.close(); } catch (DocumentException | IOException ex) { Logger.getLogger(Reportes.class.getName()).log(Level.SEVERE, null, ex); } }
From source file:pkgAgenda_Virtual.frmActividades.java
public void PDFpersonales() throws SQLException { Document documento = new Document(); FileOutputStream FacturaPdf;//from w w w .ja va2s. c om try { FacturaPdf = new FileOutputStream("archives/ActividadesPersonales.pdf"); PdfWriter writer = PdfWriter.getInstance(documento, FacturaPdf); com.itextpdf.text.Rectangle rct = new com.itextpdf.text.Rectangle(36, 54, 559, 788); writer.setBoxSize("art", rct); HeaderFooter event = new HeaderFooter(); writer.setPageEvent(event); } catch (DocumentException | FileNotFoundException ex) { JOptionPane.showMessageDialog(null, ex.toString()); } try { Calendar fecha = Calendar.getInstance(); documento.open(); com.itextpdf.text.Image imagen = com.itextpdf.text.Image.getInstance("archives\\AgendaVirtual.png"); imagen.setAbsolutePosition(0f, 0f); documento.add(imagen); Paragraph AV = new Paragraph("Agenda Virtual", FontFactory.getFont("Segoe UI", 22, Font.NORMAL, BaseColor.BLACK)); AV.setAlignment(Element.ALIGN_RIGHT); documento.add(AV); documento.add(new Paragraph(" ")); documento.add(new Paragraph(" ")); documento.add(new Paragraph(" ")); documento.add(new Paragraph(" ")); documento.add(new Paragraph("Actividades Personales de " + frmLogin.usuario)); documento.add(new Paragraph("Fecha de Reporte: " + fecha.get(Calendar.DAY_OF_MONTH) + "/" + fecha.get(Calendar.MONTH) + "/" + fecha.get(Calendar.YEAR) + " " + fecha.get(Calendar.HOUR_OF_DAY) + ":" + fecha.get(Calendar.MINUTE))); documento.add(new Paragraph(" ")); documento.add(new Paragraph(" ")); documento.add(new Paragraph(" ")); documento.add(new Paragraph(" ")); documento.add(new Paragraph(" ")); PdfPTable tblHoy = new PdfPTable(4); PdfPTable tblAntes = new PdfPTable(4); PdfPTable tblDespues = new PdfPTable(4); tblHoy.addCell("Titulo"); tblHoy.addCell("Fecha"); tblHoy.addCell("Hora"); tblHoy.addCell("Lugar"); tblAntes.addCell("Titulo"); tblAntes.addCell("Fecha"); tblAntes.addCell("Hora"); tblAntes.addCell("Lugar"); tblDespues.addCell("Titulo"); tblDespues.addCell("Fecha"); tblDespues.addCell("Hora"); tblDespues.addCell("Lugar"); //sdfhfjhsdfsd int valor; rs = H.Buscar("SELECT nom_act, fecha_act, hora_act, lugar_act FROM Actividades WHERE cod_usu = " + H.Usuario + " AND id_tipoact = 2"); while (rs.next()) { String fecharecibida = rs.getString(2).substring(0, 10); valor = H.FechaAnterior(fecharecibida); if (valor == 2) { tblHoy.addCell(H.desencriptar(rs.getString(1))); tblHoy.addCell(fecharecibida); tblHoy.addCell(rs.getString(3).substring(0, 5)); tblHoy.addCell(H.desencriptar(rs.getString(4))); } else if (valor == 1) { tblAntes.addCell(H.desencriptar(rs.getString(1))); tblAntes.addCell(fecharecibida); tblAntes.addCell(rs.getString(3).substring(0, 5)); tblAntes.addCell(H.desencriptar(rs.getString(4))); } else if (valor == 0) { tblDespues.addCell(H.desencriptar(rs.getString(1))); tblDespues.addCell(fecharecibida); tblDespues.addCell(rs.getString(3).substring(0, 5)); tblDespues.addCell(H.desencriptar(rs.getString(4))); } } //askjdhskfjhdf documento.add(new Paragraph("Actividades Pasadas")); documento.add(new Paragraph(" ")); documento.add(tblAntes); documento.add(new Paragraph(" ")); documento.add(new Paragraph("Actividades de Hoy")); documento.add(new Paragraph(" ")); documento.add(tblHoy); documento.add(new Paragraph(" ")); documento.add(new Paragraph("Actividades Futuras")); documento.add(new Paragraph(" ")); documento.add(tblDespues); documento.add(new Paragraph(" ")); documento.add(P); documento.close(); } catch (DocumentException | IOException ex) { JOptionPane.showMessageDialog(null, ex.toString()); } }
From source file:pkgAgenda_Virtual.frmActividades.java
public void PDFdeestudio() throws SQLException { Document documento = new Document(); FileOutputStream FacturaPdf;/* w ww . j a v a2s . co m*/ try { FacturaPdf = new FileOutputStream("archives/ActividadesdeEstudio.pdf"); PdfWriter writer = PdfWriter.getInstance(documento, FacturaPdf); com.itextpdf.text.Rectangle rct = new com.itextpdf.text.Rectangle(36, 54, 559, 788); writer.setBoxSize("art", rct); HeaderFooter event = new HeaderFooter(); writer.setPageEvent(event); } catch (DocumentException | FileNotFoundException ex) { JOptionPane.showMessageDialog(null, ex.toString()); } try { Calendar fecha = Calendar.getInstance(); documento.open(); com.itextpdf.text.Image imagen = com.itextpdf.text.Image.getInstance("archives\\AgendaVirtual.png"); imagen.setAbsolutePosition(0f, 0f); documento.add(imagen); Paragraph AV = new Paragraph("Agenda Virtual", FontFactory.getFont("Segoe UI", 22, Font.NORMAL, BaseColor.BLACK)); AV.setAlignment(Element.ALIGN_RIGHT); documento.add(AV); documento.add(new Paragraph(" ")); documento.add(new Paragraph(" ")); documento.add(new Paragraph(" ")); documento.add(new Paragraph(" ")); documento.add(new Paragraph("Actividades de Estudio de " + frmLogin.usuario)); documento.add(new Paragraph("Fecha de Reporte: " + fecha.get(Calendar.DAY_OF_MONTH) + "/" + fecha.get(Calendar.MONTH) + "/" + fecha.get(Calendar.YEAR) + " " + fecha.get(Calendar.HOUR_OF_DAY) + ":" + fecha.get(Calendar.MINUTE))); documento.add(new Paragraph(" ")); documento.add(new Paragraph(" ")); documento.add(new Paragraph(" ")); documento.add(new Paragraph(" ")); documento.add(new Paragraph(" ")); PdfPTable tblHoy = new PdfPTable(4); PdfPTable tblAntes = new PdfPTable(4); PdfPTable tblDespues = new PdfPTable(4); tblHoy.addCell("Asignatura"); tblHoy.addCell("Tarea"); tblHoy.addCell("Fecha"); tblHoy.addCell("Hora"); tblAntes.addCell("Asignatura"); tblAntes.addCell("Tarea"); tblAntes.addCell("Fecha"); tblAntes.addCell("Hora"); tblDespues.addCell("Asignatura"); tblDespues.addCell("Tarea"); tblDespues.addCell("Fecha"); tblDespues.addCell("Hora"); //sdfhfjhsdfsd int valor; rs = H.Buscar("SELECT nom_act, des_act, fecha_act, hora_act FROM Actividades WHERE cod_usu = " + H.Usuario + " AND id_tipoact = 1"); while (rs.next()) { String fecharecibida = rs.getString(3).substring(0, 10); valor = H.FechaAnterior(fecharecibida); if (valor == 2) { tblHoy.addCell(H.desencriptar(rs.getString(1))); tblHoy.addCell(H.desencriptar(rs.getString(2))); tblHoy.addCell(fecharecibida); tblHoy.addCell(rs.getString(4).substring(0, 5)); } else if (valor == 1) { tblAntes.addCell(H.desencriptar(rs.getString(1))); tblAntes.addCell(H.desencriptar(rs.getString(2))); tblAntes.addCell(fecharecibida); tblAntes.addCell(rs.getString(4).substring(0, 5)); } else if (valor == 0) { tblDespues.addCell(H.desencriptar(rs.getString(1))); tblDespues.addCell(H.desencriptar(rs.getString(2))); tblDespues.addCell(fecharecibida); tblDespues.addCell(rs.getString(4).substring(0, 5)); } } //askjdhskfjhdf documento.add(new Paragraph("Actividades Pasadas")); documento.add(new Paragraph(" ")); documento.add(tblAntes); documento.add(new Paragraph(" ")); documento.add(new Paragraph("Actividades de Hoy")); documento.add(new Paragraph(" ")); documento.add(tblHoy); documento.add(new Paragraph(" ")); documento.add(new Paragraph("Actividades Futuras")); documento.add(new Paragraph(" ")); documento.add(tblDespues); documento.add(new Paragraph(" ")); documento.add(P); documento.close(); } catch (DocumentException | IOException ex) { JOptionPane.showMessageDialog(null, ex.toString()); } }
From source file:pkgAgenda_Virtual.frmAgenda.java
public void PDF() throws SQLException { Document documento = new Document(); FileOutputStream FacturaPdf;// w w w . j a v a 2 s . co m try { FacturaPdf = new FileOutputStream("archives/Notas.pdf"); PdfWriter writer = PdfWriter.getInstance(documento, FacturaPdf); com.itextpdf.text.Rectangle rct = new com.itextpdf.text.Rectangle(36, 54, 559, 788); writer.setBoxSize("art", rct); HeaderFooter event = new HeaderFooter(); writer.setPageEvent(event); } catch (DocumentException | FileNotFoundException ex) { JOptionPane.showMessageDialog(null, ex.toString()); } try { Calendar fecha = Calendar.getInstance(); documento.open(); com.itextpdf.text.Image imagen = com.itextpdf.text.Image.getInstance("archives\\AgendaVirtual.png"); imagen.setAbsolutePosition(0f, 0f); documento.add(imagen); Paragraph AV = new Paragraph("Agenda Virtual", FontFactory.getFont("Segoe UI", 22, Font.NORMAL, BaseColor.BLACK)); AV.setAlignment(Element.ALIGN_RIGHT); documento.add(AV); documento.add(new Paragraph(" ")); documento.add(new Paragraph(" ")); documento.add(new Paragraph(" ")); documento.add(new Paragraph(" ")); documento.add(new Paragraph("Notas de " + frmLogin.usuario)); documento.add(new Paragraph("Fecha de Reporte: " + fecha.get(Calendar.DAY_OF_MONTH) + "/" + fecha.get(Calendar.MONTH) + "/" + fecha.get(Calendar.YEAR) + " " + fecha.get(Calendar.HOUR_OF_DAY) + ":" + fecha.get(Calendar.MINUTE))); documento.add(new Paragraph(" ")); documento.add(new Paragraph(" ")); documento.add(new Paragraph(" ")); documento.add(new Paragraph(" ")); documento.add(new Paragraph(" ")); PdfPTable tabla = new PdfPTable(2); tabla.addCell("Titulo"); tabla.addCell("Descripcion"); //sdfhfjhsdfsd rs = H.Buscar( "SELECT nom_nota, des_nota FROM Notas WHERE cod_usu = " + H.Usuario + " ORDER BY nom_nota ASC"); while (rs.next()) { tabla.addCell(rs.getString(1)); tabla.addCell(rs.getString(2)); } //askjdhskfjhdf documento.add(tabla); documento.add(new Paragraph(" ")); documento.add(new Paragraph(" ")); documento.add(new Paragraph(" ")); documento.add(new Paragraph(" ")); documento.add(new Paragraph(" ")); documento.add(new Paragraph(" ")); documento.add(new Paragraph(" ")); documento.add(new Paragraph(" ")); documento.add(new Paragraph(" ")); documento.add(new Paragraph(" ")); documento.add(new Paragraph(" ")); documento.add(new Paragraph(" ")); documento.add(new Paragraph(" ")); documento.add(new Paragraph(" ")); documento.add(new Paragraph(" ")); documento.add(new Paragraph(" ")); documento.add(new Paragraph(" ")); documento.add(new Paragraph(" ")); documento.add(new Paragraph(" ")); documento.add(P); documento.close(); } catch (DocumentException | IOException ex) { JOptionPane.showMessageDialog(null, ex.toString()); } }
From source file:pkgAgenda_Virtual.frmVerContactos.java
public void PDF() throws SQLException { Document documento = new Document(); FileOutputStream FacturaPdf;//from w w w.j a v a 2 s. c o m try { FacturaPdf = new FileOutputStream("archives/Contactos.pdf"); PdfWriter writer = PdfWriter.getInstance(documento, FacturaPdf); com.itextpdf.text.Rectangle rct = new com.itextpdf.text.Rectangle(36, 54, 559, 788); writer.setBoxSize("art", rct); HeaderFooter event = new HeaderFooter(); writer.setPageEvent(event); } catch (DocumentException | FileNotFoundException ex) { JOptionPane.showMessageDialog(null, ex.toString()); } try { Calendar fecha = Calendar.getInstance(); documento.open(); com.itextpdf.text.Image imagen = com.itextpdf.text.Image.getInstance("archives\\AgendaVirtual.png"); imagen.setAbsolutePosition(0f, 0f); documento.add(imagen); Paragraph AV = new Paragraph("Agenda Virtual", FontFactory.getFont("Segoe UI", 22, Font.NORMAL, BaseColor.BLACK)); AV.setAlignment(Element.ALIGN_RIGHT); documento.add(AV); documento.add(new Paragraph(" ")); documento.add(new Paragraph(" ")); documento.add(new Paragraph(" ")); documento.add(new Paragraph(" ")); documento.add(new Paragraph("Contactos de " + frmLogin.usuario)); documento.add(new Paragraph("Fecha de Reporte: " + fecha.get(Calendar.DAY_OF_MONTH) + "/" + fecha.get(Calendar.MONTH) + "/" + fecha.get(Calendar.YEAR) + " " + fecha.get(Calendar.HOUR_OF_DAY) + ":" + fecha.get(Calendar.MINUTE))); documento.add(new Paragraph(" ")); documento.add(new Paragraph(" ")); documento.add(new Paragraph(" ")); documento.add(new Paragraph(" ")); documento.add(new Paragraph(" ")); PdfPTable tabla = new PdfPTable(4); tabla.addCell("Apellidos"); tabla.addCell("Nombres"); tabla.addCell("Telefono"); tabla.addCell("Correo"); //sdfhfjhsdfsd rs = H.Buscar("SELECT ape_contacto FROM Contactos WHERE cod_usu = " + H.Usuario + ""); while (rs.next()) { cantidad_contactos += 1; } contactosdesordenados = new String[cantidad_contactos]; rs = H.Buscar("SELECT ape_contacto FROM Contactos WHERE cod_usu = " + H.Usuario + ""); while (rs.next()) { contactosdesordenados[num_contacto] = H.desencriptar(rs.getString(1)); num_contacto += 1; } contactosordenados = new String[cantidad_contactos]; Arrays.sort(contactosdesordenados); contactosordenados = contactosdesordenados; for (int i = 0; i < contactosordenados.length; i++) { if (!"".equals(contactosordenados[i].toString())) { rs = H.Buscar( "SELECT ape_contacto, nom_contacto, tel1_contacto, correo_contacto FROM Contactos WHERE ape_contacto = '" + H.encriptar(contactosordenados[i].toString()) + "'"); while (rs.next()) { tabla.addCell(H.desencriptar(rs.getString(1))); tabla.addCell(H.desencriptar(rs.getString(2))); tabla.addCell(rs.getString(3)); tabla.addCell(H.desencriptar(rs.getString(4))); } } } //askjdhskfjhdf documento.add(tabla); documento.add(new Paragraph(" ")); documento.add(new Paragraph(" ")); documento.add(new Paragraph(" ")); documento.add(new Paragraph(" ")); documento.add(new Paragraph(" ")); documento.add(new Paragraph(" ")); documento.add(new Paragraph(" ")); documento.add(new Paragraph(" ")); documento.add(new Paragraph(" ")); documento.add(new Paragraph(" ")); documento.add(new Paragraph(" ")); documento.add(new Paragraph(" ")); documento.add(new Paragraph(" ")); documento.add(new Paragraph(" ")); documento.add(new Paragraph(" ")); documento.add(new Paragraph(" ")); documento.add(new Paragraph(" ")); documento.add(new Paragraph(" ")); documento.add(new Paragraph(" ")); documento.add(P); documento.close(); } catch (DocumentException | IOException ex) { JOptionPane.showMessageDialog(null, ex.toString()); } }
From source file:Report.RelatorioAluno.java
/** * funcao para gerar o stream do relatorio * * @return ByteArrayOutputStream//from ww w .ja v a2 s. c om */ public ByteArrayOutputStream relatorioAlunosMatriculados() { ByteArrayOutputStream baos = new ByteArrayOutputStream(); FacesContext faces = FacesContext.getCurrentInstance(); // pega o contexto da aplicacao realPath = faces.getExternalContext().getRealPath("/"); //realPath = "C:/Users/Alessandro/Desktop/TCC2/SisGES/build/web"; try { BaseFont fHelvetica = BaseFont.createFont(BaseFont.HELVETICA, "Cp1252", false); //---------------------------------------------------------------------- // creation of the document with a certain size and certain margins // may want to use PageSize.LETTER instead Document document = new Document(PageSize.A4, 40, 40, 20, 50); document.addAuthor("SisGES"); // optional document.addSubject("Relatrio"); // opcional document.addKeywords("SisGES"); document.addCreator("iText"); //---------------------------------------------------------------------- // creation of the different writers //PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("web/resources/report/alunosMatriculados.pdf")); PdfWriter writer = PdfWriter.getInstance(document, baos); writer.setBoxSize("header", new Rectangle(36, 54, 559, 788)); //---------------------------------------------------------------------- // ADICIONA HEADER E FOOTER //---------------------------------------------------------------------- HeaderFooter headerFooter = new HeaderFooter(); writer.setPageEvent(headerFooter); //---------------------------------------------------------------------- // ABRE DOCUMENTO PARA ESCRITA //---------------------------------------------------------------------- document.open(); //---------------------------------------------------------------------- //ADICIONAR LOGO NO DOCUMENTO //---------------------------------------------------------------------- Image logoUfu = Image.getInstance(realPath + "/resources/images/logoUFU.png"); logoUfu.scaleAbsolute(57, 56);//(largura,altura) logoUfu.isImgTemplate(); //add no template //logoUfu.setAbsolutePosition(30, 745); //x ,y por referencia do rodape document.add(logoUfu); Image logoFacom = Image.getInstance(realPath + "/resources/images/logoFacom.png"); logoFacom.scaleAbsolute(62, 55);//(largura,altura) logoFacom.setAbsolutePosition(92, 767); //x ,y por referencia do rodape //logoFacom.isImgTemplate(); //add no template document.add(logoFacom); //---------------------------------------------------------------------- //ADICIONAR CABEALHO //---------------------------------------------------------------------- PdfContentByte univ = writer.getDirectContentUnder(); univ.beginText(); univ.setFontAndSize(fHelvetica, 10); univ.setTextMatrix(349, 805); // x e y univ.showText("UNIVERSIDADE FEDERAL DE UBERLNDIA"); univ.setTextMatrix(405, 790); // x e y univ.showText("FACULDADE DE COMPUTAO"); univ.setTextMatrix(403, 775); // x e y univ.showText("COORDENADORIA DE ESTGIO "); univ.endText(); PdfContentByte univEnd = writer.getDirectContentUnder(); univEnd.beginText(); univEnd.setFontAndSize(fHelvetica, 7); univEnd.setTextMatrix(326, 761); // x e y univEnd.showText("Campus Universitrio - Santa Mnica - CEP 38408-100 - Uberlndia - MG"); univEnd.setTextMatrix(432, 750); // x e y univEnd.showText("Telefone: (34) 3239-4144 ou 3239-4393"); univEnd.endText(); //---------------------------------------------------------------------- //ADICIONAR TITULO //---------------------------------------------------------------------- PdfContentByte titulo = writer.getDirectContentUnder(); titulo.beginText(); titulo.setFontAndSize(fHelvetica, 16); titulo.setTextMatrix(210, 700); // x e y titulo.showText("Alunos Matrculados"); titulo.endText(); //---------------------------------------------------------------------- //---------------------------------------------------------------------- AlunoDAO aDAO = new AlunoDAO(); List<Aluno> allAlunos = aDAO.getAllAlunos(); aDAO.closeSession(); PdfPTable table = new PdfPTable(5); table.setTotalWidth(100f); table.setWidthPercentage(100); float[] widths = { 10, 30, 30, 13, 17 };//largura das colunas table.setWidths(widths); table.setHeaderRows(1); Paragraph cabecalho = new Paragraph("Matricula"); PdfPCell cellMatricula = new PdfPCell(cabecalho); // celula cabecalho.getFont().setStyle(Font.BOLD); cabecalho.getFont().setSize(8); cellMatricula.setBackgroundColor(BaseColor.LIGHT_GRAY); cellMatricula.setBorderColor(BaseColor.LIGHT_GRAY); cellMatricula.setHorizontalAlignment(Element.ALIGN_CENTER); table.addCell(cellMatricula); cabecalho = new Paragraph("Nome"); cabecalho.getFont().setStyle(Font.BOLD); cabecalho.getFont().setSize(8); PdfPCell cellNome = new PdfPCell(cabecalho); // celula cellNome.setBackgroundColor(BaseColor.LIGHT_GRAY); cellNome.setBorderColor(BaseColor.LIGHT_GRAY); cellNome.setHorizontalAlignment(Element.ALIGN_CENTER); table.addCell(cellNome); cabecalho = new Paragraph("Email"); cabecalho.getFont().setStyle(Font.BOLD); cabecalho.getFont().setSize(8); PdfPCell cellEmail = new PdfPCell(cabecalho); // celula cellEmail.setBackgroundColor(BaseColor.LIGHT_GRAY); cellEmail.setBorderColor(BaseColor.LIGHT_GRAY); cellEmail.setHorizontalAlignment(Element.ALIGN_CENTER); table.addCell(cellEmail); cabecalho = new Paragraph("Telefone"); cabecalho.getFont().setStyle(Font.BOLD); cabecalho.getFont().setSize(8); PdfPCell cellTelefone = new PdfPCell(cabecalho); // celula cellTelefone.setBackgroundColor(BaseColor.LIGHT_GRAY); cellTelefone.setBorderColor(BaseColor.LIGHT_GRAY); cellTelefone.setHorizontalAlignment(Element.ALIGN_CENTER); table.addCell(cellTelefone); cabecalho = new Paragraph("Curso"); cabecalho.getFont().setStyle(Font.BOLD); cabecalho.getFont().setSize(8); PdfPCell cellCurso = new PdfPCell(cabecalho); // celula cellCurso.setBackgroundColor(BaseColor.LIGHT_GRAY); cellCurso.setBorderColor(BaseColor.LIGHT_GRAY); cellCurso.setHorizontalAlignment(Element.ALIGN_CENTER); table.addCell(cellCurso); for (int i = 0; i < allAlunos.size(); i++) { Aluno aluno = allAlunos.get(i); Paragraph texto = new Paragraph(aluno.getMatricula()); cellMatricula = new PdfPCell(texto); // celula cellMatricula.setBorderColor(BaseColor.LIGHT_GRAY); texto.getFont().setSize(8); table.addCell(cellMatricula); texto = new Paragraph(aluno.getNome()); texto.getFont().setSize(8); cellNome = new PdfPCell(texto); // celula cellNome.setBorderColor(BaseColor.LIGHT_GRAY); table.addCell(cellNome); texto = new Paragraph(aluno.getEmail()); texto.getFont().setSize(8); cellEmail = new PdfPCell(texto); // celula cellEmail.setBorderColor(BaseColor.LIGHT_GRAY); table.addCell(cellEmail); texto = new Paragraph(aluno.getTelefone()); texto.getFont().setSize(8); cellTelefone = new PdfPCell(texto); // celula cellTelefone.setBorderColor(BaseColor.LIGHT_GRAY); table.addCell(cellTelefone); texto = new Paragraph(aluno.getCursoidcurso().getNomecurso()); texto.getFont().setSize(8); cellCurso = new PdfPCell(texto); // celula cellCurso.setBorderColor(BaseColor.LIGHT_GRAY); table.addCell(cellCurso); } table.setSpacingBefore(100); table.setSpacingAfter(10); table.completeRow(); document.add(table); //add nova pagina document.newPage(); //close document document.close(); } catch (DocumentException | IOException ex) { Logger.getLogger(RelatorioAluno.class.getName()).log(Level.SEVERE, null, ex); } catch (Exception ex) { Logger.getLogger(RelatorioAluno.class.getName()).log(Level.SEVERE, null, ex); } //return stream return baos; }
From source file:Report.RelatorioBanca.java
/** * funcao para gerar o stream do relatorio * * @param banca/* w w w . j av a 2 s . c o m*/ * @param listaConvidados * @param coordenador * @param campus * @return ByteArrayOutputStream */ public ByteArrayOutputStream relatorioAtaDeDefesa(Banca banca, List<Convidado> listaConvidados, Professor coordenador, Campus campus) { ByteArrayOutputStream baos = new ByteArrayOutputStream(); FacesContext faces = FacesContext.getCurrentInstance(); //pega o contexto da aplicacao String realPath = faces.getExternalContext().getRealPath("/"); try { BaseFont fHelvetica = BaseFont.createFont(BaseFont.HELVETICA, "Cp1252", false); //---------------------------------------------------------------------- // creation of the document with a certain size and certain margins // may want to use PageSize.LETTER instead Document document = new Document(PageSize.A4, 40, 40, 20, 50); document.addAuthor("SisGES"); // optional document.addSubject("Relatrio"); // opcional document.addKeywords("SisGES"); document.addCreator("iText"); //---------------------------------------------------------------------- // creation of the different writers //PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("web/resources/report/alunosMatriculados.pdf")); PdfWriter writer = PdfWriter.getInstance(document, baos); writer.setBoxSize("header", new Rectangle(36, 54, 559, 788)); //---------------------------------------------------------------------- // ADICIONA HEADER E FOOTER //---------------------------------------------------------------------- HeaderFooter headerFooter = new HeaderFooter(); headerFooter.setY(760f); writer.setPageEvent(headerFooter); //---------------------------------------------------------------------- // ABRE DOCUMENTO PARA ESCRITA //---------------------------------------------------------------------- document.open(); //---------------------------------------------------------------------- //ADICIONAR LOGO NO DOCUMENTO //---------------------------------------------------------------------- Image logoUfu = Image.getInstance(realPath + "/resources/images/logoUFUAta.png"); logoUfu.scaleAbsolute(155, 39);//(largura,altura) logoUfu.isImgTemplate(); //add no template document.add(logoUfu); //---------------------------------------------------------------------- //ADICIONAR CABEALHO //---------------------------------------------------------------------- PdfContentByte univ = writer.getDirectContentUnder(); univ.beginText(); univ.setFontAndSize(fHelvetica, 10); univ.setTextMatrix(349, 816); // x e y univ.showText("UNIVERSIDADE FEDERAL DE UBERLNDIA"); univ.setTextMatrix(405, 802); // x e y univ.showText("FACULDADE DE COMPUTAO"); univ.setTextMatrix(403, 788); // x e y univ.showText("COORDENADORIA DE ESTGIO "); univ.endText(); String info = "Campus Universitrio - " + campus.getNomecampus() + " - CEP " + campus.getCep() + " - " + campus.getCidade() + " - " + campus.getEstadosigla().toUpperCase(); Chunk txtCampus = new Chunk(info); Paragraph paragraph0 = new Paragraph(); paragraph0.setSpacingBefore(-10); paragraph0.setFont(new Font(fHelvetica, 7)); paragraph0.add(txtCampus); paragraph0.setAlignment(Element.ALIGN_RIGHT); document.add(paragraph0); info = "Telefone: " + coordenador.getTelefone() + " Email: " + coordenador.getEmail(); Chunk txtCoordenador = new Chunk(info); Paragraph paragraph1 = new Paragraph(); paragraph1.setSpacingBefore(-5); paragraph1.setSpacingAfter(10); paragraph1.setFont(new Font(fHelvetica, 7)); paragraph1.add(txtCoordenador); paragraph1.setAlignment(Element.ALIGN_RIGHT); document.add(paragraph1); // PdfContentByte univ = writer.getDirectContentUnder(); // univ.beginText(); // univ.setFontAndSize(fHelvetica, 12); // univ.setTextMatrix(200, 815); // x e y // univ.showText("UNIVERSIDADE FEDERAL DE UBERLNDIA"); // univ.setTextMatrix(235, 800); // x e y // univ.showText("FACULDADE DE COMPUTAO"); // univ.endText(); // // PdfContentByte univEnd = writer.getDirectContentUnder(); // univEnd.beginText(); // univEnd.setFontAndSize(fHelvetica, 7); // univEnd.setTextMatrix(210, 785); // x e y // univEnd.showText("Campus Universitrio - Santa Mnica - CEP 38408-100 - Uberlndia - MG"); // univEnd.setTextMatrix(260, 775); // x e y // univEnd.showText("Telefone: (34) 3239-4144 ou 3239-4393"); // univEnd.endText(); //---------------------------------------------------------------------- //ADICIONAR TITULO //---------------------------------------------------------------------- PdfContentByte curso = writer.getDirectContentUnder(); curso.beginText(); curso.setFontAndSize(fHelvetica, 14); curso.setTextMatrix(140, 720); // x e y String cursoAluno; //curso.showText("Curso de Bacharelado em Cincia da Computao"); cursoAluno = banca.getTrabalhoidtrabalho().getAlunomatricula().getCursoidcurso().getNomecurso(); if (cursoAluno.contains("sistema")) { cursoAluno = "Bacharelado em Sistemas de Informao"; } else { cursoAluno = "Bacharelado em Cincia da Computao"; } curso.showText("Curso de " + cursoAluno); curso.endText(); PdfContentByte titulo = writer.getDirectContentUnder(); titulo.beginText(); titulo.setFontAndSize(fHelvetica, 12); titulo.setTextMatrix(160, 660); // x e y titulo.showText("Ata de Defesa de Trabalho de Estgio Supervisionado"); titulo.endText(); //----------------------------------------------------------------------] String texto = "Ata da ___________ de defesa de Trabalho de Estgio Supervisionado, do Curso de Bacharelado " + "em Cincia da Computao, realizada em " + CalendarFormat.getDataBRtoDate(banca.getDatabanca()) + ", na " + banca.getLocalbanca() + ", s " + CalendarFormat.parseDateToTimeString(banca.getHorario()) + " horas, pelo aluno " + banca.getTrabalhoidtrabalho().getAlunomatricula().getNome() + " (" + banca.getTrabalhoidtrabalho().getAlunomatricula().getMatricula() + "). O trabalho " + "intitulado \"" + banca.getTrabalhoidtrabalho().getTitulo() + "\" foi apresentado pelo aluno em sesso pblica " + "com cerca de 1 hora de durao. Na ocasio, o aluno foi arguido oralmente pelos membros " + "da banca, sendo considerado ________________________ (aprovado/reprovado)."; Chunk chunk1 = new Chunk(texto); Paragraph paragraph = new Paragraph(); paragraph.setFont(new Font(fHelvetica, 12)); paragraph.setSpacingBefore(170); paragraph.add(chunk1); paragraph.setAlignment(Element.ALIGN_JUSTIFIED); document.add(paragraph); document.add(Chunk.NEWLINE); texto = "Carga horria total do estgio: ____________ horas (preenchido pela coordenao de estgios)"; Paragraph paragraph2 = new Paragraph(); paragraph2.setSpacingBefore(15); paragraph2.setFont(new Font(fHelvetica, 10)); paragraph2.add(texto); paragraph2.setAlignment(Element.ALIGN_JUSTIFIED); document.add(paragraph2); document.add(Chunk.NEWLINE); Paragraph paragraph3 = new Paragraph(); paragraph3.setSpacingBefore(25); paragraph3.add("Uberlndia, " + CalendarFormat.getDataPorExtenso(banca.getDatabanca()) + "."); paragraph3.setAlignment(Element.ALIGN_JUSTIFIED); document.add(paragraph3); document.add(Chunk.NEWLINE); //---------------------------------------------------------------------- PdfContentByte tituloMembros = writer.getDirectContentUnder(); tituloMembros.beginText(); tituloMembros.setFontAndSize(fHelvetica, 12); tituloMembros.setTextMatrix(220, 350); // x e y tituloMembros.showText("Membros da Banca Examinadora"); tituloMembros.endText(); //---------------------------------------------------------------------- float x = 160f; float y = 300f; // distancia do fim da pagina //retorna orientador //----------------------------------------------------- //linha PdfContentByte linhaOrientador = writer.getDirectContentUnder(); linhaOrientador.setLineWidth(1f); // mostrar linha linhaOrientador.setGrayStroke(0.5f); // 0 = preto, 1 = branco linhaOrientador.moveTo(x, y); linhaOrientador.lineTo(450f, y); // ate onde a linha vai linhaOrientador.stroke(); //------------------------------------------------------ //nome orientador PdfContentByte orientador = writer.getDirectContentUnder(); orientador.beginText(); orientador.setFontAndSize(fHelvetica, 12); orientador.setTextMatrix(x, y - 20); // x e y orientador.showText("Prof.Orientador - " + banca.getTrabalhoidtrabalho().getProfessorsiape().getNome()); orientador.setTextMatrix(x, y - 35); // x e y orientador.showText("Presidente da banca"); orientador.endText(); y = y - 100; //retorna convidados for (int i = 0; i < listaConvidados.size(); i++) { Convidado convidado = listaConvidados.get(i); if (convidado.getConfirmado() == true) { //----------------------------------------------------- //linha PdfContentByte linha = writer.getDirectContentUnder(); linha.setLineWidth(1f); // mostrar linha linha.setGrayStroke(0.5f); // 0 = preto, 1 = branco linha.moveTo(x, y); linha.lineTo(450f, y); // ate onde a linha vai linha.stroke(); //------------------------------------------------------ //nome convidado PdfContentByte conv = writer.getDirectContentUnder(); conv.beginText(); conv.setFontAndSize(fHelvetica, 12); conv.setTextMatrix(x, y - 20); // x e y conv.showText("Prof.Convidado - " + convidado.getProfessorsiape().getNome()); conv.endText(); //------------------------------------------------------ y = y - 80; } } //add nova pagina document.newPage(); //close document document.close(); } catch (DocumentException | IOException ex) { Logger.getLogger(RelatorioBanca.class.getName()).log(Level.SEVERE, null, ex); } //return stream return baos; }
From source file:Report.RelatorioBanca.java
/** * funcao para gerar o stream do relatorio de participaes em banca * * @param prof//from w w w . j av a 2s. c o m * @param listaOrientador * @param listaConvidado * @param dtinicial * @param dtfinal * @param coordenador * @param campus * @return ByteArrayOutputStream */ public ByteArrayOutputStream relatorioParticipacaoEmBanca(Professor prof, List<Banca> listaOrientador, List<Convidado> listaConvidado, Date dtinicial, Date dtfinal, Professor coordenador, Campus campus) { ByteArrayOutputStream baos = new ByteArrayOutputStream(); FacesContext faces = FacesContext.getCurrentInstance(); //pega o contexto da aplicacao String realPath = faces.getExternalContext().getRealPath("/"); try { BaseFont fHelvetica = BaseFont.createFont(BaseFont.HELVETICA, "Cp1252", false); //---------------------------------------------------------------------- //creation of the document with a certain size and certain margins //may want to use PageSize.LETTER instead Document document = new Document(PageSize.A4, 40, 40, 20, 50); document.addAuthor("SisGES"); // optional document.addSubject("Relatrio"); // opcional document.addKeywords("SisGES"); document.addCreator("iText"); //---------------------------------------------------------------------- // creation of the different writers //PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("web/resources/report/alunosMatriculados.pdf")); PdfWriter writer = PdfWriter.getInstance(document, baos); writer.setBoxSize("header", new Rectangle(36, 54, 559, 788)); //---------------------------------------------------------------------- // ADICIONA HEADER E FOOTER //---------------------------------------------------------------------- HeaderFooter headerFooter = new HeaderFooter(); headerFooter.setY(760f); writer.setPageEvent(headerFooter); //---------------------------------------------------------------------- //ABRE DOCUMENTO PARA ESCRITA //---------------------------------------------------------------------- document.open(); //---------------------------------------------------------------------- //ADICIONAR LOGO NO DOCUMENTO //---------------------------------------------------------------------- Image logoUfu = Image.getInstance(realPath + "/resources/images/logoUFUAta.png"); logoUfu.scaleAbsolute(155, 39);//(largura,altura) logoUfu.isImgTemplate(); //add no template document.add(logoUfu); //---------------------------------------------------------------------- //ADICIONAR CABEALHO //---------------------------------------------------------------------- PdfContentByte univ = writer.getDirectContentUnder(); univ.beginText(); univ.setFontAndSize(fHelvetica, 10); univ.setTextMatrix(349, 816); // x e y univ.showText("UNIVERSIDADE FEDERAL DE UBERLNDIA"); univ.setTextMatrix(405, 802); // x e y univ.showText("FACULDADE DE COMPUTAO"); univ.setTextMatrix(403, 788); // x e y univ.showText("COORDENADORIA DE ESTGIO "); univ.endText(); String info = "Campus Universitrio - " + campus.getNomecampus() + " - CEP " + campus.getCep() + " - " + campus.getCidade() + " - " + campus.getEstadosigla().toUpperCase(); Chunk txtCampus = new Chunk(info); Paragraph paragraph0 = new Paragraph(); paragraph0.setSpacingBefore(-10); paragraph0.setFont(new Font(fHelvetica, 7)); paragraph0.add(txtCampus); paragraph0.setAlignment(Element.ALIGN_RIGHT); document.add(paragraph0); info = "Telefone: " + coordenador.getTelefone() + " Email: " + coordenador.getEmail(); Chunk txtCoordenador = new Chunk(info); Paragraph paragraph1 = new Paragraph(); paragraph1.setSpacingBefore(-5); paragraph1.setSpacingAfter(10); paragraph1.setFont(new Font(fHelvetica, 7)); paragraph1.add(txtCoordenador); paragraph1.setAlignment(Element.ALIGN_RIGHT); document.add(paragraph1); // PdfContentByte univ = writer.getDirectContentUnder(); // univ.beginText(); // univ.setFontAndSize(fHelvetica, 12); // univ.setTextMatrix(200, 815); // x e y // univ.showText("UNIVERSIDADE FEDERAL DE UBERLNDIA"); // univ.setTextMatrix(235, 800); // x e y // univ.showText("FACULDADE DE COMPUTAO"); // univ.endText(); // // PdfContentByte univEnd = writer.getDirectContentUnder(); // univEnd.beginText(); // univEnd.setFontAndSize(fHelvetica, 7); // univEnd.setTextMatrix(210, 785); // x e y // univEnd.showText("Campus Universitrio - Santa Mnica - CEP 38408-100 - Uberlndia - MG"); // univEnd.setTextMatrix(260, 775); // x e y // univEnd.showText("Telefone: (34) 3239-4144 ou 3239-4393"); // univEnd.endText(); //---------------------------------------------------------------------- //ADICIONAR TITULO //---------------------------------------------------------------------- PdfContentByte t1 = writer.getDirectContentUnder(); t1.beginText(); t1.setFontAndSize(fHelvetica, 14); t1.setTextMatrix(210, 735); // x e y t1.showText("Participao em Bancas"); t1.endText(); PdfContentByte t2 = writer.getDirectContentUnder(); t2.beginText(); t2.setFontAndSize(fHelvetica, 12); t2.setTextMatrix(190, 710); // x e y String periodo = CalendarFormat.getDataBRtoDate(dtinicial) + " at " + CalendarFormat.getDataBRtoDate(dtfinal); t2.showText("Perodo: " + periodo); t2.endText(); PdfContentByte t3 = writer.getDirectContentUnder(); t3.beginText(); t3.setFontAndSize(fHelvetica, 12); t3.setTextMatrix(40, 675); // x e y t3.showText("Professor: " + prof.getNome()); t3.endText(); //---------------------------------------------------------------------- //TABELA PdfPTable table = new PdfPTable(6); //espao do inicio da pagina table.setSpacingBefore(100f); table.setTotalWidth(110f); table.setWidthPercentage(100); float[] widths = { 13, 25, 22, 18, 12, 10 };//largura das 2 colunas table.setWidths(widths); table.setHeaderRows(1); //CABEALHO DA TABELA Paragraph cabecalho = new Paragraph("Matricula do Aluno"); PdfPCell cell1 = new PdfPCell(cabecalho); // celula cabecalho.getFont().setStyle(Font.BOLD); cabecalho.getFont().setSize(8); cell1.setBackgroundColor(BaseColor.LIGHT_GRAY); cell1.setBorderColor(BaseColor.LIGHT_GRAY); cell1.setHorizontalAlignment(Element.ALIGN_CENTER); table.addCell(cell1); cabecalho = new Paragraph("Nome do Aluno"); cabecalho.getFont().setStyle(Font.BOLD); cabecalho.getFont().setSize(8); PdfPCell cell2 = new PdfPCell(cabecalho); // celula cell2.setBackgroundColor(BaseColor.LIGHT_GRAY); cell2.setBorderColor(BaseColor.LIGHT_GRAY); cell2.setHorizontalAlignment(Element.ALIGN_CENTER); table.addCell(cell2); cabecalho = new Paragraph("Ttulo do Trabalho"); cabecalho.getFont().setStyle(Font.BOLD); cabecalho.getFont().setSize(8); PdfPCell cell3 = new PdfPCell(cabecalho); // celula cell3.setBackgroundColor(BaseColor.LIGHT_GRAY); cell3.setBorderColor(BaseColor.LIGHT_GRAY); cell3.setHorizontalAlignment(Element.ALIGN_CENTER); table.addCell(cell3); cabecalho = new Paragraph("Nome do Orientador"); cabecalho.getFont().setStyle(Font.BOLD); cabecalho.getFont().setSize(8); PdfPCell cell4 = new PdfPCell(cabecalho); // celula cell4.setBackgroundColor(BaseColor.LIGHT_GRAY); cell4.setBorderColor(BaseColor.LIGHT_GRAY); cell4.setHorizontalAlignment(Element.ALIGN_CENTER); table.addCell(cell4); cabecalho = new Paragraph("Papel do Professor"); cabecalho.getFont().setStyle(Font.BOLD); cabecalho.getFont().setSize(8); PdfPCell cell5 = new PdfPCell(cabecalho); // celula cell5.setBackgroundColor(BaseColor.LIGHT_GRAY); cell5.setBorderColor(BaseColor.LIGHT_GRAY); cell5.setHorizontalAlignment(Element.ALIGN_CENTER); table.addCell(cell5); cabecalho = new Paragraph("Data Defesa"); cabecalho.getFont().setStyle(Font.BOLD); cabecalho.getFont().setSize(8); PdfPCell cell6 = new PdfPCell(cabecalho); // celula cell6.setBackgroundColor(BaseColor.LIGHT_GRAY); cell6.setBorderColor(BaseColor.LIGHT_GRAY); cell6.setHorizontalAlignment(Element.ALIGN_CENTER); table.addCell(cell6); for (int i = 0; i < listaOrientador.size(); i++) { Banca b = listaOrientador.get(i); Paragraph texto = new Paragraph(b.getTrabalhoidtrabalho().getAlunomatricula().getMatricula()); texto.getFont().setSize(8); cell1 = new PdfPCell(texto); // celula cell1.setBorderColor(BaseColor.LIGHT_GRAY); table.addCell(cell1); texto = new Paragraph(b.getTrabalhoidtrabalho().getAlunomatricula().getNome()); texto.getFont().setSize(8); cell2 = new PdfPCell(texto); // celula cell2.setBorderColor(BaseColor.LIGHT_GRAY); table.addCell(cell2); texto = new Paragraph(b.getTrabalhoidtrabalho().getTitulo()); texto.getFont().setSize(8); cell3 = new PdfPCell(texto); // celula cell3.setBorderColor(BaseColor.LIGHT_GRAY); table.addCell(cell3); texto = new Paragraph(b.getTrabalhoidtrabalho().getProfessorsiape().getNome()); texto.getFont().setSize(8); cell4 = new PdfPCell(texto); // celula cell4.setBorderColor(BaseColor.LIGHT_GRAY); table.addCell(cell4); texto = new Paragraph("Orientador"); texto.getFont().setSize(8); cell5 = new PdfPCell(texto); // celula cell5.setBorderColor(BaseColor.LIGHT_GRAY); table.addCell(cell5); texto = new Paragraph(CalendarFormat.getDataBRtoDate(b.getDatabanca())); texto.getFont().setSize(8); cell6 = new PdfPCell(texto); // celula cell6.setBorderColor(BaseColor.LIGHT_GRAY); table.addCell(cell6); switch (i % 2) { case 0: cell1.setBorderColor(BaseColor.LIGHT_GRAY); cell1.setBackgroundColor(BaseColor.LIGHT_GRAY); break; case 1: break; } } for (int i = 0; i < listaConvidado.size(); i++) { Convidado c = listaConvidado.get(i); Paragraph texto = new Paragraph( c.getBancaidbanca().getTrabalhoidtrabalho().getAlunomatricula().getMatricula()); texto.getFont().setSize(8); cell1 = new PdfPCell(texto); // celula cell1.setBorderColor(BaseColor.LIGHT_GRAY); table.addCell(cell1); texto = new Paragraph(c.getBancaidbanca().getTrabalhoidtrabalho().getAlunomatricula().getNome()); texto.getFont().setSize(8); cell2 = new PdfPCell(texto); // celula cell2.setBorderColor(BaseColor.LIGHT_GRAY); table.addCell(cell2); texto = new Paragraph(c.getBancaidbanca().getTrabalhoidtrabalho().getTitulo()); texto.getFont().setSize(8); cell3 = new PdfPCell(texto); // celula cell3.setBorderColor(BaseColor.LIGHT_GRAY); table.addCell(cell3); texto = new Paragraph(c.getBancaidbanca().getTrabalhoidtrabalho().getProfessorsiape().getNome()); texto.getFont().setSize(8); cell4 = new PdfPCell(texto); // celula cell4.setBorderColor(BaseColor.LIGHT_GRAY); table.addCell(cell4); texto = new Paragraph("Convidado"); texto.getFont().setSize(8); cell5 = new PdfPCell(texto); // celula cell5.setBorderColor(BaseColor.LIGHT_GRAY); table.addCell(cell5); texto = new Paragraph(CalendarFormat.getDataBRtoDate(c.getBancaidbanca().getDatabanca())); texto.getFont().setSize(8); cell6 = new PdfPCell(texto); // celula cell6.setBorderColor(BaseColor.LIGHT_GRAY); table.addCell(cell6); } //add a tabela document.add(table); //----------------------------------------------------- // distancia do fim da pagina float y = 70f; float x = 160f; //----------------------------------------------------- //linha PdfContentByte linha = writer.getDirectContentUnder(); linha.setLineWidth(1f); // mostrar linha linha.setGrayStroke(0.5f); // 0 = preto, 1 = branco linha.moveTo(x, y); linha.lineTo(450f, y); // ate onde a linha vai linha.stroke(); //------------------------------------------------------ //assinatura PdfContentByte a1 = writer.getDirectContentUnder(); a1.beginText(); a1.setFontAndSize(fHelvetica, 10); a1.setTextMatrix(x + 50, y - 15); // x e y a1.showText("Coordenao de Estgio Supervisionado"); a1.endText(); //------------------------------------------------------ //assinatura PdfContentByte a2 = writer.getDirectContentUnder(); a2.beginText(); a2.setFontAndSize(fHelvetica, 10); a2.setTextMatrix(x + 50, y - 27); // x e y a2.showText("FACOM/UFU"); a2.endText(); //---------------------------------------------------------------------- /*String texto = "Ata da defesa de Trabalho de Estgio Supervisionado, do Curso de Bacharelado" + "em Cincia da Computao, realizada em " + CalendarFormat.getDataBRtoDate(banca.getDatabanca()) + ", na " + banca.getLocalbanca() + ", s " + CalendarFormat.parseDateToTimeString(banca.getHorario()) + " horas, pelo aluno " + banca.getTrabalhoidtrabalho().getAlunomatricula().getNome() + " (" + banca.getTrabalhoidtrabalho().getAlunomatricula().getMatricula() + "). O trabalho " + "intitulado \"" + banca.getTrabalhoidtrabalho().getTitulo() + "\" foi apresentado pelo aluno em sesso pblica " + "com cerca de 1 hora de durao. Na ocasio, o aluno foi arguido oralmente pelos membros " + "da banca, sendo considerado ________________________ (aprovado/reprovado)."; */ //Chunk chunk1 = new Chunk(texto); //Paragraph paragraph = new Paragraph(); // paragraph.setSpacingBefore(180); //paragraph.add(chunk1); //paragraph.setAlignment(Element.ALIGN_JUSTIFIED); //document.add(paragraph); //document.add(Chunk.NEWLINE); //Paragraph paragraph2 = new Paragraph(); //paragraph2.setSpacingBefore(25); //paragraph2.add("Uberlndia, " + CalendarFormat.getDataPorExtenso(banca.getDatabanca()) + "."); //paragraph2.setAlignment(Element.ALIGN_JUSTIFIED); ///document.add(paragraph2); //document.add(Chunk.NEWLINE); //---------------------------------------------------------------------- //---------------------------------------------------------------------- //float x = 160f; //float y = 340f; // distancia do fim da pagina //retorna orientador //----------------------------------------------------- //linha //PdfContentByte linhaOrientador = writer.getDirectContentUnder(); //linhaOrientador.setLineWidth(1f); // mostrar linha //linhaOrientador.setGrayStroke(0.5f); // 0 = preto, 1 = branco //linhaOrientador.moveTo(x, y); //linhaOrientador.lineTo(450f, y); // ate onde a linha vai //linhaOrientador.stroke(); //------------------------------------------------------ //nome orientador //PdfContentByte orientador = writer.getDirectContentUnder(); //orientador.beginText(); //orientador.setFontAndSize(fHelvetica, 12); //orientador.setTextMatrix(x, y - 20); // x e y //orientador.showText("Prof.Orientador - " + banca.getTrabalhoidtrabalho().getProfessorsiape().getNome()); //orientador.setTextMatrix(x, y - 35); // x e y //orientador.showText("Presidente da banca"); //orientador.endText(); /* y = y - 100; //retorna convidados for (int i = 0; i < listaConvidados.size(); i++) { Convidado convidado = listaConvidados.get(i); if (convidado.getConfirmado() == true) { //----------------------------------------------------- //linha PdfContentByte linha = writer.getDirectContentUnder(); linha.setLineWidth(1f); // mostrar linha linha.setGrayStroke(0.5f); // 0 = preto, 1 = branco linha.moveTo(x, y); linha.lineTo(450f, y); // ate onde a linha vai linha.stroke(); //------------------------------------------------------ //nome convidado PdfContentByte conv = writer.getDirectContentUnder(); conv.beginText(); conv.setFontAndSize(fHelvetica, 12); conv.setTextMatrix(x, y - 20); // x e y conv.showText("Prof.Convidado - " + convidado.getProfessorsiape().getNome()); conv.endText(); //------------------------------------------------------ y = y - 80; } } */ //---------------------------------------------------------------------- //AlunoDAO aDAO = new AlunoDAO(); //List<Aluno> allAlunos = aDAO.getAllAlunos(); //aDAO.closeSession(); // PdfPTable table = new PdfPTable(5); // table.setSpacingBefore(35f); // table.setTotalWidth(100f); // table.setWidthPercentage(100); // float[] widths = {10, 30, 30, 13, 17};//largura das 2 colunas // table.setWidths(widths); // table.setHeaderRows(1); // // Paragraph cabecalho = new Paragraph("Matricula"); // PdfPCell cellMatricula = new PdfPCell(cabecalho); // celula // cabecalho.getFont().setStyle(Font.BOLD); // cabecalho.getFont().setSize(8); // cellMatricula.setBackgroundColor(BaseColor.LIGHT_GRAY); // cellMatricula.setBorderColor(BaseColor.LIGHT_GRAY); // cellMatricula.setHorizontalAlignment(Element.ALIGN_CENTER); // table.addCell(cellMatricula); // // cabecalho = new Paragraph("Nome"); // cabecalho.getFont().setStyle(Font.BOLD); // cabecalho.getFont().setSize(8); // PdfPCell cellNome = new PdfPCell(cabecalho); // celula // cellNome.setBackgroundColor(BaseColor.LIGHT_GRAY); // cellNome.setBorderColor(BaseColor.LIGHT_GRAY); // cellNome.setHorizontalAlignment(Element.ALIGN_CENTER); // table.addCell(cellNome); // // cabecalho = new Paragraph("Email"); // cabecalho.getFont().setStyle(Font.BOLD); // cabecalho.getFont().setSize(8); // PdfPCell cellEmail = new PdfPCell(cabecalho); // celula // cellEmail.setBackgroundColor(BaseColor.LIGHT_GRAY); // cellEmail.setBorderColor(BaseColor.LIGHT_GRAY); // cellEmail.setHorizontalAlignment(Element.ALIGN_CENTER); // table.addCell(cellEmail); // // cabecalho = new Paragraph("Telefone"); // cabecalho.getFont().setStyle(Font.BOLD); // cabecalho.getFont().setSize(8); // PdfPCell cellTelefone = new PdfPCell(cabecalho); // celula // cellTelefone.setBackgroundColor(BaseColor.LIGHT_GRAY); // cellTelefone.setBorderColor(BaseColor.LIGHT_GRAY); // cellTelefone.setHorizontalAlignment(Element.ALIGN_CENTER); // table.addCell(cellTelefone); // // cabecalho = new Paragraph("Curso"); // cabecalho.getFont().setStyle(Font.BOLD); // cabecalho.getFont().setSize(8); // PdfPCell cellCurso = new PdfPCell(cabecalho); // celula // cellCurso.setBackgroundColor(BaseColor.LIGHT_GRAY); // cellCurso.setBorderColor(BaseColor.LIGHT_GRAY); // cellCurso.setHorizontalAlignment(Element.ALIGN_CENTER); // table.addCell(cellCurso); // for (int i = 0; i < allAlunos.size(); i++) { // Aluno aluno = allAlunos.get(i); // Paragraph texto = new Paragraph(aluno.getMatricula()); // cellMatricula = new PdfPCell(texto); // celula // cellMatricula.setBorderColor(BaseColor.LIGHT_GRAY); // texto.getFont().setSize(8); // table.addCell(cellMatricula); // texto = new Paragraph(aluno.getNome()); // texto.getFont().setSize(8); // cellNome = new PdfPCell(texto); // celula // cellNome.setBorderColor(BaseColor.LIGHT_GRAY); // table.addCell(cellNome); // texto = new Paragraph(aluno.getEmail()); // texto.getFont().setSize(8); // cellEmail = new PdfPCell(texto); // celula // cellEmail.setBorderColor(BaseColor.LIGHT_GRAY); // table.addCell(cellEmail); // texto = new Paragraph(aluno.getTelefone()); // texto.getFont().setSize(8); // cellTelefone = new PdfPCell(texto); // celula // cellTelefone.setBorderColor(BaseColor.LIGHT_GRAY); // table.addCell(cellTelefone); // texto = new Paragraph(aluno.getCursoidcurso().getNomecurso()); // texto.getFont().setSize(8); // cellCurso = new PdfPCell(texto); // celula // cellCurso.setBorderColor(BaseColor.LIGHT_GRAY); // table.addCell(cellCurso); // // switch (i % 2) { // case 0: // cellMatricula.setBorderColor(BaseColor.LIGHT_GRAY); // cellMatricula.setBackgroundColor(BaseColor.LIGHT_GRAY); // break; // case 1: // // break; // } // // } //add nova pagina document.newPage(); //close document document.close(); } catch (DocumentException | IOException ex) { Logger.getLogger(RelatorioBanca.class.getName()).log(Level.SEVERE, null, ex); } //return stream com dados return baos; }