List of usage examples for com.itextpdf.text.pdf PdfContentByte setFontAndSize
public void setFontAndSize(final BaseFont bf, final float size)
From source file:pdf.PdfCreator.java
public String createPdf(String path, String ingredients, String recipeTitle, String recipeDescription) throws DocumentException, IOException { path += "shoppingList.pdf"; Document document = new Document(); PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(path)); document.open();/* w w w. j a v a 2 s . c om*/ String[] ings = ingredients.split(";"); PdfContentByte cb = writer.getDirectContent(); BaseFont bf = BaseFont.createFont(); cb.beginText(); Paragraph p = new Paragraph("Ingredients you'll need to buy:", new Font(FontFamily.HELVETICA, 20, Font.BOLD, new BaseColor(38, 165, 154))); p.add(Chunk.NEWLINE); document.add(p); cb.moveText(36, 750); cb.setFontAndSize(bf, 15); cb.endText(); p = new Paragraph(); for (String str : ings) { p.add(" "); p.add(str); p.add(Chunk.NEWLINE); } p.add(Chunk.NEWLINE); p.add(Chunk.NEWLINE); document.add(p); p = new Paragraph(recipeTitle, new Font(FontFamily.HELVETICA, 20, Font.BOLD, new BaseColor(38, 165, 154))); p.add(Chunk.NEWLINE); document.add(p); p = new Paragraph(recipeDescription, new Font(bf, 12)); p.add(Chunk.NEWLINE); document.add(p); document.close(); return path; }
From source file:pl.marcinmilkowski.hocrtopdf.Main.java
License:Open Source License
/** * @param args/*from ww w .j ava 2 s. co m*/ */ public static void main(String[] args) { try { if (args.length < 1 || args[0] == "--help" || args[0] == "-h") { System.out.print("Usage: java pl.marcinmilkowski.hocrtopdf.Main INPUTURL.html OUTPUTURL.pdf\n" + "\n" + "Converts hOCR files into PDF\n" + "\n" + "Example: java pl.marcinmilkowski.hocrtopdf.Main hocr.html output.pdf\n"); if (args.length < 1) System.exit(-1); else System.exit(0); } URL inputHOCRFile = null; FileOutputStream outputPDFStream = null; try { File file = new File(args[0]); inputHOCRFile = file.toURI().toURL(); } catch (MalformedURLException e) { System.out.println("The first parameter has to be a valid file."); System.out.println("We got an error: " + e.getMessage()); System.exit(-1); } try { outputPDFStream = new FileOutputStream(args[1]); } catch (FileNotFoundException e) { System.out.println("The second parameter has to be a valid URL"); System.exit(-1); } // The resolution of a PDF file (using iText) is 72pt per inch float pointsPerInch = 72.0f; // Using the jericho library to parse the HTML file Source source = new Source(inputHOCRFile); int pageCounter = 1; Document pdfDocument = null; PdfWriter pdfWriter = null; PdfContentByte cb = null; RandomAccessFileOrArray ra = null; // Find the tag of class ocr_page in order to load the scanned image StartTag pageTag = source.getNextStartTag(0, "class", OCRPAGE); while (pageTag != null) { int prevPos = pageTag.getEnd(); Pattern imagePattern = Pattern.compile("image\\s+([^;]+)"); Matcher imageMatcher = imagePattern.matcher(pageTag.getElement().getAttributeValue("title")); if (!imageMatcher.find()) { System.out.println("Could not find a tag of class \"ocr_page\", aborting."); System.exit(-1); } // Load the image Image pageImage = null; try { File file = new File(imageMatcher.group(1)); pageImage = Image.getInstance(file.toURI().toURL()); } catch (MalformedURLException e) { System.out.println("Could not load the scanned image from: " + "file://" + imageMatcher.group(1) + ", aborting."); System.exit(-1); } if (pageImage.getOriginalType() == Image.ORIGINAL_TIFF) { // this might // be // multipage // tiff! File file = new File(imageMatcher.group(1)); if (pageCounter == 1 || ra == null) { ra = new RandomAccessFileOrArray(file.toURI().toURL()); } int nPages = TiffImage.getNumberOfPages(ra); if (nPages > 0 && pageCounter <= nPages) { pageImage = TiffImage.getTiffImage(ra, pageCounter); } } int dpiX = pageImage.getDpiX(); if (dpiX == 0) { // for images that don't set the resolution we assume // 300 dpi dpiX = 300; } int dpiY = pageImage.getDpiY(); if (dpiY == 0) { // as above for dpiX dpiY = 300; } float dotsPerPointX = dpiX / pointsPerInch; float dotsPerPointY = dpiY / pointsPerInch; float pageImagePixelHeight = pageImage.getHeight(); if (pdfDocument == null) { pdfDocument = new Document(new Rectangle(pageImage.getWidth() / dotsPerPointX, pageImage.getHeight() / dotsPerPointY)); pdfWriter = PdfWriter.getInstance(pdfDocument, outputPDFStream); pdfDocument.open(); // Put the text behind the picture (reverse for debugging) // cb = pdfWriter.getDirectContentUnder(); cb = pdfWriter.getDirectContent(); } else { pdfDocument.setPageSize(new Rectangle(pageImage.getWidth() / dotsPerPointX, pageImage.getHeight() / dotsPerPointY)); pdfDocument.newPage(); } // first define a standard font for our text BaseFont base = BaseFont.createFont(BaseFont.HELVETICA, BaseFont.CP1250, BaseFont.EMBEDDED); Font defaultFont = new Font(base, 8); // FontFactory.getFont(FontFactory.HELVETICA, 8, Font.BOLD, // CMYKColor.BLACK); cb.setHorizontalScaling(1.0f); pageImage.scaleToFit(pageImage.getWidth() / dotsPerPointX, pageImage.getHeight() / dotsPerPointY); pageImage.setAbsolutePosition(0, 0); // Put the image in front of the text (reverse for debugging) // pdfWriter.getDirectContent().addImage(pageImage); pdfWriter.getDirectContentUnder().addImage(pageImage); // In order to place text behind the recognised text snippets we are // interested in the bbox property Pattern bboxPattern = Pattern.compile("bbox(\\s+\\d+){4}"); // This pattern separates the coordinates of the bbox property Pattern bboxCoordinatePattern = Pattern.compile("(\\d+)\\s+(\\d+)\\s+(\\d+)\\s+(\\d+)"); // Only tags of the ocr_line class are interesting StartTag ocrTag = source.getNextStartTag(prevPos, "class", OCRPAGEORLINE); while (ocrTag != null) { prevPos = ocrTag.getEnd(); if ("ocrx_word".equalsIgnoreCase(ocrTag.getAttributeValue("class"))) { net.htmlparser.jericho.Element lineElement = ocrTag.getElement(); Matcher bboxMatcher = bboxPattern.matcher(lineElement.getAttributeValue("title")); if (bboxMatcher.find()) { // We found a tag of the ocr_line class containing a bbox property Matcher bboxCoordinateMatcher = bboxCoordinatePattern.matcher(bboxMatcher.group()); bboxCoordinateMatcher.find(); int[] coordinates = { Integer.parseInt((bboxCoordinateMatcher.group(1))), Integer.parseInt((bboxCoordinateMatcher.group(2))), Integer.parseInt((bboxCoordinateMatcher.group(3))), Integer.parseInt((bboxCoordinateMatcher.group(4))) }; String line = lineElement.getContent().getTextExtractor().toString(); float bboxWidthPt = (coordinates[2] - coordinates[0]) / dotsPerPointX; float bboxHeightPt = (coordinates[3] - coordinates[1]) / dotsPerPointY; // Put the text into the PDF cb.beginText(); // Comment the next line to debug the PDF output (visible Text) cb.setTextRenderingMode(PdfContentByte.TEXT_RENDER_MODE_INVISIBLE); // height cb.setFontAndSize(defaultFont.getBaseFont(), Math.max(Math.round(bboxHeightPt), 1)); // width cb.setHorizontalScaling(bboxWidthPt / cb.getEffectiveStringWidth(line, false)); cb.moveText((coordinates[0] / dotsPerPointX), ((pageImagePixelHeight - coordinates[3]) / dotsPerPointY)); cb.showText(line); cb.endText(); cb.setHorizontalScaling(1.0f); } } else { if ("ocr_page".equalsIgnoreCase(ocrTag.getAttributeValue("class"))) { pageCounter++; pageTag = ocrTag; break; } } ocrTag = source.getNextStartTag(prevPos, "class", OCRPAGEORLINE); } if (ocrTag == null) { pdfDocument.close(); break; } } } catch (DocumentException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } }
From source file:printInv.GenerateInvoice.java
private void createPDF(String pdfFilename) { Document doc = new Document(); PdfWriter docWriter = null;//from w w w . ja v a 2s . co m initializeFonts(); try { // String path = "docs/" + pdfFilename; String path = pdfFilename; docWriter = PdfWriter.getInstance(doc, new FileOutputStream(path)); doc.addAuthor("SmartWMS"); doc.addCreationDate(); doc.addProducer(); doc.addCreator("SmartWMS"); doc.addTitle("Invoice"); doc.setPageSize(PageSize.LETTER); doc.open(); PdfContentByte cb = docWriter.getDirectContent(); boolean beginPage = true; int y = 0; System.out.println("n ===========" + n); for (int i = 0; i < n; i++) { if (beginPage) { beginPage = false; generateLayout(doc, cb); generateHeader(doc, cb); y = 615; } generateDetail(doc, cb, i, y); y = y - 15; if (y < 50) { printPageNumber(cb); doc.newPage(); beginPage = true; } } printPageNumber(cb); cb.beginText(); cb.setFontAndSize(bfBold, 10); cb.showTextAligned(PdfContentByte.ALIGN_RIGHT, "Grand Total : " + total, 570, 35, 0); cb.endText(); } catch (DocumentException dex) { dex.printStackTrace(); } catch (Exception ex) { ex.printStackTrace(); } finally { if (doc != null) { doc.close(); } if (docWriter != null) { docWriter.close(); } } }
From source file:printInv.GenerateInvoice.java
private void createHeadings(PdfContentByte cb, float x, float y, String text) { cb.beginText();/*from w w w. j av a 2 s . co m*/ cb.setFontAndSize(bfBold, 8); cb.setTextMatrix(x, y); // System.out.println(text+"*****************"); cb.showText(text.trim()); // System.out.println("***************************"); cb.endText(); }
From source file:printInv.GenerateInvoice.java
public void printPageNumber(PdfContentByte cb) { cb.beginText();//from w w w . ja v a 2 s . com cb.setFontAndSize(bfBold, 8); cb.showTextAligned(PdfContentByte.ALIGN_RIGHT, "Page No. " + (pageNumber + 1), 570, 20, 0); cb.endText(); pageNumber++; }
From source file:pw.core.pdf.PWPdfFile.java
License:Open Source License
public void addField(PWPdfField field) { PdfContentByte contentByte = writer.getDirectContent(); contentByte.beginText();/* w ww . ja va2s.c o m*/ BaseFont baseFont = getFont(field.font, field.encoding, field.isEmbedded); contentByte.setFontAndSize(baseFont, field.fontSize); contentByte.setTextMatrix(field.x, field.y); contentByte.showText(field.text); contentByte.endText(); }
From source file:Report.ItextReport.java
public static void absText(PdfWriter writer, String text, int x, int y) { try {// w w w .ja v a 2 s .c o m PdfContentByte cb = writer.getDirectContent(); BaseFont bf = BaseFont.createFont(BaseFont.HELVETICA, BaseFont.CP1252, BaseFont.NOT_EMBEDDED); cb.saveState(); cb.beginText(); cb.moveText(x, y); cb.setFontAndSize(bf, 12); cb.showText(text); cb.endText(); cb.restoreState(); } catch (DocumentException | IOException e) { e.getMessage(); } }
From source file:Report.RelatorioAluno.java
/** * funcao para gerar o stream do relatorio * * @return ByteArrayOutputStream/*from ww w.j a v a 2 s . com*/ */ 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/* ww w . j a v a 2 s. co 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/*ww w .ja v a2 s .c om*/ * @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; }