List of usage examples for com.itextpdf.text.pdf PdfPTable setSpacingAfter
public void setSpacingAfter(final float spacing)
From source file:Output.QuotePDf.java
private PdfPTable packingListTable(JTable packingListTable) throws DocumentException { PdfPTable table = new PdfPTable(11); table.setHorizontalAlignment(Element.ALIGN_LEFT); table.setWidthPercentage(100f);/*from www.j av a2s . c o m*/ table.setWidths(new int[] { 5, 2, 2, 2, 2, 3, 2, 2, 2, 3, 3 }); table.setSpacingAfter(10f); cell = new PdfPCell(new Phrase("Packing List", tableHeadingFont)); cell.setBackgroundColor(BaseColor.BLACK); cell.setColspan(11); cell.setPaddingBottom(5); cell.setHorizontalAlignment(Element.ALIGN_CENTER); table.addCell(cell); cell = new PdfPCell(new Phrase("Commodity", plLabelFont)); cell.setBackgroundColor(BaseColor.LIGHT_GRAY); cell.setPaddingBottom(5); table.addCell(cell); cell = new PdfPCell(new Phrase("Qty", plLabelFont)); cell.setBackgroundColor(BaseColor.LIGHT_GRAY); cell.setPaddingBottom(5); table.addCell(cell); cell = new PdfPCell(new Phrase("L(cm)", plLabelFont)); cell.setBackgroundColor(BaseColor.LIGHT_GRAY); cell.setPaddingBottom(5); table.addCell(cell); cell = new PdfPCell(new Phrase("W(cm)", plLabelFont)); cell.setBackgroundColor(BaseColor.LIGHT_GRAY); cell.setPaddingBottom(5); table.addCell(cell); cell = new PdfPCell(new Phrase("H(cm)", plLabelFont)); cell.setBackgroundColor(BaseColor.LIGHT_GRAY); cell.setPaddingBottom(5); table.addCell(cell); cell = new PdfPCell(new Phrase("Kgs", plLabelFont)); cell.setBackgroundColor(BaseColor.LIGHT_GRAY); cell.setPaddingBottom(5); table.addCell(cell); cell = new PdfPCell(new Phrase("L(in)", plLabelFont)); cell.setBackgroundColor(BaseColor.LIGHT_GRAY); cell.setPaddingBottom(5); table.addCell(cell); cell = new PdfPCell(new Phrase("W(in)", plLabelFont)); cell.setBackgroundColor(BaseColor.LIGHT_GRAY); cell.setPaddingBottom(5); table.addCell(cell); cell = new PdfPCell(new Phrase("H(in)", plLabelFont)); cell.setBackgroundColor(BaseColor.LIGHT_GRAY); cell.setPaddingBottom(5); table.addCell(cell); cell = new PdfPCell(new Phrase("M3", plLabelFont)); cell.setBackgroundColor(BaseColor.LIGHT_GRAY); cell.setPaddingBottom(5); table.addCell(cell); cell = new PdfPCell(new Phrase("Lbs", plLabelFont)); cell.setBackgroundColor(BaseColor.LIGHT_GRAY); cell.setPaddingBottom(5); table.addCell(cell); for (int row = 0; row < packingListTable.getRowCount(); row++) { for (int col = 0; col < 11; col++) { String packingListData = String.valueOf(packingListTable.getValueAt(row, col)); if (packingListData.equals("null")) { packingListData = " "; cell = new PdfPCell(new Phrase(packingListData, textFont)); table.getDefaultCell().setHorizontalAlignment(Element.ALIGN_LEFT); table.addCell(cell); } else { cell = new PdfPCell(new Phrase(packingListData, textFont)); table.getDefaultCell().setHorizontalAlignment(Element.ALIGN_LEFT); table.addCell(cell); } } } return table; }
From source file:pdf.PdfUtility.java
private Paragraph addTableEntry(Achievement a) { PdfPTable mainTable = new PdfPTable(new float[] { 1f, 5f }); mainTable.setWidthPercentage(100f);/* www . j a va2 s. c om*/ mainTable.setSpacingBefore(0f); mainTable.setSpacingAfter(0f); PdfPCell datesCell = getDateCell(a); PdfPCell summaryCell = getSummaryCell(a); mainTable.addCell(datesCell); mainTable.addCell(summaryCell); Paragraph current = new Paragraph(); current.setAlignment(Paragraph.ALIGN_LEFT); //current.setSpacingBefore(10f); current.add(mainTable); return current; }
From source file:pdfreporter.PDFGenTable.java
public static void pdfgentable() { Document document = new Document(); try {//from w ww .j ava2 s. co m PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("AddTableExample.pdf")); document.open(); PdfPTable table = new PdfPTable(4); // 3 columns. table.setWidthPercentage(100); //Width 100% table.setSpacingBefore(10f); //Space before table table.setSpacingAfter(10f); //Space after table //Set Column widths float[] columnWidths = { 1f, 1f, 1f, 1f }; table.setWidths(columnWidths); PdfPCell cell1 = new PdfPCell(new Paragraph("Nemam Pojma")); cell1.setBorderColor(BaseColor.BLACK); cell1.setPaddingLeft(10); cell1.setHorizontalAlignment(Element.ALIGN_CENTER); cell1.setVerticalAlignment(Element.ALIGN_MIDDLE); PdfPCell cell2 = new PdfPCell(new Paragraph("Nemam pojma 2")); cell2.setBorderColor(BaseColor.BLACK); cell2.setPaddingLeft(10); cell2.setHorizontalAlignment(Element.ALIGN_CENTER); cell2.setVerticalAlignment(Element.ALIGN_MIDDLE); PdfPCell cell3 = new PdfPCell(new Paragraph("Nemam pojma 3")); cell3.setBorderColor(BaseColor.BLACK); cell3.setPaddingLeft(10); cell3.setHorizontalAlignment(Element.ALIGN_CENTER); cell3.setVerticalAlignment(Element.ALIGN_MIDDLE); PdfPCell cell4 = new PdfPCell(new Paragraph("Nemam pojma 4")); cell4.setBorderColor(BaseColor.BLACK); cell4.setPaddingLeft(10); cell4.setHorizontalAlignment(Element.ALIGN_CENTER); cell4.setVerticalAlignment(Element.ALIGN_MIDDLE); //To avoid having the cell border and the content overlap, if you are having thick cell borders //cell1.setUserBorderPadding(true); //cell2.setUserBorderPadding(true); //cell3.setUserBorderPadding(true); table.addCell(cell1); table.addCell(cell2); table.addCell(cell3); table.addCell(cell4); document.add(table); document.close(); writer.close(); } catch (FileNotFoundException | DocumentException e) { } }
From source file:pidevhany.Controllers.GeneratePDF.java
public GeneratePDF(String ReponsesCorretes, String ReponsesFausses) throws FileNotFoundException, IOException { Document document = new Document(); OutputStream outputStream = new FileOutputStream( new File("D:\\Esprit\\Atelier Java\\piweb\\pidevHany\\src\\pidevhany\\TestFile.pdf")); try {//from w w w . j a v a 2 s . c o m PdfWriter writer = PdfWriter.getInstance(document, outputStream); document.open(); document.add(new Paragraph("Resultat du test :")); PdfPTable table = new PdfPTable(2); // 3 columns. table.setWidthPercentage(100); //Width 100% table.setSpacingBefore(10f); //Space before table table.setSpacingAfter(10f); //Space after table //Set Column widths float[] columnWidths = { 1f, 1f }; table.setWidths(columnWidths); PdfPCell cell1 = new PdfPCell(new Paragraph(ReponsesCorretes)); cell1.setBorderColor(BaseColor.BLUE); cell1.setPaddingLeft(10); cell1.setHorizontalAlignment(Element.ALIGN_CENTER); cell1.setVerticalAlignment(Element.ALIGN_MIDDLE); PdfPCell cell2 = new PdfPCell(new Paragraph(ReponsesFausses)); cell2.setBorderColor(BaseColor.GREEN); cell2.setPaddingLeft(10); cell2.setHorizontalAlignment(Element.ALIGN_CENTER); cell2.setVerticalAlignment(Element.ALIGN_MIDDLE); table.addCell(cell1); table.addCell(cell2); document.add(table); document.close(); outputStream.close(); writer.close(); } catch (DocumentException e) { e.printStackTrace(); } }
From source file:platnosci.WyszukPlatnosciController.java
public void akcjaDrukuj() { Drukowanie drukPanel = new Drukowanie(null, true); drukPanel.setLocationRelativeTo(null); drukPanel.setVisible(true);/*from w ww .ja v a2 s . c om*/ if (!drukPanel.isDruk()) { return; } FileOutputStream file = null; File druk = null; try { Document document = new Document(); String userPath = System.getProperty("user.home"); druk = new File(userPath + "/Baks wydruki"); if (!druk.exists()) { druk.mkdirs(); } SimpleDateFormat sdf = new SimpleDateFormat("dd-MM-yyyy"); String strdate = ""; Date calendardate = new Date(); strdate = sdf.format(calendardate.getTime()); File wydruk = new File(druk + "/Platnosci - " + strdate + ".pdf"); if (!wydruk.exists()) { try { wydruk.createNewFile(); } catch (IOException ex) { Logger.getLogger(WyszukPlatnosciController.class.getName()).log(Level.SEVERE, null, ex); } } file = new FileOutputStream(wydruk); try { PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(wydruk)); document.open(); PdfPTable table = new PdfPTable(4); // 3 columns. table.setWidthPercentage(100); //Width 100% table.setSpacingBefore(10f); //Space before table table.setSpacingAfter(10f); //Space after table //Set Column widths float[] columnWidths = { 1f, 1f, 1f, 1f }; table.setWidths(columnWidths); BaseFont bf = BaseFont.createFont("c:/windows/fonts/arial.ttf", BaseFont.IDENTITY_H, BaseFont.EMBEDDED); PdfPCell cell1 = new PdfPCell(new Paragraph("Lp", new com.itextpdf.text.Font(bf, 16))); cell1.setPaddingLeft(10); cell1.setHorizontalAlignment(Element.ALIGN_CENTER); cell1.setVerticalAlignment(Element.ALIGN_LEFT); PdfPCell cell2 = new PdfPCell(new Paragraph("Firma", new com.itextpdf.text.Font(bf, 16))); cell2.setPaddingLeft(10); cell2.setHorizontalAlignment(Element.ALIGN_CENTER); cell2.setVerticalAlignment(Element.ALIGN_LEFT); PdfPCell cell3 = new PdfPCell( new Paragraph("Data patnoci", new com.itextpdf.text.Font(bf, 16))); cell3.setPaddingLeft(10); cell3.setHorizontalAlignment(Element.ALIGN_CENTER); cell3.setVerticalAlignment(Element.ALIGN_LEFT); PdfPCell cell4 = new PdfPCell(new Paragraph("Kwota", new com.itextpdf.text.Font(bf, 16))); cell4.setPaddingLeft(10); cell4.setHorizontalAlignment(Element.ALIGN_CENTER); cell4.setVerticalAlignment(Element.ALIGN_LEFT); //To avoid having the cell border and the content overlap, if you are having thick cell borders cell1.setBorder(PdfPCell.NO_BORDER); cell2.setBorder(PdfPCell.NO_BORDER); cell3.setBorder(PdfPCell.NO_BORDER); cell4.setBorder(PdfPCell.NO_BORDER); table.addCell(cell1); table.addCell(cell2); table.addCell(cell3); table.addCell(cell4); TO_Invoice kryt = new TO_Invoice(); kryt.setDataDo(drukPanel.getDateDo()); kryt.setDataOd(drukPanel.getDateOd()); kryt.setStatus(TO_InvoiceStatus.ZAPLACONA); List<TO_Invoice> listaFaktur = getDaoFactory().getDaoInvoice().getListaInvoiceDruk(getConnection(), kryt); Integer i = 1; for (TO_Invoice item : listaFaktur) { table.addCell(getNewCell(i.toString() + ".")); table.addCell(getNewCell(item.getPaymentCompany().getName())); table.addCell(getNewCell(item.getDataZaplacenia().toString())); table.addCell(getNewCell(TO_Invoice.getWynikSumaKoszt(item.getKoszt()) + " z")); i++; } document.add(table); document.close(); writer.close(); } catch (Exception e) { e.printStackTrace(); } } catch (FileNotFoundException ex) { Logger.getLogger(WyszukPlatnosciController.class.getName()).log(Level.SEVERE, null, ex); BaksSessionBean.getInstance().fireMessage(widok, "Wydruk", "Pdf do ktrego chcesz zapisa wynik jest otwarty!\n Zamknij i sprbuj jeszcze raz."); } finally { try { file.close(); } catch (IOException ex) { Logger.getLogger(WyszukPlatnosciController.class.getName()).log(Level.SEVERE, null, ex); } } Desktop desktop = null; if (Desktop.isDesktopSupported()) { desktop = Desktop.getDesktop(); try { desktop.open(druk); } catch (IOException ex) { Logger.getLogger(WyszukPlatnosciController.class.getName()).log(Level.SEVERE, null, ex); } } BaksSessionBean.getInstance().fireMessage(widok, "Zapis", "Wydruk zapisany w folderze: " + System.getProperty("user.home") + "/Baks wydruki"); }
From source file:printers.HojaDeFirmaPrinter.java
License:Open Source License
private void creaCuerpo(Document doc, GregorianCalendar dia, ArrayList<HorarioItem> data) { Collections.sort(data, new ComparatorHorarioItems()); PdfPTable t = new PdfPTable(3); t.setSpacingBefore(15f);// w ww . java2 s . c o m t.setSpacingAfter(10f); t.setWidthPercentage(100); Font fontbold = new Font(Font.FontFamily.HELVETICA, 14, Font.BOLD); PdfPCell c = new PdfPCell(new Paragraph("Asignatura", fontbold)); c.setHorizontalAlignment(PdfPCell.ALIGN_CENTER); c.setPadding(5); t.addCell(c); c = new PdfPCell(new Paragraph("Firma", fontbold)); c.setPadding(5); c.setHorizontalAlignment(PdfPCell.ALIGN_CENTER); c.setPadding(5); t.addCell(c); c = new PdfPCell(new Paragraph("Incidencias", fontbold)); c.setPadding(5); c.setHorizontalAlignment(PdfPCell.ALIGN_CENTER); t.addCell(c); for (HorarioItem h : data) { creaFilaFirma(t, h); } try { doc.add(t); } catch (DocumentException ex) { Logger.getLogger(HojaDeFirmaPrinter.class.getName()).log(Level.SEVERE, null, ex); } }
From source file:Report.RelatorioAluno.java
/** * funcao para gerar o stream do relatorio * * @return ByteArrayOutputStream/*from w w w .j ava 2s . c o m*/ */ 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.RelatorioCurso.java
/** * Funo para gerar o stream do relatrio anual de atividades * * @param proforiseparada//from w w w. j a v a2s .c om * @param sm * @param sa * @param am * @param aa * @param dtinicial * @param dtfinal * @param ano * @param cursoNome * @param coordenador * @param campus * @return ByteArrayOutputStream */ public ByteArrayOutputStream relatorioAnualDeAtividades(ArrayList<Professororientacaoseparada> proforiseparada, ArrayList<Sumariomatricula> sm, ArrayList<Sumarioaprovado> sa, ArrayList<Alunomatriculado> am, ArrayList<Alunoaprovado> aa, Date dtinicial, Date dtfinal, String ano, String cursoNome, Professor coordenador, Campus campus) { 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); BaseFont fHelveticaBOLD = BaseFont.createFont(BaseFont.HELVETICA_BOLD, "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(); 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); //---------------------------------------------------------------------- //ADICIONAR TITULO //---------------------------------------------------------------------- PdfContentByte t1 = writer.getDirectContentUnder(); t1.beginText(); t1.setFontAndSize(fHelveticaBOLD, 12); t1.setTextMatrix(175, 700); // x e y t1.showText("RELATRIO ANUAL DE ATIVIDADES - " + ano); t1.endText(); PdfContentByte t2 = writer.getDirectContentUnder(); t2.beginText(); t2.setFontAndSize(fHelveticaBOLD, 12); t2.setTextMatrix(160, 680); // x e y if (cursoNome.contains("sistema") || cursoNome.contains("Sistemas") || cursoNome.contains("Sistema")) { t2.showText("BACHARELADO EM SISTEMAS DE INFORMAO"); cursoNome = "Sistemas de Informao"; } else if (cursoNome.contains("cincia") || cursoNome.contains("Cincias") || cursoNome.contains("Cincia")) { t2.showText("BACHARELADO EM CINCIA DA COMPUTAO"); cursoNome = "Cincia da Computao"; } else { t2.showText("BACHARELADO EM " + cursoNome.toUpperCase()); } t2.endText(); Paragraph p0 = new Paragraph("1. Introduo"); p0.setSpacingBefore(95); p0.getFont().setStyle(Font.BOLD); p0.getFont().setSize(12); document.add(p0); //---------------------------------------------------------------------- String textoIntro = "Este documento tem o objetivo de apresentar as atividades da coordenao de estgio " + "supervisionado da Faculdade de Computao da Universidade Federal de Uberlndia. As principais " + "atividades desenvolvidas foram:"; Chunk chunk1 = new Chunk(textoIntro); Paragraph paragraph = new Paragraph(); paragraph.setSpacingBefore(20); paragraph.setSpacingAfter(10); paragraph.setFont(new Font(fHelvetica, 12)); paragraph.add(chunk1); paragraph.setAlignment(Element.ALIGN_JUSTIFIED); document.add(paragraph); //lista List overview = new List(false, 10); overview.setAutoindent(true); overview.add("Aprovao dos documentos de matricula do estgio supervisionado;"); overview.add("Alocao de professores orientadores de estgio;"); overview.add( "Matrcula de alunos do curso de " + cursoNome + " na disciplina de estgio supervisionado;"); overview.add("Acompanhamento das atividades do estagirio na empresa;"); overview.add("Aprovao do Relatrio parcial/final do estagirio."); document.add(overview); String textoIntro2 = "Os resultados das atividades listadas so apresentados nas prximas sees."; Chunk chunk2 = new Chunk(textoIntro2); Paragraph paragraph2 = new Paragraph(); paragraph2.setSpacingBefore(10); paragraph2.setSpacingAfter(10); paragraph2.setFont(new Font(fHelvetica, 12)); paragraph2.add(chunk2); paragraph2.setAlignment(Element.ALIGN_JUSTIFIED); document.add(paragraph2); Paragraph p01 = new Paragraph("2. Sumrio das Atividades"); p01.setSpacingBefore(5); p01.getFont().setStyle(Font.BOLD); p01.getFont().setSize(12); document.add(p01); //---------------------------------------------------------------------- //FAZER SUMARIO //---------------------------------------------------------------------- PdfPTable tabelaSumario = new PdfPTable(4); tabelaSumario.setTotalWidth(100f); tabelaSumario.setWidthPercentage(100); float[] widths = { 40, 20, 20, 20 };//largura das colunas tabelaSumario.setWidths(widths); tabelaSumario.setHeaderRows(1); Paragraph l1 = new Paragraph(" "); l1.getFont().setStyle(Font.BOLD); l1.getFont().setSize(8); PdfPCell cell1 = new PdfPCell(l1); // celula cell1.setBackgroundColor(BaseColor.WHITE); cell1.setBorderColor(BaseColor.WHITE); cell1.setHorizontalAlignment(Element.ALIGN_CENTER); tabelaSumario.addCell(cell1); l1 = new Paragraph("Matrculas"); l1.getFont().setStyle(Font.BOLD); l1.getFont().setSize(8); PdfPCell cell2 = new PdfPCell(l1); // celula cell2.setBackgroundColor(BaseColor.LIGHT_GRAY); cell2.setBorderColor(BaseColor.LIGHT_GRAY); cell2.setHorizontalAlignment(Element.ALIGN_CENTER); tabelaSumario.addCell(cell2); l1 = new Paragraph("Aprovaes"); l1.getFont().setStyle(Font.BOLD); l1.getFont().setSize(8); PdfPCell cell3 = new PdfPCell(l1); // celula cell3.setBackgroundColor(BaseColor.LIGHT_GRAY); cell3.setBorderColor(BaseColor.LIGHT_GRAY); cell3.setHorizontalAlignment(Element.ALIGN_CENTER); tabelaSumario.addCell(cell3); l1 = new Paragraph("Reprovaes"); l1.getFont().setStyle(Font.BOLD); l1.getFont().setSize(8); PdfPCell cell4 = new PdfPCell(l1); // celula cell4.setBackgroundColor(BaseColor.LIGHT_GRAY); cell4.setBorderColor(BaseColor.LIGHT_GRAY); cell4.setHorizontalAlignment(Element.ALIGN_CENTER); tabelaSumario.addCell(cell4); int i = 0; for (Sumariomatricula m : sm) { Sumarioaprovado a = sa.get(i); Paragraph texto = new Paragraph(m.getTipoestagio()); cell1 = new PdfPCell(texto); // celula cell1.setBorderColor(BaseColor.LIGHT_GRAY); cell1.setHorizontalAlignment(Element.ALIGN_LEFT); texto.getFont().setSize(8); tabelaSumario.addCell(cell1); if (m.getMatriculas() != null) { texto = new Paragraph(String.valueOf(m.getMatriculas())); cell1 = new PdfPCell(texto); // celula cell1.setBorderColor(BaseColor.LIGHT_GRAY); cell1.setHorizontalAlignment(Element.ALIGN_CENTER); texto.getFont().setSize(8); tabelaSumario.addCell(cell1); } else { texto = new Paragraph(String.valueOf(0)); cell1 = new PdfPCell(texto); // celula cell1.setBorderColor(BaseColor.LIGHT_GRAY); cell1.setHorizontalAlignment(Element.ALIGN_CENTER); texto.getFont().setSize(8); tabelaSumario.addCell(cell1); } if (m.getTipoestagio().equalsIgnoreCase("Estgio Obrigatrio") && a.getTipoestagio().equalsIgnoreCase("Estgio Obrigatrio")) { if (a.getAprovados() != null) { //aprovados texto = new Paragraph(String.valueOf(a.getAprovados())); cell1 = new PdfPCell(texto); // celula cell1.setBorderColor(BaseColor.LIGHT_GRAY); cell1.setHorizontalAlignment(Element.ALIGN_CENTER); texto.getFont().setSize(8); tabelaSumario.addCell(cell1); } else { texto = new Paragraph(String.valueOf(0)); cell1 = new PdfPCell(texto); // celula cell1.setBorderColor(BaseColor.LIGHT_GRAY); cell1.setHorizontalAlignment(Element.ALIGN_CENTER); texto.getFont().setSize(8); tabelaSumario.addCell(cell1); } //reprovados texto = new Paragraph(String.valueOf(0)); cell1 = new PdfPCell(texto); // celula cell1.setBorderColor(BaseColor.LIGHT_GRAY); cell1.setHorizontalAlignment(Element.ALIGN_CENTER); texto.getFont().setSize(8); tabelaSumario.addCell(cell1); } else if (m.getTipoestagio().equalsIgnoreCase("Estgio No Obrigatrio") && a.getTipoestagio().equalsIgnoreCase("Estgio No Obrigatrio")) { if (a.getAprovados() != null) { //aprovados texto = new Paragraph(String.valueOf(a.getAprovados())); cell1 = new PdfPCell(texto); // celula cell1.setBorderColor(BaseColor.LIGHT_GRAY); cell1.setHorizontalAlignment(Element.ALIGN_CENTER); texto.getFont().setSize(8); tabelaSumario.addCell(cell1); } else { texto = new Paragraph(String.valueOf(0)); cell1 = new PdfPCell(texto); // celula cell1.setBorderColor(BaseColor.LIGHT_GRAY); cell1.setHorizontalAlignment(Element.ALIGN_CENTER); texto.getFont().setSize(8); tabelaSumario.addCell(cell1); } //reprovados texto = new Paragraph(String.valueOf(0)); cell1 = new PdfPCell(texto); // celula cell1.setBorderColor(BaseColor.LIGHT_GRAY); cell1.setHorizontalAlignment(Element.ALIGN_CENTER); texto.getFont().setSize(8); tabelaSumario.addCell(cell1); } i++; } tabelaSumario.setSpacingBefore(20); tabelaSumario.setSpacingAfter(20); tabelaSumario.completeRow(); document.add(tabelaSumario); //---------------------------------------------------------------------- //ALUNOS MATRICULADOS //---------------------------------------------------------------------- Paragraph p1 = new Paragraph("3. Alunos Matriculados"); p1.setSpacingBefore(5); p1.getFont().setStyle(Font.BOLD); p1.getFont().setSize(12); document.add(p1); p01 = new Paragraph("Estgio Obrigatrio"); p01.setSpacingBefore(5); p01.getFont().setStyle(Font.BOLD); p01.getFont().setSize(10); document.add(p01); //---------------------------------------------------------------------- //FAZER TABELA ALUNOS MATRICULADOS ESTAGIO OBRIGATORIO //---------------------------------------------------------------------- PdfPTable tabelaAlunoMatriculadoEO = new PdfPTable(4); tabelaAlunoMatriculadoEO.setTotalWidth(100f); tabelaAlunoMatriculadoEO.setWidthPercentage(100); float[] widthsEO = { 20, 30, 30, 20 };//largura das colunas tabelaAlunoMatriculadoEO.setWidths(widthsEO); tabelaAlunoMatriculadoEO.setHeaderRows(1); l1 = new Paragraph("Matrculas"); l1.getFont().setStyle(Font.BOLD); l1.getFont().setSize(8); cell1 = new PdfPCell(l1); // celula cell1.setBackgroundColor(BaseColor.LIGHT_GRAY); cell1.setBorderColor(BaseColor.LIGHT_GRAY); cell1.setHorizontalAlignment(Element.ALIGN_CENTER); tabelaAlunoMatriculadoEO.addCell(cell1); l1 = new Paragraph("Nome"); l1.getFont().setStyle(Font.BOLD); l1.getFont().setSize(8); cell1 = new PdfPCell(l1); // celula cell1.setBackgroundColor(BaseColor.LIGHT_GRAY); cell1.setBorderColor(BaseColor.LIGHT_GRAY); cell1.setHorizontalAlignment(Element.ALIGN_CENTER); tabelaAlunoMatriculadoEO.addCell(cell1); l1 = new Paragraph("Orientador"); l1.getFont().setStyle(Font.BOLD); l1.getFont().setSize(8); cell1 = new PdfPCell(l1); // celula cell1.setBackgroundColor(BaseColor.LIGHT_GRAY); cell1.setBorderColor(BaseColor.LIGHT_GRAY); cell1.setHorizontalAlignment(Element.ALIGN_CENTER); tabelaAlunoMatriculadoEO.addCell(cell1); l1 = new Paragraph("Data de Matrcula"); l1.getFont().setStyle(Font.BOLD); l1.getFont().setSize(8); cell1 = new PdfPCell(l1); // celula cell1.setBackgroundColor(BaseColor.LIGHT_GRAY); cell1.setBorderColor(BaseColor.LIGHT_GRAY); cell1.setHorizontalAlignment(Element.ALIGN_CENTER); tabelaAlunoMatriculadoEO.addCell(cell1); for (int j = 0; j < am.size(); j++) { Alunomatriculado amat = am.get(j); if (amat.getTipoestagio().equalsIgnoreCase("Estgio Obrigatrio") || amat.getTipoestagio().equalsIgnoreCase("Estgio Obrigatorio") || amat.getTipoestagio().equalsIgnoreCase("Estagio Obrigatorio")) { Paragraph texto = new Paragraph(amat.getMatricula()); cell1 = new PdfPCell(texto); // celula cell1.setBorderColor(BaseColor.LIGHT_GRAY); cell1.setHorizontalAlignment(Element.ALIGN_CENTER); texto.getFont().setSize(8); tabelaAlunoMatriculadoEO.addCell(cell1); texto = new Paragraph(amat.getNome()); cell1 = new PdfPCell(texto); // celula cell1.setBorderColor(BaseColor.LIGHT_GRAY); cell1.setHorizontalAlignment(Element.ALIGN_CENTER); texto.getFont().setSize(8); tabelaAlunoMatriculadoEO.addCell(cell1); texto = new Paragraph(amat.getOrientador()); cell1 = new PdfPCell(texto); // celula cell1.setBorderColor(BaseColor.LIGHT_GRAY); cell1.setHorizontalAlignment(Element.ALIGN_CENTER); texto.getFont().setSize(8); tabelaAlunoMatriculadoEO.addCell(cell1); texto = new Paragraph(CalendarFormat.getDataBRtoDate(amat.getDatamatricula())); cell1 = new PdfPCell(texto); // celula cell1.setBorderColor(BaseColor.LIGHT_GRAY); cell1.setHorizontalAlignment(Element.ALIGN_CENTER); texto.getFont().setSize(8); tabelaAlunoMatriculadoEO.addCell(cell1); } } tabelaAlunoMatriculadoEO.setSpacingBefore(20); tabelaAlunoMatriculadoEO.setSpacingAfter(20); tabelaAlunoMatriculadoEO.completeRow(); document.add(tabelaAlunoMatriculadoEO); //---------------------------------------------------------------------- //FAZER TABELA ALUNOS MATRICULADOS ESTAGIO NO OBRIGATORIO //---------------------------------------------------------------------- p01 = new Paragraph("Estgio No Obrigatrio"); p01.setSpacingBefore(5); p01.getFont().setStyle(Font.BOLD); p01.getFont().setSize(10); document.add(p01); PdfPTable tabelaAlunoMatriculadoENO = new PdfPTable(4); tabelaAlunoMatriculadoENO.setTotalWidth(100f); tabelaAlunoMatriculadoENO.setWidthPercentage(100); float[] widthsENO = { 20, 30, 30, 20 };//largura das colunas tabelaAlunoMatriculadoENO.setWidths(widthsENO); tabelaAlunoMatriculadoENO.setHeaderRows(1); l1 = new Paragraph("Matrculas"); l1.getFont().setStyle(Font.BOLD); l1.getFont().setSize(8); cell1 = new PdfPCell(l1); // celula cell1.setBackgroundColor(BaseColor.LIGHT_GRAY); cell1.setBorderColor(BaseColor.LIGHT_GRAY); cell1.setHorizontalAlignment(Element.ALIGN_CENTER); tabelaAlunoMatriculadoENO.addCell(cell1); l1 = new Paragraph("Nome"); l1.getFont().setStyle(Font.BOLD); l1.getFont().setSize(8); cell1 = new PdfPCell(l1); // celula cell1.setBackgroundColor(BaseColor.LIGHT_GRAY); cell1.setBorderColor(BaseColor.LIGHT_GRAY); cell1.setHorizontalAlignment(Element.ALIGN_CENTER); tabelaAlunoMatriculadoENO.addCell(cell1); l1 = new Paragraph("Orientador"); l1.getFont().setStyle(Font.BOLD); l1.getFont().setSize(8); cell1 = new PdfPCell(l1); // celula cell1.setBackgroundColor(BaseColor.LIGHT_GRAY); cell1.setBorderColor(BaseColor.LIGHT_GRAY); cell1.setHorizontalAlignment(Element.ALIGN_CENTER); tabelaAlunoMatriculadoENO.addCell(cell1); l1 = new Paragraph("Data de Matrcula"); l1.getFont().setStyle(Font.BOLD); l1.getFont().setSize(8); cell1 = new PdfPCell(l1); // celula cell1.setBackgroundColor(BaseColor.LIGHT_GRAY); cell1.setBorderColor(BaseColor.LIGHT_GRAY); cell1.setHorizontalAlignment(Element.ALIGN_CENTER); tabelaAlunoMatriculadoENO.addCell(cell1); for (int k = 0; k < am.size(); k++) { Alunomatriculado amat = am.get(k); if (amat.getTipoestagio().equalsIgnoreCase("Estgio No Obrigatrio") || amat.getTipoestagio().equalsIgnoreCase("Estgio No Obrigatorio") || amat.getTipoestagio().equalsIgnoreCase("Estagio No Obrigatorio")) { Paragraph texto = new Paragraph(amat.getMatricula()); cell1 = new PdfPCell(texto); // celula cell1.setBorderColor(BaseColor.LIGHT_GRAY); cell1.setHorizontalAlignment(Element.ALIGN_CENTER); texto.getFont().setSize(8); tabelaAlunoMatriculadoENO.addCell(cell1); texto = new Paragraph(amat.getNome()); cell1 = new PdfPCell(texto); // celula cell1.setBorderColor(BaseColor.LIGHT_GRAY); cell1.setHorizontalAlignment(Element.ALIGN_CENTER); texto.getFont().setSize(8); tabelaAlunoMatriculadoENO.addCell(cell1); texto = new Paragraph(amat.getOrientador()); cell1 = new PdfPCell(texto); // celula cell1.setBorderColor(BaseColor.LIGHT_GRAY); cell1.setHorizontalAlignment(Element.ALIGN_CENTER); texto.getFont().setSize(8); tabelaAlunoMatriculadoENO.addCell(cell1); texto = new Paragraph(CalendarFormat.getDataBRtoDate(amat.getDatamatricula())); cell1 = new PdfPCell(texto); // celula cell1.setBorderColor(BaseColor.LIGHT_GRAY); cell1.setHorizontalAlignment(Element.ALIGN_CENTER); texto.getFont().setSize(8); tabelaAlunoMatriculadoENO.addCell(cell1); } } tabelaAlunoMatriculadoENO.setSpacingBefore(20); tabelaAlunoMatriculadoENO.setSpacingAfter(20); tabelaAlunoMatriculadoENO.completeRow(); document.add(tabelaAlunoMatriculadoENO); //add nova pagina //document.newPage(); //---------------------------------------------------------------------- //ALUNOS APROVADOS EM ESTAGIO OBRIGATORIO //---------------------------------------------------------------------- p1 = new Paragraph("4. Alunos Aprovados em Estgio Obrigatrio"); p1.setSpacingBefore(20); p1.getFont().setStyle(Font.BOLD); p1.getFont().setSize(12); document.add(p1); PdfPTable tabelaAlunoAprovadoEO = new PdfPTable(5); tabelaAlunoAprovadoEO.setTotalWidth(100f); tabelaAlunoAprovadoEO.setWidthPercentage(100); float[] widthsAprovadoEO = { 20, 30, 30, 10, 10 };//largura das colunas tabelaAlunoAprovadoEO.setWidths(widthsAprovadoEO); tabelaAlunoAprovadoEO.setHeaderRows(1); l1 = new Paragraph("Matrculas"); l1.getFont().setStyle(Font.BOLD); l1.getFont().setSize(8); cell1 = new PdfPCell(l1); // celula cell1.setBackgroundColor(BaseColor.LIGHT_GRAY); cell1.setBorderColor(BaseColor.LIGHT_GRAY); cell1.setHorizontalAlignment(Element.ALIGN_CENTER); tabelaAlunoAprovadoEO.addCell(cell1); l1 = new Paragraph("Nome"); l1.getFont().setStyle(Font.BOLD); l1.getFont().setSize(8); cell1 = new PdfPCell(l1); // celula cell1.setBackgroundColor(BaseColor.LIGHT_GRAY); cell1.setBorderColor(BaseColor.LIGHT_GRAY); cell1.setHorizontalAlignment(Element.ALIGN_CENTER); tabelaAlunoAprovadoEO.addCell(cell1); l1 = new Paragraph("Orientador"); l1.getFont().setStyle(Font.BOLD); l1.getFont().setSize(8); cell1 = new PdfPCell(l1); // celula cell1.setBackgroundColor(BaseColor.LIGHT_GRAY); cell1.setBorderColor(BaseColor.LIGHT_GRAY); cell1.setHorizontalAlignment(Element.ALIGN_CENTER); tabelaAlunoAprovadoEO.addCell(cell1); l1 = new Paragraph("Data de Matrcula"); l1.getFont().setStyle(Font.BOLD); l1.getFont().setSize(8); cell1 = new PdfPCell(l1); // celula cell1.setBackgroundColor(BaseColor.LIGHT_GRAY); cell1.setBorderColor(BaseColor.LIGHT_GRAY); cell1.setHorizontalAlignment(Element.ALIGN_CENTER); tabelaAlunoAprovadoEO.addCell(cell1); l1 = new Paragraph("Data de Finalizao"); l1.getFont().setStyle(Font.BOLD); l1.getFont().setSize(8); cell1 = new PdfPCell(l1); // celula cell1.setBackgroundColor(BaseColor.LIGHT_GRAY); cell1.setBorderColor(BaseColor.LIGHT_GRAY); cell1.setHorizontalAlignment(Element.ALIGN_CENTER); tabelaAlunoAprovadoEO.addCell(cell1); for (int t = 0; t < aa.size(); t++) { Alunoaprovado aprov = aa.get(t); if (aprov.getTipoestagio().equalsIgnoreCase("Estgio Obrigatrio") || aprov.getTipoestagio().equalsIgnoreCase("Estgio Obrigatorio") || aprov.getTipoestagio().equalsIgnoreCase("Estagio Obrigatorio")) { Paragraph texto = new Paragraph(aprov.getMatricula()); cell1 = new PdfPCell(texto); // celula cell1.setBorderColor(BaseColor.LIGHT_GRAY); cell1.setHorizontalAlignment(Element.ALIGN_CENTER); texto.getFont().setSize(8); tabelaAlunoAprovadoEO.addCell(cell1); texto = new Paragraph(aprov.getNome()); cell1 = new PdfPCell(texto); // celula cell1.setBorderColor(BaseColor.LIGHT_GRAY); cell1.setHorizontalAlignment(Element.ALIGN_CENTER); texto.getFont().setSize(8); tabelaAlunoAprovadoEO.addCell(cell1); texto = new Paragraph(aprov.getOrientador()); cell1 = new PdfPCell(texto); // celula cell1.setBorderColor(BaseColor.LIGHT_GRAY); cell1.setHorizontalAlignment(Element.ALIGN_CENTER); texto.getFont().setSize(8); tabelaAlunoAprovadoEO.addCell(cell1); texto = new Paragraph(CalendarFormat.getDataBRtoDate(aprov.getDatamatricula())); cell1 = new PdfPCell(texto); // celula cell1.setBorderColor(BaseColor.LIGHT_GRAY); cell1.setHorizontalAlignment(Element.ALIGN_CENTER); texto.getFont().setSize(8); tabelaAlunoAprovadoEO.addCell(cell1); texto = new Paragraph(CalendarFormat.getDataBRtoDate(aprov.getDatafinalizacao())); cell1 = new PdfPCell(texto); // celula cell1.setBorderColor(BaseColor.LIGHT_GRAY); cell1.setHorizontalAlignment(Element.ALIGN_CENTER); texto.getFont().setSize(8); tabelaAlunoAprovadoEO.addCell(cell1); } } tabelaAlunoAprovadoEO.setSpacingBefore(20); tabelaAlunoAprovadoEO.setSpacingAfter(20); tabelaAlunoAprovadoEO.completeRow(); document.add(tabelaAlunoAprovadoEO); //---------------------------------------------------------------------- //ALUNOS APROVADOS EM ESTAGIO OBRIGATORIO //---------------------------------------------------------------------- p1 = new Paragraph("5. Participao dos professores FACOM"); p1.setSpacingBefore(20); p1.getFont().setStyle(Font.BOLD); p1.getFont().setSize(12); document.add(p1); // PdfPTable tabelaProfOriSeparada = new PdfPTable(3); tabelaProfOriSeparada.setTotalWidth(100f); tabelaProfOriSeparada.setWidthPercentage(100); float[] widths0 = { 60, 20, 20 };//largura das colunas tabelaProfOriSeparada.setWidths(widths0); tabelaProfOriSeparada.setHeaderRows(1); l1 = new Paragraph("Professor"); l1.getFont().setStyle(Font.BOLD); l1.getFont().setSize(8); cell1 = new PdfPCell(l1); // celula cell1.setBackgroundColor(BaseColor.LIGHT_GRAY); cell1.setBorderColor(BaseColor.LIGHT_GRAY); cell1.setHorizontalAlignment(Element.ALIGN_CENTER); tabelaProfOriSeparada.addCell(cell1); l1 = new Paragraph("Orientaes Estgio Obrigatrio"); l1.getFont().setStyle(Font.BOLD); l1.getFont().setSize(8); cell1 = new PdfPCell(l1); // celula cell1.setBackgroundColor(BaseColor.LIGHT_GRAY); cell1.setBorderColor(BaseColor.LIGHT_GRAY); cell1.setHorizontalAlignment(Element.ALIGN_CENTER); tabelaProfOriSeparada.addCell(cell1); l1 = new Paragraph("Orientaes Estgio No Obrigatrio"); l1.getFont().setStyle(Font.BOLD); l1.getFont().setSize(8); cell1 = new PdfPCell(l1); // celula cell1.setBackgroundColor(BaseColor.LIGHT_GRAY); cell1.setBorderColor(BaseColor.LIGHT_GRAY); cell1.setHorizontalAlignment(Element.ALIGN_CENTER); tabelaProfOriSeparada.addCell(cell1); for (int ii = 0; ii < proforiseparada.size(); ii++) { Professororientacaoseparada profoe = proforiseparada.get(ii); Paragraph texto = new Paragraph(profoe.getNome()); cell1 = new PdfPCell(texto); // celula cell1.setBorderColor(BaseColor.LIGHT_GRAY); cell1.setHorizontalAlignment(Element.ALIGN_LEFT); texto.getFont().setSize(8); tabelaProfOriSeparada.addCell(cell1); texto = new Paragraph(profoe.getOrientacoesestobrigatorio().toString()); cell1 = new PdfPCell(texto); // celula cell1.setBorderColor(BaseColor.LIGHT_GRAY); cell1.setHorizontalAlignment(Element.ALIGN_CENTER); texto.getFont().setSize(8); tabelaProfOriSeparada.addCell(cell1); texto = new Paragraph(profoe.getOrientacoesestnaoobrigatorio().toString()); cell1 = new PdfPCell(texto); // celula cell1.setBorderColor(BaseColor.LIGHT_GRAY); cell1.setHorizontalAlignment(Element.ALIGN_CENTER); texto.getFont().setSize(8); tabelaProfOriSeparada.addCell(cell1); } tabelaProfOriSeparada.setSpacingBefore(20); tabelaProfOriSeparada.setSpacingAfter(20); tabelaProfOriSeparada.completeRow(); document.add(tabelaProfOriSeparada); //---------------------------------------------------------------------- p1 = new Paragraph("6. Observaes e Consideraes Finais"); p1.setSpacingBefore(20); p1.getFont().setStyle(Font.BOLD); p1.getFont().setSize(12); document.add(p1); String text6 = "O processo de matrcula, acompanhamento, composio de bancas e " + "defesas ocorreu sem nenhum problema ou acontecimento excepcional."; chunk1 = new Chunk(text6); paragraph = new Paragraph(); paragraph.setSpacingBefore(20); paragraph.setSpacingAfter(10); paragraph.setFont(new Font(fHelvetica, 12)); paragraph.add(chunk1); paragraph.setAlignment(Element.ALIGN_JUSTIFIED); document.add(paragraph); document.add(Chunk.NEWLINE); document.add(Chunk.NEWLINE); document.add(Chunk.NEWLINE); //----------------------------------------------------- Paragraph paragraphCab = new Paragraph(); paragraphCab.setSpacingBefore(25); paragraphCab.add("Uberlndia, " + CalendarFormat.getDataPorExtenso(CalendarFormat.getDataSO()) + "."); paragraphCab.setAlignment(Element.ALIGN_JUSTIFIED); document.add(paragraphCab); document.add(Chunk.NEWLINE); //----------------------------------------------------- // distancia do fim da pagina float y = 120f; 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 a0 = writer.getDirectContentUnder(); a0.beginText(); a0.setFontAndSize(fHelvetica, 10); a0.setTextMatrix(x + 50, y - 15); // x e y a0.showText("Prof. " + coordenador.getNome()); a0.endText(); PdfContentByte a1 = writer.getDirectContentUnder(); a1.beginText(); a1.setFontAndSize(fHelvetica, 10); a1.setTextMatrix(x + 50, y - 30); // 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 - 45); // x e y a2.showText("SIAPE: " + coordenador.getSiape()); a2.endText(); //---------------------------------------------------------------------- //FIM DO DOCUMENTO //add nova pagina document.newPage(); //close document document.close(); //---------------------------------------------------------------------- } catch (DocumentException | IOException ex) { Logger.getLogger(RelatorioAluno.class.getName()).log(Level.SEVERE, null, ex); } //return stream return baos; }
From source file:rs.marko.helper.Kreiranje.java
public static File createPdfStatistika(List<Stavkadnevneberbe> stavke, Date pocetak, Date kraj) { Document document = new Document(); File yourFile = null;//from ww w .ja v a 2 s . c o m try { yourFile = new File(System.getProperty("user.home") + "/Desktop/" + pocetak + "_" + kraj + ".pdf"); if (!yourFile.exists()) { yourFile.createNewFile(); } FileOutputStream oFile = new FileOutputStream(yourFile, false); document.setPageSize(PageSize.A4.rotate()); PdfWriter.getInstance(document, oFile); document.open(); // String text = ""; // for (int i = 0; i < 10000; i++) { // text += "test"; // , } // String jmbg = stavke.get(0).getDobavljac().getJmbg(); PdfPTable table = new PdfPTable( new float[] { 300f, 150f, 150f, 150f, 150f, 150f, 150f, 150f, 150f, 150f, 150f, 150f, 150f }); table.setWidthPercentage(100); table.setSpacingBefore(0f); table.setSpacingAfter(0f); Paragraph p = new Paragraph("Od: " + pocetak + " do: " + kraj); p.add(new Paragraph(" ")); document.add(p); PdfPCell c = new PdfPCell(new Phrase("")); // PdfPCell c1 = new PdfPCell(new Phrase("Sifra")); // c1.setHorizontalAlignment(Element.ALIGN_CENTER); // c1.setRowspan(2); // c1.setColspan(2); // table.addCell(c1); PdfPCell c1 = new PdfPCell(new Phrase("Dobavljac")); c1.setHorizontalAlignment(Element.ALIGN_CENTER); c1.setVerticalAlignment(Element.ALIGN_MIDDLE); c1.setRowspan(2); c1.setColspan(2); table.addCell(c1); c1 = new PdfPCell(new Phrase("Tacne")); c1.setHorizontalAlignment(Element.ALIGN_CENTER); c1.setColspan(2); table.addCell(c1); c1 = new PdfPCell(new Phrase("I Klasa")); c1.setHorizontalAlignment(Element.ALIGN_CENTER); c1.setColspan(2); table.addCell(c1); c1 = new PdfPCell(new Phrase("II Klasa")); c1.setHorizontalAlignment(Element.ALIGN_CENTER); c1.setColspan(2); table.addCell(c1); c1 = new PdfPCell(new Phrase("III Klasa")); c1.setHorizontalAlignment(Element.ALIGN_CENTER); c1.setColspan(2); table.addCell(c1); c1 = new PdfPCell(new Phrase("Svega")); c1.setHorizontalAlignment(Element.ALIGN_CENTER); c1.setColspan(3); table.addCell(c1); c1 = new PdfPCell(new Phrase("Kol")); c1.setHorizontalAlignment(Element.ALIGN_CENTER); table.addCell(c1); c1 = new PdfPCell(new Phrase("Iznos")); c1.setHorizontalAlignment(Element.ALIGN_CENTER); table.addCell(c1); c1 = new PdfPCell(new Phrase("Kol")); c1.setHorizontalAlignment(Element.ALIGN_CENTER); table.addCell(c1); c1 = new PdfPCell(new Phrase("Iznos")); c1.setHorizontalAlignment(Element.ALIGN_CENTER); table.addCell(c1); c1 = new PdfPCell(new Phrase("Kol")); c1.setHorizontalAlignment(Element.ALIGN_CENTER); table.addCell(c1); c1 = new PdfPCell(new Phrase("Iznos")); c1.setHorizontalAlignment(Element.ALIGN_CENTER); table.addCell(c1); c1 = new PdfPCell(new Phrase("Kol")); c1.setHorizontalAlignment(Element.ALIGN_CENTER); table.addCell(c1); c1 = new PdfPCell(new Phrase("Iznos")); c1.setHorizontalAlignment(Element.ALIGN_CENTER); table.addCell(c1); c1 = new PdfPCell(new Phrase("Kol")); c1.setHorizontalAlignment(Element.ALIGN_CENTER); table.addCell(c1); c1 = new PdfPCell(new Phrase("Cena")); c1.setHorizontalAlignment(Element.ALIGN_CENTER); table.addCell(c1); c1 = new PdfPCell(new Phrase("Iznos")); c1.setHorizontalAlignment(Element.ALIGN_CENTER); table.addCell(c1); Font font = new Font(BaseFont.createFont(), 10, Font.NORMAL); // table.setHeaderRows(3); List<String> jmbgovi = new ArrayList<>(); Map<Double, Double> kt = new HashMap<>(); Map<Double, Double> k1 = new HashMap<>(); Map<Double, Double> k2 = new HashMap<>(); Map<Double, Double> k3 = new HashMap<>(); Map<Double, Double> ukupnoTacneVrednost = new HashMap<>(); Map<Double, Double> ukupnoPrvaKlasaVrednost = new HashMap<>(); Map<Double, Double> ukupnoDrugaKlasaVrednost = new HashMap<>(); Map<Double, Double> ukupnoTrecaKlasaVrednost = new HashMap<>(); for (Stavkadnevneberbe stavkaDnevneBerbe : stavke) { if (!jmbgovi.contains(stavkaDnevneBerbe.getDnevnaberba().getDobavljac().getJmbg())) { jmbgovi.add(stavkaDnevneBerbe.getDnevnaberba().getDobavljac().getJmbg()); } } Double ukupnoKolicinaTacne = 0.0; Double ukupnoKolicinaPrvaKlasa = 0.0; Double ukupnoKolicinaDrugaKlasa = 0.0; Double ukupnoKolicinaTrecaKlasa = 0.0; Double ukupnoCenaTacne = 0.0; Double ukupnoCenaPrvaKlasa = 0.0; Double ukupnoCenaDrugaKlasa = 0.0; Double ukupnoCenaTrecaKlasa = 0.0; Double ukupanIznosSvih = 0.0; for (String j : jmbgovi) { String imeDobavljaca = null; for (Stavkadnevneberbe stavkaDnevneBerbe : stavke) { if (stavkaDnevneBerbe.getDnevnaberba().getDobavljac().getJmbg().equals(j)) { if (imeDobavljaca == null) { imeDobavljaca = stavkaDnevneBerbe.getDnevnaberba().getDobavljac().getIme() + " " + stavkaDnevneBerbe.getDnevnaberba().getDobavljac().getPrezime(); } if (!kt.containsKey(stavkaDnevneBerbe.getCenatacne()) && stavkaDnevneBerbe.getTacne() != 0) { kt.put(stavkaDnevneBerbe.getCenatacne(), new Double(0)); } if (!k1.containsKey(stavkaDnevneBerbe.getCenaprvaklasa()) && stavkaDnevneBerbe.getCenaprvaklasa() != 0) { k1.put(stavkaDnevneBerbe.getCenaprvaklasa(), new Double(0)); } if (!k2.containsKey(stavkaDnevneBerbe.getCenadrugaklasa()) && stavkaDnevneBerbe.getCenadrugaklasa() != 0) { k2.put(stavkaDnevneBerbe.getCenadrugaklasa(), new Double(0)); } if (!k3.containsKey(stavkaDnevneBerbe.getCenatrecaklasa()) && stavkaDnevneBerbe.getCenatrecaklasa() != 0) { k3.put(stavkaDnevneBerbe.getCenatrecaklasa(), new Double(0)); } } } for (Stavkadnevneberbe s : stavke) { if (s.getDnevnaberba().getDobavljac().getJmbg().equals(j)) { if (kt.containsKey(s.getCenatacne())) { kt.put(s.getCenatacne(), kt.get(s.getCenatacne()) + s.getTacne()); } if (k1.containsKey(s.getCenaprvaklasa())) { k1.put(s.getCenaprvaklasa(), k1.get(s.getCenaprvaklasa()) + s.getPrvaklasa()); } if (k2.containsKey(s.getCenadrugaklasa())) { k2.put(s.getCenadrugaklasa(), k2.get(s.getCenadrugaklasa()) + s.getDrugaklasa()); } if (k3.containsKey(s.getCenatrecaklasa())) { k3.put(s.getCenatrecaklasa(), k3.get(s.getCenatrecaklasa()) + s.getTrecaklasa()); } } } c1 = new PdfPCell(new Phrase(imeDobavljaca)); c1.setHorizontalAlignment(Element.ALIGN_CENTER); c1.setColspan(2); table.addCell(c1); Iterator it = kt.entrySet().iterator(); Double ukupnoKolicinaT = 0.0; Double ukupnoCenaT = 0.0; Double ukupanIznos = 0.0; while (it.hasNext()) { Map.Entry pair = (Map.Entry) it.next(); ukupnoKolicinaT += (Double) pair.getValue(); ukupnoCenaT += (Double) pair.getKey(); ukupanIznos += ((Double) pair.getValue() * (Double) pair.getKey()); //ukupno vrednost if (ukupnoTacneVrednost.containsKey((Double) pair.getKey())) { ukupnoTacneVrednost.put((Double) pair.getKey(), ukupnoTacneVrednost.get((Double) pair.getKey()) + ((Double) pair.getKey() * (Double) pair.getValue())); } else { ukupnoTacneVrednost.put((Double) pair.getKey(), (Double) pair.getKey() * (Double) pair.getValue()); } } c1 = new PdfPCell(new Phrase(round(ukupnoKolicinaT, 2) + "", font)); table.addCell(c1); c1 = new PdfPCell(new Phrase(round(ukupanIznos, 2) + "", font)); table.addCell(c1); it = k1.entrySet().iterator(); Double ukupnoKolicinaP = 0.0; Double ukupnoCenaP = 0.0; Double ukupanIznosP = 0.0; while (it.hasNext()) { Map.Entry pair = (Map.Entry) it.next(); ukupnoKolicinaP += (Double) pair.getValue(); ukupnoCenaP += (Double) pair.getKey(); ukupanIznosP += ((Double) pair.getValue() * (Double) pair.getKey()); if (ukupnoPrvaKlasaVrednost.containsKey((Double) pair.getKey())) { ukupnoPrvaKlasaVrednost.put((Double) pair.getKey(), ukupnoPrvaKlasaVrednost.get((Double) pair.getKey()) + ((Double) pair.getKey() * (Double) pair.getValue())); } else { ukupnoPrvaKlasaVrednost.put((Double) pair.getKey(), (Double) pair.getKey() * (Double) pair.getValue()); } } c1 = new PdfPCell(new Phrase(round(ukupnoKolicinaP, 2) + "", font)); table.addCell(c1); c1 = new PdfPCell(new Phrase(round(ukupanIznosP, 2) + "", font)); table.addCell(c1); it = k2.entrySet().iterator(); Double ukupnoKolicinaD = 0.0; Double ukupnoCenaD = 0.0; Double ukupanIznosD = 0.0; while (it.hasNext()) { Map.Entry pair = (Map.Entry) it.next(); ukupnoKolicinaD += (Double) pair.getValue(); ukupnoCenaD += (Double) pair.getKey(); ukupanIznosD += ((Double) pair.getValue() * (Double) pair.getKey()); if (ukupnoDrugaKlasaVrednost.containsKey((Double) pair.getKey())) { ukupnoDrugaKlasaVrednost.put((Double) pair.getKey(), ukupnoDrugaKlasaVrednost.get((Double) pair.getKey()) + ((Double) pair.getKey() * (Double) pair.getValue())); } else { ukupnoDrugaKlasaVrednost.put((Double) pair.getKey(), (Double) pair.getKey() * (Double) pair.getValue()); } } c1 = new PdfPCell(new Phrase(round(ukupnoKolicinaD, 2) + "", font)); table.addCell(c1); c1 = new PdfPCell(new Phrase(round(ukupanIznosD, 2) + "", font)); table.addCell(c1); it = k3.entrySet().iterator(); Double ukupnoKolicinaTr = 0.0; Double ukupnoCenaTr = 0.0; Double ukupanIznosT = 0.0; while (it.hasNext()) { Map.Entry pair = (Map.Entry) it.next(); ukupnoKolicinaTr += (Double) pair.getValue(); ukupnoCenaTr += (Double) pair.getKey(); ukupanIznosT += ((Double) pair.getValue() * (Double) pair.getKey()); if (ukupnoTrecaKlasaVrednost.containsKey((Double) pair.getKey())) { ukupnoTrecaKlasaVrednost.put((Double) pair.getKey(), ukupnoTrecaKlasaVrednost.get((Double) pair.getKey()) + ((Double) pair.getKey() * (Double) pair.getValue())); } else { ukupnoTrecaKlasaVrednost.put((Double) pair.getKey(), (Double) pair.getKey() * (Double) pair.getValue()); } } c1 = new PdfPCell(new Phrase(round(ukupnoKolicinaTr, 2) + "", font)); table.addCell(c1); c1 = new PdfPCell(new Phrase(round(ukupanIznosT, 2) + "", font)); table.addCell(c1); Double ukupnoKolicina = ukupnoKolicinaT + ukupnoKolicinaP + ukupnoKolicinaD + ukupnoKolicinaTr; Double ukupnoVrednost = ukupanIznos + ukupanIznosP + ukupanIznosD + ukupanIznosT; Double ukupnoCena = ukupnoVrednost / ukupnoKolicina; c1 = new PdfPCell(new Phrase(round(ukupnoKolicina, 2) + "", font)); table.addCell(c1); c1 = new PdfPCell(new Phrase(round(ukupnoCena, 2) + "", font)); table.addCell(c1); c1 = new PdfPCell(new Phrase(round(ukupnoVrednost, 2) + "", font)); table.addCell(c1); ukupanIznosSvih += ukupnoVrednost; ukupnoKolicinaTacne += ukupnoKolicinaT; ukupnoKolicinaPrvaKlasa += ukupnoKolicinaP; ukupnoKolicinaDrugaKlasa += ukupnoKolicinaD; ukupnoKolicinaTrecaKlasa += ukupnoKolicinaTr; ukupnoCenaTacne += ukupanIznos; ukupnoCenaPrvaKlasa += ukupanIznosP; ukupnoCenaDrugaKlasa += ukupanIznosD; ukupnoCenaTrecaKlasa += ukupanIznosT; kt.clear(); k1.clear(); k2.clear(); k3.clear(); } c1 = new PdfPCell(new Phrase("UKUPNO")); c1.setHorizontalAlignment(Element.ALIGN_CENTER); c1.setColspan(2); table.addCell(c1); c1 = new PdfPCell(new Phrase(ukupnoKolicinaTacne + "", font)); table.addCell(c1); c1 = new PdfPCell(new Phrase(ukupnoCenaTacne + "", font)); table.addCell(c1); c1 = new PdfPCell(new Phrase(ukupnoKolicinaPrvaKlasa + "", font)); table.addCell(c1); c1 = new PdfPCell(new Phrase(ukupnoCenaPrvaKlasa + "", font)); table.addCell(c1); c1 = new PdfPCell(new Phrase(ukupnoKolicinaDrugaKlasa + "", font)); table.addCell(c1); c1 = new PdfPCell(new Phrase(ukupnoCenaDrugaKlasa + "", font)); table.addCell(c1); c1 = new PdfPCell(new Phrase(ukupnoKolicinaTrecaKlasa + "", font)); table.addCell(c1); c1 = new PdfPCell(new Phrase(ukupnoCenaTrecaKlasa + "", font)); table.addCell(c1); Double ukupnoKolicinaSve = ukupnoKolicinaTacne + ukupnoKolicinaPrvaKlasa + ukupnoKolicinaDrugaKlasa + ukupnoKolicinaTrecaKlasa; Double prosecnaCena = ukupanIznosSvih / ukupnoKolicinaSve; c1 = new PdfPCell(new Phrase(round(ukupnoKolicinaSve, 2) + "", font)); table.addCell(c1); c1 = new PdfPCell(new Phrase(round(prosecnaCena, 2) + "", font)); table.addCell(c1); c1 = new PdfPCell(new Phrase(round(ukupanIznosSvih, 2) + "", font)); table.addCell(c1); //PDV c1 = new PdfPCell(new Phrase("PDV")); c1.setHorizontalAlignment(Element.ALIGN_CENTER); c1.setColspan(2); table.addCell(c1); table.addCell(c); Iterator it = ukupnoTacneVrednost.entrySet().iterator(); Double ukupnoTacnePdv = 0.0; while (it.hasNext()) { Map.Entry pair = (Map.Entry) it.next(); if ((Double) pair.getKey() == 110) { ukupnoTacnePdv += (((Double) pair.getValue() / (Double) pair.getKey()) * 106); } else { ukupnoTacnePdv += (Double) pair.getValue(); } } c1 = new PdfPCell(new Phrase(round(ukupnoTacnePdv * (110.0f / 100.0f), 2) + "", font)); table.addCell(c1); table.addCell(c); it = ukupnoPrvaKlasaVrednost.entrySet().iterator(); Double ukupnoPrvaKlasaPdv = 0.0; while (it.hasNext()) { Map.Entry pair = (Map.Entry) it.next(); ukupnoPrvaKlasaPdv += (Double) pair.getValue(); } c1 = new PdfPCell(new Phrase(round(ukupnoPrvaKlasaPdv * (110.0f / 100.0f), 2) + "", font)); table.addCell(c1); table.addCell(c); it = ukupnoDrugaKlasaVrednost.entrySet().iterator(); Double ukupnoDrugaKlasaPdv = 0.0; while (it.hasNext()) { Map.Entry pair = (Map.Entry) it.next(); ukupnoDrugaKlasaPdv += (Double) pair.getValue(); } c1 = new PdfPCell(new Phrase(round(ukupnoDrugaKlasaPdv * (110.0f / 100.0f), 2) + "", font)); table.addCell(c1); table.addCell(c); it = ukupnoTrecaKlasaVrednost.entrySet().iterator(); Double ukupnoTrecaKlasaPdv = 0.0; while (it.hasNext()) { Map.Entry pair = (Map.Entry) it.next(); ukupnoTrecaKlasaPdv += (Double) pair.getValue(); } c1 = new PdfPCell(new Phrase(round(ukupnoTrecaKlasaPdv * (110.0f / 100.0f), 2) + "", font)); table.addCell(c1); c = new PdfPCell(new Phrase("")); c.setColspan(2); table.addCell(c); Double ukupnoSvePDV = ukupnoTacnePdv + ukupnoPrvaKlasaPdv + ukupnoDrugaKlasaPdv + ukupnoTrecaKlasaPdv; c1 = new PdfPCell(new Phrase(round(ukupnoSvePDV * (110.0f / 100.0f), 2) + "", font)); table.addCell(c1); c = new PdfPCell(new Phrase("")); c.setColspan(10); table.addCell(c); // table.addCell(c); // table.addCell(c); // table.addCell(c); // table.addCell(c); // table.addCell(c); // table.addCell(c); // table.addCell(c); // table.addCell(c); // table.addCell(c); c1 = new PdfPCell(new Phrase("DOBITAK")); c1.setHorizontalAlignment(Element.ALIGN_CENTER); c1.setColspan(2); table.addCell(c1); c1 = new PdfPCell( new Phrase(round((ukupnoSvePDV * (110.0f / 100.0f)) - ukupanIznosSvih, 2) + "", font)); table.addCell(c1); document.add(table); document.add(new Paragraph(" ")); } catch (DocumentException ex) { Logger.getLogger(Kreiranje.class.getName()).log(Level.SEVERE, null, ex); } catch (FileNotFoundException ex) { Logger.getLogger(Kreiranje.class.getName()).log(Level.SEVERE, null, ex); } catch (IOException ex) { Logger.getLogger(Kreiranje.class.getName()).log(Level.SEVERE, null, ex); } document.close(); return yourFile; }
From source file:se.billes.pdf.renderer.model.text.TableParagraph.java
License:Open Source License
@Override public void onRender(PdfPCell cell) throws PdfRenderException { PdfPTable table = new PdfPTable(widths.length); try {//from w ww . java 2s . c o m table.setTotalWidth(getTotalWidthsAsPs()); table.setLockedWidth(true); table.setSpacingAfter(0f); for (AbstractParagraph tableCell : cells) { PdfPCell c = new PdfPCell(); float[] padding = new float[] { 0f, 0f, 0f, 0f }; if (tableCell instanceof TableCell) { padding = ((TableCell) tableCell).getPadding(); } c.setBorderWidth(0f); c.setLeft(0); c.setTop(0); c.setRight(0); c.setBottom(0); c.setUseAscender(true); c.setIndent(0); c.setHorizontalAlignment(Element.ALIGN_LEFT); c.setVerticalAlignment(Element.ALIGN_TOP); c.setPaddingLeft(SizeFactory.millimetersToPostscriptPoints(padding[0])); c.setPaddingBottom(SizeFactory.millimetersToPostscriptPoints(padding[3])); c.setPaddingRight(SizeFactory.millimetersToPostscriptPoints(padding[2])); c.setPaddingTop(SizeFactory.millimetersToPostscriptPoints(padding[1])); c.setBorder(0); tableCell.onRender(c); table.addCell(c); } cell.addElement(table); } catch (Exception e) { throw new PdfRenderException(e); } }