List of usage examples for com.itextpdf.text.pdf PdfPTable setHorizontalAlignment
public void setHorizontalAlignment(final int horizontalAlignment)
From source file:edu.uc.modulocontable.general.GenerarKardexPDF.java
private void cabeceraTabla() throws DocumentException { PdfPTable tablePanelInicial = new PdfPTable(4); tablePanelInicial.setWidthPercentage(100); tablePanelInicial.setWidths(new int[] { 28, 15, 15, 15 }); tablePanelInicial.getDefaultCell().setBorder(5); tablePanelInicial.setHorizontalAlignment(2); PdfPCell cell = new PdfPCell(new Paragraph("", FontFactory.getFont("arial", 10, Font.BOLD))); cell.setHorizontalAlignment(1);//from w w w . j av a 2s . co m cell.setBorder(0); tablePanelInicial.addCell(cell); cell = new PdfPCell(new Paragraph("Entrada", FontFactory.getFont("arial", 10, Font.BOLD))); cell.setHorizontalAlignment(1); tablePanelInicial.addCell(cell); cell = new PdfPCell(new Paragraph("Salida", FontFactory.getFont("arial", 10, Font.BOLD))); cell.setHorizontalAlignment(1); tablePanelInicial.addCell(cell); cell = new PdfPCell(new Paragraph("Saldo", FontFactory.getFont("arial", 10, Font.BOLD))); cell.setHorizontalAlignment(1); tablePanelInicial.addCell(cell); documento.add(tablePanelInicial); }
From source file:edu.uc.modulocontable.general.GenerarKardexPDF.java
private void comprobarLIFO() throws DocumentException { PdfPTable tablePanelInicial = new PdfPTable(1); tablePanelInicial.setWidthPercentage(100); tablePanelInicial.getDefaultCell().setBorder(0); tablePanelInicial.setHorizontalAlignment(2); PdfPCell cell = new PdfPCell(new Paragraph("Comprobacin", FontFactory.getFont("arial", 10, Font.BOLD))); cell.setHorizontalAlignment(2);/*w w w.j av a 2 s. c o m*/ cell.setBorder(0); tablePanelInicial.addCell(cell); documento.add(espacioBlanco.getElemento()); documento.add(espacioBlanco.getElemento()); documento.add(tablePanelInicial); documento.add(espacioBlanco.getElemento()); tablaVertical.limpiar(); int[] alineamientos = { 0, 2 }; int[] tamanos = { 20, 17 }; Vector datos = new Vector(); Vector<String> titulos = new Vector<String>(); datos.add(0); titulos.add("Inv. inicial"); datos.add(getCantidadEntrada()); titulos.add("(+) U. entrada"); datos.add(getCantidadSalida()); titulos.add("(-) U. salida"); datos.add(getSaldoCantidad()); titulos.add("(=) Stock"); String[] anArray = new String[titulos.size()]; tablaVertical.setTitulos(titulos.toArray(anArray)); tablaVertical.setContenidos(datos.toArray()); tablaVertical.setAlineamientos(alineamientos); tablaVertical.llenarTabla(true); tablaVertical.setPosicion(2); tablaVertical.setAnchoTabla(42); tablaVertical.setTamanos(tamanos); documento.add(tablaVertical.getTabla()); }
From source file:edu.uc.modulocontable.transaccion.GenerarComprobacion.java
private void cabeceraTabla() throws DocumentException { PdfPTable tablePanelInicial = new PdfPTable(5); tablePanelInicial.setWidthPercentage(100); tablePanelInicial.setWidths(new int[] { 10, 5, 5, 5, 5 }); tablePanelInicial.getDefaultCell().setBorder(5); tablePanelInicial.setHorizontalAlignment(2); PdfPCell cell = new PdfPCell(new Paragraph("", FontFactory.getFont("arial", 10, Font.BOLD))); cell.setHorizontalAlignment(1);/*from w w w . j a v a 2 s . c o m*/ cell.setBorder(0); tablePanelInicial.addCell(cell); cell = new PdfPCell(new Paragraph("Suma", FontFactory.getFont("arial", 10, Font.BOLD))); cell.setHorizontalAlignment(1); tablePanelInicial.addCell(cell); cell = new PdfPCell(new Paragraph("Saldos", FontFactory.getFont("arial", 10, Font.BOLD))); cell.setHorizontalAlignment(1); tablePanelInicial.addCell(cell); documento.add(tablePanelInicial); }
From source file:Export.ExporOnlyViagemPdf.java
private void dataTableTitile(Document documento, String data) throws IOException, BadElementException, DocumentException { try {//from ww w . j a v a 2 s. c om pTableEmpresaPricipal = new PdfPTable(new float[] { 15f, 85f }); pTableEmpresaInforImpres1 = new PdfPTable(1); pTableEmpresaInforImpres5 = new PdfPTable(1); PdfPCell pCellNomeEmpresa = new PdfPCell(new Phrase(Empresa.NOME, fontCabecalhoNG)); pCellNomeEmpresa.setBorder(0); PdfPCell pCellNomeEndereco = new PdfPCell(new Phrase(Empresa.ENDERECO, fontCabecalhoN)); pCellNomeEndereco.setBorder(0); PdfPCell pCellCaixaPostal = new PdfPCell(new Phrase(Empresa.CAIXAPOSTAL, fontCabecalhoN)); pCellCaixaPostal.setBorder(0); PdfPCell pCellTeleFax = new PdfPCell( new Phrase(Empresa.TELEFAX + " " + ConfigDoc.Empresa.EMAIL, fontCabecalhoN)); pCellTeleFax.setBorder(0); PdfPCell pCellSociedade = new PdfPCell(new Phrase(Empresa.SOCIEDADE, fontCabecalhoN)); pCellSociedade.setBorder(0); Image imageEmpresa = Image.getInstance("logo.png"); imageEmpresa.scaleToFit(120f, 85f); pTableEmpresaInforImpres1.addCell(pCellNomeEmpresa); pTableEmpresaInforImpres1.addCell(pCellNomeEndereco); pTableEmpresaInforImpres1.addCell(pCellCaixaPostal); pTableEmpresaInforImpres1.addCell(pCellTeleFax); pTableEmpresaInforImpres1.addCell(pCellSociedade); PdfPCell cellTabela3 = new PdfPCell(pTableEmpresaInforImpres1); cellTabela3.setBorder(0); pTableEmpresaInforImpres5.addCell(cellTabela3); PdfPCell cellTabela5 = new PdfPCell(pTableEmpresaInforImpres5); cellTabela5.setBorder(0); PdfPCell cellTabela6 = new PdfPCell(imageEmpresa); cellTabela6.setBorder(0); pTableEmpresaPricipal.setWidthPercentage(95); pTableEmpresaPricipal.addCell(cellTabela6); pTableEmpresaPricipal.addCell(cellTabela5); PdfPTable pTableTitulo = new PdfPTable(1); pTableTitulo.setHorizontalAlignment(Element.ALIGN_CENTER); pTableTitulo.setWidthPercentage(100); SimpleDateFormat sdfEsp = new SimpleDateFormat("MMMM, yyyy", Locale.ENGLISH); SimpleDateFormat sdf = new SimpleDateFormat("MM-yyyy"); PdfPCell cellTitulo = new PdfPCell( new Phrase("TOTAL PREMIUM COLLECTED ON TRAVEL INSURANCE AND TAXES FOR " + sdfEsp.format(sdf.parse(data)).toUpperCase(), fontCorpoNG)); cellTitulo.setBorder(0); cellTitulo.setPaddingBottom(10f); pTableTitulo.addCell(cellTitulo); pTableEmpresaPricipal.setHorizontalAlignment(Element.ALIGN_CENTER); documento.add(pTableEmpresaPricipal); documento.add(pTableNull); documento.add(pTableTitulo); } catch (ParseException ex) { Logger.getLogger(ExporOnlyViagemPdf.class.getName()).log(Level.SEVERE, null, ex); } }
From source file:Export.ExportViagemSemanaPdf.java
public static void criarDoc(Date dataInicio, Date dateFim, String user, String nomeFuncinario) { Font fontTableCorpo = FontFactory.getFont(ConfigDoc.Fontes.FONT, BaseFont.WINANSI, BaseFont.EMBEDDED, 6f); Font fontTableTitile = FontFactory.getFont(ConfigDoc.Fontes.FONTB, BaseFont.WINANSI, BaseFont.EMBEDDED, 6f); Font fontRoadape = FontFactory.getFont(ConfigDoc.Fontes.FONTB, BaseFont.WINANSI, BaseFont.EMBEDDED, 8f); Font fontRoadapeP = FontFactory.getFont(ConfigDoc.Fontes.FONTB, BaseFont.WINANSI, BaseFont.EMBEDDED, 6f); Font fontRoadapeB = FontFactory.getFont(ConfigDoc.Fontes.FONTB, BaseFont.WINANSI, BaseFont.EMBEDDED, 8f); Font fontRoadapeBU = FontFactory.getFont(ConfigDoc.Fontes.FONTB, BaseFont.WINANSI, BaseFont.EMBEDDED, 8f, Font.UNDEFINED);//from ww w.java 2s .c o m Font fontCabecalhoN = FontFactory.getFont(ConfigDoc.Fontes.FONTB, BaseFont.WINANSI, BaseFont.EMBEDDED, 9.5f); Font fontCorpoNG = FontFactory.getFont(ConfigDoc.Fontes.FONTB, BaseFont.WINANSI, BaseFont.EMBEDDED, 9.5f); Font fontCabecalhoNG = FontFactory.getFont(ConfigDoc.Fontes.FONTB, BaseFont.WINANSI, BaseFont.EMBEDDED, 16f, Font.UNDERLINE); OutputStream outputStraem; try { SimpleDateFormat sdf = new SimpleDateFormat("dd-MM-yyyy hh.mm.ss"); SimpleDateFormat sdfTitile = new SimpleDateFormat("dd-MM-yyyy"); Document documento = new Document(); documento.setPageSize(PageSize.A4.rotate()); documento.setMargins(10f, 10f, 35f, 20f); File ff = new File(ConfigDoc.Fontes.getDiretorio() + "/" + user + "/Seguro Viagem/"); ff.mkdirs(); String Ddata = sdf.format(new Date()); ff = new File(ff.getAbsoluteFile() + "/" + "Export Mapa Viagem Semanal " + Ddata + ".pdf"); String reString = "../Documentos/" + user + "/Seguro Viagem/" + "Export Mapa Viagem Semanal " + Ddata + ".pdf"; outputStraem = new FileOutputStream(ff); PdfWriter writer = PdfWriter.getInstance(documento, outputStraem); PdfPTable tableDados = new PdfPTable( new float[] { 5f, 10.6f, 5f, 5f, 4.6f, 19f, 5.6f, 6f, 10.6f, 9.6f, 7f, 5.5f, 5.5f }); tableDados.setWidthPercentage(100f); BaseColor colorCinza = new BaseColor(129, 138, 145); for (int j = 0; j < 13; j++) { PdfPCell cellTitileTable = new PdfPCell(new Phrase(titileTable(j), fontTableTitile)); cellTitileTable.setHorizontalAlignment(PdfPCell.ALIGN_CENTER); cellTitileTable.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE); cellTitileTable.setBackgroundColor(colorCinza); tableDados.addCell(cellTitileTable); } dataViagem(dataInicio, dateFim); float premiototal = 0; for (HashMap<String, Object> data : hasList) { tableDados.addCell(new Phrase(toString(data.get(DATA)), fontTableCorpo)); tableDados.addCell(ExportViagemSemanaPdf .cellEspecial(new PdfPCell(new Phrase(toString(data.get(NUMEROAPOLICE)), fontTableCorpo)))); tableDados.addCell( new Phrase(ConfigDoc.toFormat(toString(data.get(INICIO)), "dd-MM-yyyy", "yyyy-MM-dd"), fontTableCorpo)); tableDados.addCell(new Phrase( ConfigDoc.toFormat(toString(data.get(FIM)), "dd-MM-yyyy", "yyyy-MM-dd"), fontTableCorpo)); premiototal += toFloat(data.get(PREMIO)); PdfPCell cellRigh = new PdfPCell( new Phrase(ConfigDoc.toMoeda(toFloat(data.get(PREMIO)), ""), fontTableCorpo)); cellRigh.setHorizontalAlignment(PdfPCell.ALIGN_RIGHT); tableDados.addCell(cellRigh); tableDados.addCell(new Phrase(toString(data.get(CLIENTE)), fontTableCorpo)); tableDados.addCell(new Phrase(toString(data.get(DATANASCIMENTO)), fontTableCorpo)); tableDados.addCell(new Phrase(toString(data.get(TELEFONE)), fontTableCorpo)); tableDados.addCell(new Phrase(toString(data.get(ENDERECO)), fontTableCorpo)); tableDados.addCell(new Phrase(toString(data.get(LOCALNASCIMENTO)), fontTableCorpo)); tableDados.addCell(new Phrase(toString(data.get(PAISDESTINO)), fontTableCorpo)); tableDados.addCell(new Phrase(toString(data.get(CIDADEDESTINO)), fontTableCorpo)); tableDados.addCell(new Phrase(toString(data.get(ZONADESTINO)), fontTableCorpo)); } PdfPCell cellTotal = new PdfPCell(ExportViagemSemanaPdf.cellEspecial(new PdfPCell( new Phrase("AL AMOUNT..........................................", fontTableTitile)))); cellTotal.setColspan(4); cellTotal.setPadding(1.5f); cellTotal.setBackgroundColor(colorCinza); tableDados.addCell(cellTotal); cellTotal = new PdfPCell(ExportViagemSemanaPdf .cellEspecial(new PdfPCell(new Phrase(ConfigDoc.toMoeda(premiototal, ""), fontTableTitile)))); cellTotal.setPadding(1.5f); cellTotal.setBackgroundColor(colorCinza); tableDados.addCell(cellTotal); cellTotal = new PdfPCell( ExportViagemSemanaPdf.cellEspecial(new PdfPCell(new Phrase(" ", fontTableTitile)))); cellTotal.setColspan(8); cellTotal.setPadding(1.5f); cellTotal.setBackgroundColor(colorCinza); tableDados.addCell(cellTotal); PdfPTable pTableEmpresaPricipal = new PdfPTable(new float[] { 15f, 85f }); PdfPTable pTableEmpresaInforImpres1 = new PdfPTable(1); PdfPTable pTableEmpresaInforImpres5 = new PdfPTable(1); PdfPCell pCellNomeEmpresa = new PdfPCell(new Phrase(ConfigDoc.Empresa.NOME, fontCabecalhoNG)); pCellNomeEmpresa.setBorder(0); PdfPCell pCellNomeEndereco = new PdfPCell(new Phrase(ConfigDoc.Empresa.ENDERECO, fontCabecalhoN)); pCellNomeEndereco.setBorder(0); PdfPCell pCellCaixaPostal = new PdfPCell(new Phrase(ConfigDoc.Empresa.CAIXAPOSTAL, fontCabecalhoN)); pCellCaixaPostal.setBorder(0); PdfPCell pCellTeleFax = new PdfPCell( new Phrase(ConfigDoc.Empresa.TELEFAX + " " + ConfigDoc.Empresa.EMAIL, fontCabecalhoN)); pCellTeleFax.setBorder(0); PdfPCell pCellSociedade = new PdfPCell(new Phrase(ConfigDoc.Empresa.SOCIEDADE, fontCabecalhoN)); pCellSociedade.setBorder(0); Image imageEmpresa = Image.getInstance("logo.png"); imageEmpresa.scaleToFit(120f, 85f); pTableEmpresaInforImpres1.addCell(pCellNomeEmpresa); pTableEmpresaInforImpres1.addCell(pCellNomeEndereco); pTableEmpresaInforImpres1.addCell(pCellCaixaPostal); pTableEmpresaInforImpres1.addCell(pCellTeleFax); pTableEmpresaInforImpres1.addCell(pCellSociedade); PdfPCell cellTabela3 = new PdfPCell(pTableEmpresaInforImpres1); cellTabela3.setBorder(0); pTableEmpresaInforImpres5.addCell(cellTabela3); PdfPCell cellTabela5 = new PdfPCell(pTableEmpresaInforImpres5); cellTabela5.setBorder(0); PdfPCell cellTabela6 = new PdfPCell(imageEmpresa); cellTabela6.setBorder(0); pTableEmpresaPricipal.setWidthPercentage(95); pTableEmpresaPricipal.addCell(cellTabela6); pTableEmpresaPricipal.addCell(cellTabela5); PdfPTable pTableTitulo = new PdfPTable(1); pTableTitulo.setHorizontalAlignment(Element.ALIGN_CENTER); pTableTitulo.setWidthPercentage(100); PdfPCell cellTitulo = new PdfPCell(new Phrase("RLELATORIO SEMANAL NO. " + "" + "\n" + ((dataInicio != null) ? sdfTitile.format(dataInicio) + " - " : "") + ((dateFim != null) ? sdfTitile.format(dateFim) : ""), fontCorpoNG)); cellTitulo.setBorder(0); cellTitulo.setPaddingBottom(20f); cellTitulo.setPaddingTop(10f); cellTitulo.setHorizontalAlignment(PdfPCell.ALIGN_CENTER); pTableTitulo.addCell(cellTitulo); pTableEmpresaPricipal.setHorizontalAlignment(Element.ALIGN_CENTER); PdfPTable pTableRodape = new PdfPTable(new float[] { 50f, 50f }); pTableRodape.setWidthPercentage(90f); PdfPCell cellRodape = new PdfPCell(new Phrase("DEPARTAMENTO FINANCEIRO", fontRoadapeBU)); cellRodape.setBorder(0); cellRodape.setColspan(2); cellRodape.setPaddingTop(20f); pTableRodape.addCell(cellRodape); cellRodape = new PdfPCell(new Phrase("QUEIRA POR FAVOR CONFERIR OS PAGAMENTOS", fontRoadape)); cellRodape.setColspan(2); cellRodape.setBorder(0); pTableRodape.addCell(cellRodape); cellRodape = new PdfPCell(new Phrase("ELABORADO POR", fontRoadapeB)); cellRodape.setBorder(0); pTableRodape.addCell(cellRodape); cellRodape = new PdfPCell(new Phrase("VENFICADO POR", fontRoadapeB)); cellRodape.setBorder(0); cellRodape.setHorizontalAlignment(PdfPCell.ALIGN_RIGHT); pTableRodape.addCell(cellRodape); cellRodape = new PdfPCell(new Phrase("................................................", fontRoadape)); cellRodape.setBorder(0); cellRodape.setPaddingTop(30f); pTableRodape.addCell(cellRodape); cellRodape = new PdfPCell(new Phrase("................................................", fontRoadape)); cellRodape.setHorizontalAlignment(PdfPCell.ALIGN_RIGHT); cellRodape.setBorder(0); cellRodape.setPaddingTop(30f); pTableRodape.addCell(cellRodape); cellRodape = new PdfPCell(new Phrase(nomeFuncinario, fontRoadapeP)); cellRodape.setColspan(2); cellRodape.setBorder(0); pTableRodape.addCell(cellRodape); documento.open(); documento.add(pTableEmpresaPricipal); documento.add(pTableTitulo); documento.add(tableDados); documento.add(pTableRodape); documento.close(); RequestContext.getCurrentInstance().execute("openAllDocument('" + reString + "')"); } catch (FileNotFoundException | DocumentException ex) { Logger.getLogger(ExportViagemSemanaPdf.class.getName()).log(Level.SEVERE, null, ex); } catch (IOException ex) { Logger.getLogger(ExportViagemSemanaPdf.class.getName()).log(Level.SEVERE, null, ex); } }
From source file:Export.FuncPagamento.java
private String pequenoPagamento(String numPagamento, String user, String nomeUser, int i) { OutputStream outputStraem;//from ww w . ja v a 2 s .c o m try { SimpleDateFormat sdf = new SimpleDateFormat("MMMM yyyy - dd", new Locale("pt", "BR")); SimpleDateFormat sdf3 = new SimpleDateFormat("dd-MM-yyyy"); SimpleDateFormat sdf2 = new SimpleDateFormat("dd 'de' MMMM 'de' yyyy", new Locale("pt", "BR")); SimpleDateFormat sdf1 = new SimpleDateFormat("dd-MM-yyyy hh'.'mm'.'ss"); Font fontCabecalhoN = FontFactory.getFont(ConfigDoc.Fontes.FONT, BaseFont.WINANSI, BaseFont.EMBEDDED, 14f); Font fontCorpo = FontFactory.getFont(ConfigDoc.Fontes.FONT, BaseFont.WINANSI, BaseFont.EMBEDDED, 8.5f); Font fontCorpoU = FontFactory.getFont(ConfigDoc.Fontes.FONT, BaseFont.WINANSI, BaseFont.EMBEDDED, 9f, Font.UNDERLINE); // Font fontCorpoP= FontFactory.getFont(ConfigDoc.Fontes.FONT, BaseFont.WINANSI, BaseFont.EMBEDDED ,8f ); Font fontCorpoN = FontFactory.getFont(ConfigDoc.Fontes.FONTB, BaseFont.WINANSI, BaseFont.EMBEDDED, 9f); Font fontCorpoNG = FontFactory.getFont(ConfigDoc.Fontes.FONTB, BaseFont.WINANSI, BaseFont.EMBEDDED, 8.5f); // Font fontCorpoNGT= FontFactory.getFont(ConfigDoc.Fontes.FONTB, BaseFont.WINANSI, BaseFont.EMBEDDED , 13f ,Font.UNDERLINE); Font fontCabecalhoNG = FontFactory.getFont(ConfigDoc.Fontes.FONTB, BaseFont.WINANSI, BaseFont.EMBEDDED, 16f, Font.UNDERLINE); Document documento = new Document(); documento.setPageSize(PageSize.A4); documento.setMargins(20f, 20f, 10f, 5f); String Ddata = sdf1.format(new Date()); ArrayList<HashMap<String, Object>> mapList = getObj(numPagamento); int total = mapList.size(); File ff = new File(ConfigDoc.Fontes.getDiretorio() + "/" + user + "/Pagamentos/"); ff.mkdirs(); ff = new File(ff.getAbsoluteFile() + "/" + "Pagamentos Func " + Ddata + ".pdf"); outputStraem = new FileOutputStream(ff); PdfWriter writer = PdfWriter.getInstance(documento, outputStraem); MyFooterA5 event = new MyFooterA5(); writer.setPageEvent(event); documento.open(); PdfPTable pTableTitile = new PdfPTable(new float[] { 100 }); pTableTitile.setWidthPercentage(95f); PdfPCell cellTitile = new PdfPCell(); cellTitile.setBorder(0); Paragraph pTitile = new Paragraph(); pTitile.add(new Phrase(ConfigDoc.Empresa.NOME.toUpperCase(), fontCabecalhoNG)); pTitile.setAlignment(Element.ALIGN_CENTER); PdfPTable pTableSubTitile = new PdfPTable(new float[] { 80, 20 }); pTableSubTitile.setWidthPercentage(101f); PdfPCell cellSubTitile = new PdfPCell( new Phrase("Petty cash voucher no.".toUpperCase(), fontCabecalhoN)); cellSubTitile.setBorder(0); cellSubTitile.setHorizontalAlignment(Element.ALIGN_RIGHT); cellSubTitile.setPaddingBottom(20); cellSubTitile.setPaddingRight(67); cellSubTitile.setPaddingTop(10); pTableSubTitile.addCell(cellSubTitile); cellSubTitile = new PdfPCell( new Phrase(toData((mapList.size() > 0) ? mapList.get(0).get(REGISTRO) : " ", i).toUpperCase(), fontCabecalhoN)); cellSubTitile.setHorizontalAlignment(Element.ALIGN_LEFT); cellSubTitile.setBorder(0); cellSubTitile.setPaddingBottom(20); cellSubTitile.setPaddingTop(10); pTableSubTitile.addCell(cellSubTitile); // pTitile.add(cellSubTitile); pTitile.add(pTableSubTitile); cellTitile.addElement(pTitile); pTableTitile.addCell(cellTitile); documento.add(pTableTitile); PdfPTable pTableDados = new PdfPTable(new float[] { 5.6f, 6.05f, 53.5f, 17.95f, 19f }); pTableDados.setWidthPercentage(95f); PdfPCell cellDados = new PdfPCell(new Phrase("S/N", fontCorpoNG)); cellDados.setHorizontalAlignment(Element.ALIGN_CENTER); pTableDados.addCell(cellDados); cellDados = new PdfPCell(new Phrase("Qty", fontCorpoNG)); cellDados.setHorizontalAlignment(Element.ALIGN_CENTER); pTableDados.addCell(cellDados); cellDados = new PdfPCell(new Phrase("Detail Description", fontCorpoNG)); cellDados.setHorizontalAlignment(Element.ALIGN_CENTER); pTableDados.addCell(cellDados); cellDados = new PdfPCell(new Phrase("Unit price", fontCorpoNG)); cellDados.setHorizontalAlignment(Element.ALIGN_CENTER); pTableDados.addCell(cellDados); cellDados = new PdfPCell(new Phrase("AMT (STD)", fontCorpoNG)); cellDados.setHorizontalAlignment(Element.ALIGN_CENTER); pTableDados.addCell(cellDados); Double toPa = 0.0; for (int j = 0; j < total; j++) { int tLinha = toString(mapList.get(j).get(DESCRICAOPAGAMENTO)).split("\n").length; float pad = setPadding(total, tLinha); cellDados = new PdfPCell(new Phrase((j + 1) + "", fontCorpo)); cellDados.setPaddingBottom(pad); cellDados.setVerticalAlignment(Element.ALIGN_MIDDLE); cellDados.setPaddingTop(pad); pTableDados.addCell(cellDados); cellDados = new PdfPCell(new Phrase(toInt(mapList.get(j).get(QUANTIDADE)) + "", fontCorpo)); cellDados.setPaddingBottom(pad); cellDados.setVerticalAlignment(Element.ALIGN_MIDDLE); cellDados.setPaddingTop(pad); pTableDados.addCell(cellDados); cellDados = new PdfPCell(new Phrase(toString(mapList.get(j).get(DESCRICAOPAGAMENTO)), fontCorpo)); cellDados.setPaddingBottom(pad); cellDados.setVerticalAlignment(Element.ALIGN_MIDDLE); cellDados.setPaddingTop(pad); pTableDados.addCell(cellDados); cellDados = new PdfPCell(new Phrase(toMoeda( (toDouble(mapList.get(j).get(VALORPAGAMENTO)) / (float) toInt(mapList.get(j).get(QUANTIDADE))), toString(mapList.get(j).get(SIGLA))), fontCorpo)); cellDados.setPaddingBottom(pad); cellDados.setVerticalAlignment(Element.ALIGN_MIDDLE); cellDados.setPaddingTop(pad); pTableDados.addCell(cellDados); cellDados = new PdfPCell(new Phrase( toMoeda(toDouble(mapList.get(j).get(VALORPAGAMENTO)), toString(mapList.get(j).get(SIGLA))), fontCorpo)); cellDados.setPaddingBottom(pad); cellDados.setVerticalAlignment(Element.ALIGN_MIDDLE); cellDados.setPaddingTop(pad); pTableDados.addCell(cellDados); toPa += toDouble(mapList.get(j).get(VALORPAGAMENTO)); } // 5.6f,5.6f,53.5f,17.95f,19.45f PdfPTable pTableRodape = new PdfPTable(new float[] { 5.6f, 6.05f, 19.795f, 33.705f, 17.95f, 19f }); pTableRodape.setWidthPercentage(95f); cellDados = new PdfPCell(new Phrase(" ", fontCorpoNG)); pTableRodape.addCell(cellDados); cellDados = new PdfPCell(new Phrase("CODE", fontCorpoNG)); pTableRodape.addCell(cellDados); cellDados = new PdfPCell(new Phrase(toString(mapList.get(0).get(DOCFORMAPAGAMENTO)), fontCorpoNG)); pTableRodape.addCell(cellDados); cellDados = new PdfPCell(new Phrase(toString(mapList.get(0).get(DESCRICAOCONTABANCO)), fontCorpoNG)); pTableRodape.addCell(cellDados); cellDados = new PdfPCell(new Phrase("TOTAL", fontCorpoNG)); pTableRodape.addCell(cellDados); cellDados = new PdfPCell(new Phrase(toMoeda(toPa, toString(mapList.get(0).get(SIGLA))), fontCorpoNG)); pTableRodape.addCell(cellDados); documento.add(pTableDados); documento.add(pTableRodape); PdfPTable pTableAssiEstenso = new PdfPTable(new float[] { 100f }); pTableAssiEstenso.setWidthPercentage(95f); PdfPCell cellAssiEstenso = new PdfPCell(); Paragraph pAssiEstenso = new Paragraph(); PdfPTable pTableResposavel = new PdfPTable(new float[] { 70, 30 }); pTableResposavel.setWidthPercentage(100f); PdfPCell cellResposavel = new PdfPCell(); cellResposavel .addElement(new Phrase("Requested by:_________________________________________", fontCorpoN)); cellResposavel.setPaddingTop(10f); cellResposavel.setPaddingBottom(20f); cellResposavel.setBorder(0); pTableResposavel.addCell(cellResposavel); cellResposavel = new PdfPCell(); cellResposavel.addElement(new Phrase(" HOD:___________________", fontCorpoN)); cellResposavel.setPaddingTop(10f); cellResposavel.setPaddingBottom(20f); cellResposavel.setBorder(0); pTableResposavel.addCell(cellResposavel); cellResposavel = new PdfPCell(); cellResposavel .addElement(new Phrase("Approveds by:_________________________________________", fontCorpoN)); cellResposavel.setPaddingTop(-5f); cellResposavel.setPaddingBottom(20f); cellResposavel.setBorder(0); pTableResposavel.addCell(cellResposavel); cellResposavel = new PdfPCell(); cellResposavel.addElement(new Phrase(" Date:___________________", fontCorpoN)); cellResposavel.setPaddingTop(-5f); cellResposavel.setPaddingBottom(20f); cellResposavel.setBorder(0); pTableResposavel.addCell(cellResposavel); pAssiEstenso.add(pTableResposavel); cellAssiEstenso.addElement(pAssiEstenso); PdfPTable pTableExteso = new PdfPTable(new float[] { 25f, 75f }); pTableExteso.setWidthPercentage(100f); JTextPane jtp = new JTextPane(); Moeda.EscreverEstenso(toPa, jtp, ((mapList.size() > 0) ? toString(mapList.get(0).get(MOEDA)) : "")); PdfPCell cellExteso = new PdfPCell(new Phrase("Recived the sum of", fontCorpoN)); cellExteso.setBorder(0); pTableExteso.addCell(cellExteso); cellExteso = new PdfPCell(new Phrase(jtp.getText().toUpperCase().trim(), fontCorpoU)); cellExteso.setBorder(0); pTableExteso.addCell(cellExteso); pAssiEstenso.add(pTableExteso); PdfPTable pTableAss = new PdfPTable(new float[] { 45f, 55f }); pTableAss.setWidthPercentage(100f); PdfPCell cellAss = new PdfPCell(new Phrase(" ______________", fontCorpoN)); cellAss.setPaddingTop(15f); cellAss.setHorizontalAlignment(Element.ALIGN_CENTER); cellAss.setBorder(0); cellAss.setPaddingBottom(0f); pTableAss.addCell(cellAss); cellAss = new PdfPCell(new Phrase(" ____________________________________________", fontCorpoN)); cellAss.setPaddingTop(15f); cellAss.setPaddingBottom(0f); cellAss.setHorizontalAlignment(Element.ALIGN_CENTER); cellAss.setBorder(0); pTableAss.addCell(cellAss); cellAss = new PdfPCell(new Phrase("Date", fontCorpoN)); cellAss.setHorizontalAlignment(Element.ALIGN_CENTER); cellAss.setBorder(0); pTableAss.addCell(cellAss); cellAss = new PdfPCell(new Phrase("Receiver name & signature", fontCorpoN)); cellAss.setHorizontalAlignment(Element.ALIGN_CENTER); cellAss.setBorder(0); pTableAss.addCell(cellAss); pTableAss.setHorizontalAlignment(Element.ALIGN_CENTER); pAssiEstenso.add(pTableAss); pAssiEstenso.setAlignment(Element.ALIGN_CENTER); pAssiEstenso.add(new Phrase( "NOTA: Um recibo oficial pode ser obtido por um pagamento e informado na parte inversa deste comprovativo.\n\n", fontCorpoN)); cellAssiEstenso = new PdfPCell(); cellAssiEstenso.addElement(pAssiEstenso); pTableAssiEstenso.addCell(cellAssiEstenso); documento.add(pTableAssiEstenso); documento.close(); reString = "../Documentos/" + user + "/Pagamentos/" + "Pagamentos Func " + Ddata + ".pdf"; return reString; } catch (FileNotFoundException | DocumentException ex) { Logger.getLogger(FuncPagamento.class.getName()).log(Level.SEVERE, null, ex); } return reString; }
From source file:Export.GrossSarary.java
public static void criaDoc(String user) { OutputStream outputStraem;/*from w ww . j a va2s .co m*/ try { Font fontCabecalhoN = FontFactory.getFont(ConfigDoc.Fontes.FONTB, BaseFont.WINANSI, BaseFont.EMBEDDED, 10f); Font fontCorpo = FontFactory.getFont(ConfigDoc.Fontes.FONT, BaseFont.WINANSI, BaseFont.EMBEDDED, 9f); Font fontCorpoBP = FontFactory.getFont(ConfigDoc.Fontes.FONTB, BaseFont.WINANSI, BaseFont.EMBEDDED, 9f); Font fontCorpoN = FontFactory.getFont(ConfigDoc.Fontes.FONTB, BaseFont.WINANSI, BaseFont.EMBEDDED, 9.5f); Font fontCorpoNG = FontFactory.getFont(ConfigDoc.Fontes.FONTB, BaseFont.WINANSI, BaseFont.EMBEDDED, 13f); Font fontCorpoTitile = FontFactory.getFont(ConfigDoc.Fontes.FONTB, BaseFont.WINANSI, BaseFont.EMBEDDED, 11f); Font fontCabecalhoNG = FontFactory.getFont(ConfigDoc.Fontes.FONTB, BaseFont.WINANSI, BaseFont.EMBEDDED, 16f, Font.UNDERLINE); SimpleDateFormat sdf1 = new SimpleDateFormat("dd-MM-yyyy hh'.'mm'.'ss"); File ff = new File(ConfigDoc.Fontes.getDiretorio() + "/" + user + "/Relatorio"); ff.mkdirs(); String Ddata = sdf1.format(new Date()); ff = new File(ff.getAbsoluteFile() + "/" + "Gross Salary " + Ddata + ".pdf"); outputStraem = new FileOutputStream(ff); String reString = "../Documentos/" + user + "/Relatorio/Gross Salary " + Ddata + ".pdf"; PdfPTable pTableEmpresaPricipal = new PdfPTable(new float[] { 15f, 85f }); PdfPTable pTableEmpresaInforImpres1 = new PdfPTable(1); PdfPTable pTableEmpresaInforImpres5 = new PdfPTable(1); PdfPTable pTableNull = new PdfPTable(1); PdfPCell cellNull = new PdfPCell(new Phrase(" ", fontCorpo)); cellNull.setBorder(0); pTableNull.addCell(cellNull); PdfPCell pCellNomeEmpresa = new PdfPCell(new Phrase(ConfigDoc.Empresa.NOME, fontCabecalhoNG)); pCellNomeEmpresa.setBorder(0); PdfPCell pCellNomeEndereco = new PdfPCell(new Phrase(ConfigDoc.Empresa.ENDERECO, fontCabecalhoN)); pCellNomeEndereco.setBorder(0); PdfPCell pCellCaixaPostal = new PdfPCell(new Phrase(ConfigDoc.Empresa.CAIXAPOSTAL, fontCabecalhoN)); pCellCaixaPostal.setBorder(0); PdfPCell pCellTeleFax = new PdfPCell( new Phrase(ConfigDoc.Empresa.TELEFAX + " " + ConfigDoc.Empresa.EMAIL, fontCabecalhoN)); pCellTeleFax.setBorder(0); PdfPCell pCellSociedade = new PdfPCell(new Phrase(ConfigDoc.Empresa.SOCIEDADE, fontCabecalhoN)); pCellSociedade.setBorder(0); Image imageEmpresa = Image.getInstance("logo.png"); imageEmpresa.scaleToFit(120f, 85f); pTableEmpresaInforImpres1.addCell(pCellNomeEmpresa); pTableEmpresaInforImpres1.addCell(pCellNomeEndereco); pTableEmpresaInforImpres1.addCell(pCellCaixaPostal); pTableEmpresaInforImpres1.addCell(pCellTeleFax); pTableEmpresaInforImpres1.addCell(pCellSociedade); PdfPCell cellTabela3 = new PdfPCell(pTableEmpresaInforImpres1); cellTabela3.setBorder(0); pTableEmpresaInforImpres5.addCell(cellTabela3); PdfPCell cellTabela5 = new PdfPCell(pTableEmpresaInforImpres5); cellTabela5.setBorder(0); PdfPCell cellTabela6 = new PdfPCell(imageEmpresa); cellTabela6.setBorder(0); pTableEmpresaPricipal.setWidthPercentage(97); pTableEmpresaPricipal.addCell(cellTabela6); pTableEmpresaPricipal.addCell(cellTabela5); Document documento = new Document(PageSize.A4.rotate()); PdfWriter writer = PdfWriter.getInstance(documento, outputStraem); //Table Principal PdfPTable pTableTitile = new PdfPTable(new float[] { 100 }); PdfPTable pTableTablePrincipal = new PdfPTable( new float[] { 16.875f, 11.875f, 11.875f, 11.875f, 11.875f, 11.875f, 11.875f, 11.875f }); pTableTablePrincipal.setWidthPercentage(100f); PdfPCell pCellTable = new PdfPCell(new Phrase("Categoria".toUpperCase(), fontCorpoTitile)); pCellTable.setHorizontalAlignment(PdfPCell.ALIGN_CENTER); pCellTable.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE); pTableTablePrincipal.addCell(pCellTable); //Table principal PdfPTable tableCell; for (int i = 1; i <= 7; i++) { tableCell = new PdfPTable(new float[] { 100 }); pCellTable = new PdfPCell(new Phrase("NIVEL", fontCorpoTitile)); pCellTable.setHorizontalAlignment(PdfPCell.ALIGN_CENTER); tableCell.addCell(pCellTable); pCellTable = new PdfPCell(new Phrase(i + "", fontCorpoTitile)); pCellTable.setHorizontalAlignment(PdfPCell.ALIGN_CENTER); tableCell.addCell(pCellTable); pTableTablePrincipal.addCell(tableCell); } de = getList(); for (DadosEstrutura de1 : de) { pCellTable = new PdfPCell(new Phrase(de1.categoria, fontCorpoN)); pCellTable.setHorizontalAlignment(PdfPCell.ALIGN_LEFT); pTableTablePrincipal.addCell(pCellTable); pCellTable = new PdfPCell(new Phrase(de1.set1, fontCorpo)); pCellTable.setHorizontalAlignment(PdfPCell.ALIGN_RIGHT); pTableTablePrincipal.addCell(pCellTable); pCellTable = new PdfPCell(new Phrase(de1.set2, fontCorpo)); pCellTable.setHorizontalAlignment(PdfPCell.ALIGN_RIGHT); pTableTablePrincipal.addCell(pCellTable); pCellTable = new PdfPCell(new Phrase(de1.set3, fontCorpo)); pCellTable.setHorizontalAlignment(PdfPCell.ALIGN_RIGHT); pTableTablePrincipal.addCell(pCellTable); pCellTable = new PdfPCell(new Phrase(de1.set4, fontCorpo)); pCellTable.setHorizontalAlignment(PdfPCell.ALIGN_RIGHT); pTableTablePrincipal.addCell(pCellTable); pCellTable = new PdfPCell(new Phrase(de1.set5, fontCorpo)); pCellTable.setHorizontalAlignment(PdfPCell.ALIGN_RIGHT); pTableTablePrincipal.addCell(pCellTable); pCellTable = new PdfPCell(new Phrase(de1.set6, fontCorpo)); pCellTable.setHorizontalAlignment(PdfPCell.ALIGN_RIGHT); pTableTablePrincipal.addCell(pCellTable); pCellTable = new PdfPCell(new Phrase(de1.set7, fontCorpo)); pCellTable.setHorizontalAlignment(PdfPCell.ALIGN_RIGHT); pTableTablePrincipal.addCell(pCellTable); } //Titulo de Table pCellTable = new PdfPCell(new Phrase("Estrutura de salrio Grosso".toUpperCase(), fontCorpoNG)); pCellTable.setHorizontalAlignment(PdfPCell.ALIGN_CENTER); pCellTable.setBorder(PdfPCell.NO_BORDER); pCellTable.setPadding(15f); pTableTitile.addCell(pCellTable); pCellTable = new PdfPCell(new Phrase("Mensal".toUpperCase(), fontCorpoNG)); pCellTable.setHorizontalAlignment(PdfPCell.ALIGN_CENTER); pCellTable.setBorder(PdfPCell.NO_BORDER); pTableTitile.addCell(pCellTable); @SuppressWarnings("UnusedAssignment") PdfPTable pTableInf = null; PdfPTable pTableInfTile = new PdfPTable(new float[] { 6, 18.5f, 18.5f, 18.5f, 18f, 20f }); PdfPTable pTableInfReal = new PdfPTable(new float[] { 100f }); pTableInfTile.setWidthPercentage(95f); pTableInfReal.setWidthPercentage(95f); pTableInfTile.setHorizontalAlignment(PdfPTable.ALIGN_CENTER); pTableInfReal.setHorizontalAlignment(PdfPTable.ALIGN_CENTER); pCellTable = new PdfPCell(new Phrase("NIVEL", fontCorpoN)); pCellTable.setHorizontalAlignment(PdfPCell.ALIGN_CENTER); pCellTable.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE); pTableInfTile.addCell(pCellTable); pCellTable = new PdfPCell(new Phrase("SAL?RIO BASE", fontCorpoN)); pCellTable.setHorizontalAlignment(PdfPCell.ALIGN_CENTER); pCellTable.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE); pTableInfTile.addCell(pCellTable); pCellTable = new PdfPCell(new Phrase("SUBSIDIO ALMOO", fontCorpoN)); pCellTable.setHorizontalAlignment(PdfPCell.ALIGN_CENTER); pCellTable.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE); pTableInfTile.addCell(pCellTable); pCellTable = new PdfPCell(new Phrase("SUBSIDIO ALOGAMENTO", fontCorpoN)); pCellTable.setHorizontalAlignment(PdfPCell.ALIGN_CENTER); pCellTable.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE); pTableInfTile.addCell(pCellTable); pCellTable = new PdfPCell(new Phrase("SUBSIDIO TRANSPORTE", fontCorpoN)); pCellTable.setHorizontalAlignment(PdfPCell.ALIGN_CENTER); pCellTable.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE); pTableInfTile.addCell(pCellTable); pCellTable = new PdfPCell(new Phrase("TOTAL", fontCorpoN)); pCellTable.setHorizontalAlignment(PdfPCell.ALIGN_CENTER); pCellTable.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE); pTableInfTile.addCell(pCellTable); HashMap<String, ArrayList<Categoria>> outherAr = GrossSarary.getCatList(); int si = outherAr.size(), i = 0; for (Map.Entry<String, ArrayList<Categoria>> eSet : outherAr.entrySet()) { pTableInf = new PdfPTable(new float[] { 6, 18.5f, 18.5f, 18.5f, 18f, 20f }); pTableInf.setWidthPercentage(95f); pTableInf.setHorizontalAlignment(PdfPTable.ALIGN_CENTER); pCellTable = new PdfPCell(new Phrase(eSet.getKey(), fontCorpoNG)); pCellTable.setHorizontalAlignment(PdfPCell.ALIGN_LEFT); pCellTable.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE); pCellTable.setBorder(PdfPCell.NO_BORDER); pCellTable.setColspan(6); pTableInf.addCell(pCellTable); pCellTable = new PdfPCell(new Phrase(" ", fontCorpoN)); pCellTable.setHorizontalAlignment(PdfPCell.ALIGN_CENTER); pCellTable.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE); pCellTable.setColspan(6); pCellTable.setBorder(PdfPCell.NO_BORDER); pTableInf.addCell(pCellTable); pCellTable = new PdfPCell(pTableInfTile); pCellTable.setHorizontalAlignment(PdfPCell.ALIGN_CENTER); pCellTable.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE); pCellTable.setColspan(6); pCellTable.setBorder(PdfPCell.NO_BORDER); pTableInf.addCell(pCellTable); for (Categoria ca : eSet.getValue()) { pCellTable = new PdfPCell(new Phrase(ca.nivel, fontCorpo)); pCellTable.setHorizontalAlignment(PdfPCell.ALIGN_LEFT); pCellTable.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE); pTableInf.addCell(pCellTable); pCellTable = new PdfPCell(new Phrase(toConverterToMoeda(ca.salarioBase), fontCorpo)); pCellTable.setHorizontalAlignment(PdfPCell.ALIGN_RIGHT); pCellTable.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE); pCellTable.setPaddingRight(10f); pTableInf.addCell(pCellTable); pCellTable = new PdfPCell(new Phrase(toConverterToMoeda(ca.subsidioAlmoco), fontCorpo)); pCellTable.setHorizontalAlignment(PdfPCell.ALIGN_RIGHT); pCellTable.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE); pCellTable.setPaddingRight(10f); pTableInf.addCell(pCellTable); pCellTable = new PdfPCell(new Phrase(toConverterToMoeda(ca.subsidioAlogamento), fontCorpo)); pCellTable.setHorizontalAlignment(PdfPCell.ALIGN_RIGHT); pCellTable.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE); pCellTable.setPaddingRight(10f); pTableInf.addCell(pCellTable); pCellTable = new PdfPCell(new Phrase(toConverterToMoeda(ca.subsidioTransporte), fontCorpo)); pCellTable.setHorizontalAlignment(PdfPCell.ALIGN_RIGHT); pCellTable.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE); pCellTable.setPaddingRight(10f); pTableInf.addCell(pCellTable); pCellTable = new PdfPCell(new Phrase(toConverterToMoeda(ca.total), fontCorpo)); pCellTable.setHorizontalAlignment(PdfPCell.ALIGN_RIGHT); pCellTable.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE); pCellTable.setPaddingRight(10f); pTableInf.addCell(pCellTable); } pCellTable = new PdfPCell(new Phrase(" ", fontCorpoN)); pCellTable.setHorizontalAlignment(PdfPCell.ALIGN_CENTER); pCellTable.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE); pCellTable.setBorder(PdfPCell.NO_BORDER); pCellTable.setColspan(6); i++; if (si == i) { pTableInf.addCell(pCellTable); pTableInf.addCell(pCellTable); pTableInf.addCell(pCellTable); } pCellTable = new PdfPCell(pTableInf); pCellTable.setHorizontalAlignment(PdfPCell.ALIGN_CENTER); pCellTable.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE); pCellTable.setBorder(PdfPCell.NO_BORDER); pTableInfReal.addCell(pCellTable); } documento.open(); documento.add(pTableEmpresaPricipal); documento.add(pTableNull); documento.add(pTableTitile); documento.add(pTableNull); documento.add(pTableTablePrincipal); // documento.add(pTableNull); documento.newPage(); documento.add(pTableInfReal); documento.close(); RequestContext.getCurrentInstance().execute("openAllDocument('" + reString + "')"); } catch (FileNotFoundException ex) { Logger.getLogger(GrossSarary.class.getName()).log(Level.SEVERE, null, ex); } catch (BadElementException | IOException ex) { Logger.getLogger(GrossSarary.class.getName()).log(Level.SEVERE, null, ex); } catch (DocumentException ex) { Logger.getLogger(GrossSarary.class.getName()).log(Level.SEVERE, null, ex); } }
From source file:fll.web.playoff.ScoresheetGenerator.java
License:Open Source License
/** * Stores the goal cells that are inserted into the output after the team name * headers and before the scoring/initials blanks at the bottom of the * scoresheet.//from www .j a v a 2 s. c om */ private void setChallengeInfo(final ChallengeDescription description) { setPageTitle(description.getTitle()); if (null != description.getRevision()) { setRevisionInfo(description.getRevision()); } if (null != description.getCopyright()) { m_copyright = description.getCopyright(); } else { m_copyright = null; } final PerformanceScoreCategory performanceElement = description.getPerformance(); // use ArrayList as we will be doing indexed access in the loop final List<AbstractGoal> goals = new ArrayList<>(performanceElement.getGoals()); final float[] relativeWidths = new float[3]; relativeWidths[0] = 4; relativeWidths[1] = 48; relativeWidths[2] = 48; m_goalsTable = new PdfPTable(relativeWidths); String prevCategory = null; for (int goalIndex = 0; goalIndex < goals.size(); ++goalIndex) { final AbstractGoal goal = goals.get(goalIndex); if (!goal.isComputed()) { final String category = goal.getCategory(); // add category cell if needed boolean firstRowInCategory = false; if (!StringUtils.equals(prevCategory, category)) { if (!StringUtils.isEmpty(category)) { // find out how many future goals have the same category int categoryRowSpan = 1; for (int otherIndex = goalIndex + 1; otherIndex < goals.size(); ++otherIndex) { final AbstractGoal otherGoal = goals.get(otherIndex); if (!otherGoal.isComputed()) { if (StringUtils.equals(category, otherGoal.getCategory())) { ++categoryRowSpan; } else { break; } } } final Paragraph catPara = new Paragraph(category, ARIAL_10PT_NORMAL); final PdfPCell categoryCell = new PdfPCell(catPara); categoryCell.setBorderWidthTop(1); categoryCell.setBorderWidthBottom(0); categoryCell.setBorderWidthLeft(0); categoryCell.setBorderWidthRight(0); categoryCell.setVerticalAlignment(Element.ALIGN_CENTER); categoryCell.setHorizontalAlignment(Element.ALIGN_CENTER); categoryCell.setRotation(90); categoryCell.setRowspan(categoryRowSpan); m_goalsTable.addCell(categoryCell); } // first row in a new category, which may be empty firstRowInCategory = true; } // This is the text for the left hand "label" cell final String title = goal.getTitle(); final Paragraph p = new Paragraph(title, ARIAL_10PT_NORMAL); final PdfPCell goalLabel = new PdfPCell(p); goalLabel.setHorizontalAlignment(Element.ALIGN_RIGHT); goalLabel.setVerticalAlignment(Element.ALIGN_CENTER); if (firstRowInCategory) { goalLabel.setBorderWidthTop(1); goalLabel.setBorderWidthBottom(0); goalLabel.setBorderWidthLeft(0); goalLabel.setBorderWidthRight(0); } else { goalLabel.setBorder(0); } goalLabel.setPaddingRight(9); goalLabel.setVerticalAlignment(Element.ALIGN_TOP); if (StringUtils.isEmpty(category)) { // category column and goal label column goalLabel.setColspan(2); } m_goalsTable.addCell(goalLabel); // define the value cell final double min = goal.getMin(); final String minStr = FP.equals(min, Math.round(min), 1E-6) ? String.valueOf((int) min) : String.valueOf(min); final double max = goal.getMax(); final String maxStr = FP.equals(max, Math.round(max), 1E-6) ? String.valueOf((int) max) : String.valueOf(max); // If element has child nodes, then we have an enumerated list // of choices. Otherwise it is either yes/no or a numeric field. final PdfPCell goalValue = new PdfPCell(); final Chunk choices = new Chunk("", COURIER_10PT_NORMAL); if (goal.isEnumerated()) { // replace spaces with "no-break" spaces boolean first = true; final List<EnumeratedValue> values = goal.getSortedValues(); for (final EnumeratedValue value : values) { if (!first) { choices.append(" /" + Utilities.NON_BREAKING_SPACE); } else { first = false; } choices.append(value.getTitle().toUpperCase().replace(' ', Utilities.NON_BREAKING_SPACE)); } goalValue.addElement(choices); } else { if (goal.isYesNo()) { // order of yes/no needs to match ScoreEntry.generateYesNoButtons final Paragraph q = new Paragraph("NO / YES", COURIER_10PT_NORMAL); goalValue.addElement(q); } else { final String range = "(" + minStr + " - " + maxStr + ")"; final PdfPTable t = new PdfPTable(2); t.setHorizontalAlignment(Element.ALIGN_LEFT); t.setTotalWidth(1 * POINTS_PER_INCH); t.setLockedWidth(true); final Phrase r = new Phrase("", ARIAL_8PT_NORMAL); t.addCell(new PdfPCell(r)); final Phrase q = new Phrase(range, ARIAL_8PT_NORMAL); t.addCell(new PdfPCell(q)); goalValue.setPaddingTop(9); goalValue.addElement(t); } } if (firstRowInCategory) { goalValue.setBorderWidthTop(1); goalValue.setBorderWidthBottom(0); goalValue.setBorderWidthLeft(0); goalValue.setBorderWidthRight(0); } else { goalValue.setBorder(0); } goalValue.setVerticalAlignment(Element.ALIGN_MIDDLE); m_goalsTable.addCell(goalValue); // setup for next loop prevCategory = category; } // if not computed goal } // foreach goal }
From source file:frames.main.java
private void jButton13ActionPerformed(java.awt.event.ActionEvent evt) { try {//from w ww . ja v a2 s. com BaseFont unicode = BaseFont.createFont("c:/windows/fonts/ALGER.ttf", BaseFont.IDENTITY_H, BaseFont.EMBEDDED); // Font font11113 = new Font(unicode, 16, Font.BOLD,BaseColor(2,2,2)); ///////////////////////////////////////////////dark brown////////////////////////////////////////////////////// Font font1003 = new Font(unicode, 16, Font.BOLD, new BaseColor(101, 67, 33)); Font font1008 = new Font(unicode, 20, Font.BOLD, new BaseColor(101, 67, 33)); ///////////////////////////////////// ///////////////////////////////////////////////dark red////////////////////////////////////////////////////// Font font1004 = new Font(unicode, 14, Font.BOLD, new BaseColor(139, 0, 0)); Font font1005 = new Font(unicode, 14, Font.BOLD, new BaseColor(255, 0, 0)); ///////////////////////////////////// Font font100 = new Font(unicode, 8, Font.ITALIC, BaseColor.BLUE); Document document = new Document(); PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("SMART-TC.pdf")); document.open(); PdfContentByte cb = writer.getDirectContent(); Font font111 = new Font(Font.FontFamily.COURIER, 16, Font.BOLD, BaseColor.ORANGE); com.itextpdf.text.Image image2 = com.itextpdf.text.Image .getInstance("C:\\smart kid\\src\\frames\\logo.jpg"); image2.scaleAbsolute(125f, 125f); image2.setAbsolutePosition(31, 700); document.add(image2); com.itextpdf.text.Image ing = com.itextpdf.text.Image.getInstance("C:\\smart kid\\src\\frames\\BC.jpg"); ing.setAbsolutePosition(1, 200); document.add(ing); Font font1111 = new Font(unicode, 16, Font.BOLD, BaseColor.ORANGE); Font font11111 = new Font(unicode, 14, Font.BOLD, BaseColor.ORANGE); java.awt.Font awtPlainFont = new java.awt.Font("ALGERIAN", java.awt.Font.PLAIN, 10); document.add(new Paragraph(" SMART KIDS CONVENT SCHOOL", font1008)); document.add(new Paragraph( " HEERA NAGAR (GURGAON) ", font1003)); document.add( new Chunk(" SCHOLOR'S REGISTER AND TRANSFER CERTIFICATE", font1005)); document.add(new Paragraph(" ")); document.add(new Paragraph( "----------------------------------------------------------------------------------------------------------------------------------")); document.add(new Paragraph(" ", font111)); Font font41 = new Font(Font.FontFamily.HELVETICA, 9, Font.BOLD, new BaseColor(0, 0, 0)); Font font23 = new Font(Font.FontFamily.HELVETICA, 12, Font.BOLD, new BaseColor(92, 64, 51)); Font font1 = new Font(Font.FontFamily.HELVETICA, 10, Font.BOLD, new BaseColor(0, 0, 0)); Font font11 = new Font(Font.FontFamily.HELVETICA, 12, Font.ITALIC, new BaseColor(148, 0, 211)); Font font31 = new Font(Font.FontFamily.HELVETICA, 10, Font.BOLD, new BaseColor(990000)); Font font2 = new Font(Font.FontFamily.COURIER, 18, Font.ITALIC | Font.UNDERLINE); Font font3 = new Font(Font.FontFamily.HELVETICA, 10, Font.BOLD, new BaseColor(255, 255, 200)); document.add(new Paragraph( "Ref No: " + TC16.getText() + " " + new java.util.Date().toString(), FontFactory.getFont(FontFactory.COURIER, 12, Font.NORMAL, BaseColor.BLACK))); document.add(new Paragraph(" ")); String ho4 = TC1.getText(); Paragraph p1 = new Paragraph(); p1.add(new Chunk("NAME OF STUDENT :", FontFactory.getFont(FontFactory.COURIER, 12, Font.NORMAL, BaseColor.BLACK))); p1.add(new Chunk(ho4, font11)); document.add(p1); String ho5 = TC2.getText(); Paragraph p2 = new Paragraph(); p2.add(new Chunk("FATHER'S NAME :", FontFactory.getFont(FontFactory.COURIER, 12, Font.NORMAL, BaseColor.BLACK))); p2.add(new Chunk(ho5, font11)); document.add(p2); String ho6 = TC3.getText(); Paragraph p93 = new Paragraph(); p93.add(new Chunk("MOTHER'S NAME :", FontFactory.getFont(FontFactory.COURIER, 12, Font.NORMAL, BaseColor.BLACK))); p93.add(new Chunk(ho6, font11)); document.add(p93); Font font15 = new Font(Font.FontFamily.HELVETICA, 10, Font.BOLD, new BaseColor(0, 0, 0)); String ho8 = TC1.getText(); String tt = TC4.getText(); Paragraph p4 = new Paragraph(); p4.add(new Chunk("RELIGION :", FontFactory.getFont(FontFactory.COURIER, 12, Font.NORMAL, BaseColor.BLACK))); p4.add(new Chunk(tt, font11)); document.add(p4); // document.add(new Paragraph(" ",font1003)); String kk = TC5.getText(); Paragraph p5 = new Paragraph(); p5.add(new Chunk("CASTE OF SCHOLOR :", FontFactory.getFont(FontFactory.COURIER, 12, Font.NORMAL, BaseColor.BLACK))); p5.add(new Chunk(kk, font11)); document.add(p5); String ho10 = TC10.getText(); Paragraph p6 = new Paragraph(); p6.add(new Chunk("ADDRESS :", FontFactory.getFont(FontFactory.COURIER, 12, Font.NORMAL, BaseColor.BLACK))); p6.add(new Chunk(ho10, font11)); document.add(p6); Paragraph p8 = new Paragraph(); p8.add(new Chunk("DATE OF BIRTH :", FontFactory.getFont(FontFactory.COURIER, 12, Font.NORMAL, BaseColor.BLACK))); p8.add(new Chunk(TC9.getText(), font11)); document.add(p8); Paragraph p9 = new Paragraph(); p9.add(new Chunk("SECTION :", FontFactory.getFont(FontFactory.COURIER, 12, Font.NORMAL, BaseColor.BLACK))); p9.add(new Chunk(TC7.getText(), font11)); document.add(p9); Paragraph p10 = new Paragraph(); p10.add(new Chunk("REGISTRATION NO: :", FontFactory.getFont(FontFactory.COURIER, 12, Font.NORMAL, BaseColor.BLACK))); p10.add(new Chunk(TC8.getText(), font11)); document.add(p10); document.add(new Paragraph(" ")); PdfPTable table = new PdfPTable(8); String vacume = ""; table.addCell("Class"); table.addCell("Date of Admission"); table.addCell("Date of Promotion"); table.addCell("Date of Removal"); table.addCell("Cause of Removal"); table.addCell("Year"); table.addCell("Conduct and Work"); table.addCell("Sign"); PdfPCell cell10 = new PdfPCell(new Paragraph("NURSERY", font100)); table.addCell(cell10); if (TC6.getSelectedIndex() == 0) { PdfPCell cell11 = new PdfPCell(new Paragraph(TC11.getText(), font100)); PdfPCell cell12 = new PdfPCell( new Paragraph(((JTextField) TC12.getDateEditor().getUiComponent()).getText(), font100)); PdfPCell cell13 = new PdfPCell( new Paragraph(((JTextField) TC13.getDateEditor().getUiComponent()).getText(), font100)); ; PdfPCell cell14 = new PdfPCell(new Paragraph(TC14.getText(), font100)); PdfPCell cell15 = new PdfPCell(new Paragraph((String) TC15.getSelectedItem(), font100)); PdfPCell cell16 = new PdfPCell(new Paragraph(TC17.getText(), font100)); table.addCell(cell11); table.addCell(cell12); table.addCell(cell13); table.addCell(cell14); table.addCell(cell15); table.addCell(cell16); table.addCell(""); } else { for (int i = 0; i < 7; i++) table.addCell(vacume); } PdfPCell cell111 = new PdfPCell(new Paragraph("LKG", font100)); table.addCell(cell111); if (TC6.getSelectedIndex() == 1) { PdfPCell cell11 = new PdfPCell(new Paragraph(TC11.getText(), font100)); PdfPCell cell12 = new PdfPCell( new Paragraph(((JTextField) TC12.getDateEditor().getUiComponent()).getText(), font100)); PdfPCell cell13 = new PdfPCell( new Paragraph(((JTextField) TC13.getDateEditor().getUiComponent()).getText(), font100)); ; PdfPCell cell14 = new PdfPCell(new Paragraph(TC14.getText(), font100)); PdfPCell cell15 = new PdfPCell(new Paragraph((String) TC15.getSelectedItem(), font100)); PdfPCell cell16 = new PdfPCell(new Paragraph(TC17.getText(), font100)); table.addCell(cell11); table.addCell(cell12); table.addCell(cell13); table.addCell(cell14); table.addCell(cell15); table.addCell(cell16); table.addCell(""); } else { for (int i = 0; i < 7; i++) table.addCell(vacume); } PdfPCell cell1 = new PdfPCell(new Paragraph("UKG", font100)); table.addCell(cell1); if (TC6.getSelectedIndex() == 2) { PdfPCell cell11 = new PdfPCell(new Paragraph(TC11.getText(), font100)); PdfPCell cell12 = new PdfPCell( new Paragraph(((JTextField) TC12.getDateEditor().getUiComponent()).getText(), font100)); PdfPCell cell13 = new PdfPCell( new Paragraph(((JTextField) TC13.getDateEditor().getUiComponent()).getText(), font100)); ; PdfPCell cell14 = new PdfPCell(new Paragraph(TC14.getText(), font100)); PdfPCell cell15 = new PdfPCell(new Paragraph((String) TC15.getSelectedItem(), font100)); PdfPCell cell16 = new PdfPCell(new Paragraph(TC17.getText(), font100)); table.addCell(cell11); table.addCell(cell12); table.addCell(cell13); table.addCell(cell14); table.addCell(cell15); table.addCell(cell16); table.addCell(""); } else { for (int i = 0; i < 7; i++) table.addCell(vacume); } PdfPCell cell2 = new PdfPCell(new Paragraph("STD-1", font100)); table.addCell(cell2); if (TC6.getSelectedIndex() == 3) { PdfPCell cell11 = new PdfPCell(new Paragraph(TC11.getText(), font100)); PdfPCell cell12 = new PdfPCell( new Paragraph(((JTextField) TC12.getDateEditor().getUiComponent()).getText(), font100)); PdfPCell cell13 = new PdfPCell( new Paragraph(((JTextField) TC13.getDateEditor().getUiComponent()).getText(), font100)); ; PdfPCell cell14 = new PdfPCell(new Paragraph(TC14.getText(), font100)); PdfPCell cell15 = new PdfPCell(new Paragraph((String) TC15.getSelectedItem(), font100)); PdfPCell cell16 = new PdfPCell(new Paragraph(TC17.getText(), font100)); table.addCell(cell11); table.addCell(cell12); table.addCell(cell13); table.addCell(cell14); table.addCell(cell15); table.addCell(cell16); table.addCell(""); } else { for (int i = 0; i < 7; i++) table.addCell(vacume); } PdfPCell cell3 = new PdfPCell(new Paragraph("STD-2", font100)); table.addCell(cell3); if (TC6.getSelectedIndex() == 4) { PdfPCell cell11 = new PdfPCell(new Paragraph(TC11.getText(), font100)); PdfPCell cell12 = new PdfPCell( new Paragraph(((JTextField) TC12.getDateEditor().getUiComponent()).getText(), font100)); PdfPCell cell13 = new PdfPCell( new Paragraph(((JTextField) TC13.getDateEditor().getUiComponent()).getText(), font100)); ; PdfPCell cell14 = new PdfPCell(new Paragraph(TC14.getText(), font100)); PdfPCell cell15 = new PdfPCell(new Paragraph((String) TC15.getSelectedItem(), font100)); PdfPCell cell16 = new PdfPCell(new Paragraph(TC17.getText(), font100)); table.addCell(cell11); table.addCell(cell12); table.addCell(cell13); table.addCell(cell14); table.addCell(cell15); table.addCell(cell16); table.addCell(""); } else { for (int i = 0; i < 7; i++) table.addCell(vacume); } PdfPCell cell4 = new PdfPCell(new Paragraph("STD-3", font100)); table.addCell(cell4); if (TC6.getSelectedIndex() == 5) { PdfPCell cell11 = new PdfPCell(new Paragraph(TC11.getText(), font100)); PdfPCell cell12 = new PdfPCell( new Paragraph(((JTextField) TC12.getDateEditor().getUiComponent()).getText(), font100)); PdfPCell cell13 = new PdfPCell( new Paragraph(((JTextField) TC13.getDateEditor().getUiComponent()).getText(), font100)); ; PdfPCell cell14 = new PdfPCell(new Paragraph(TC14.getText(), font100)); PdfPCell cell15 = new PdfPCell(new Paragraph((String) TC15.getSelectedItem(), font100)); PdfPCell cell16 = new PdfPCell(new Paragraph(TC17.getText(), font100)); table.addCell(cell11); table.addCell(cell12); table.addCell(cell13); table.addCell(cell14); table.addCell(cell15); table.addCell(cell16); table.addCell(""); } else { for (int i = 0; i < 7; i++) table.addCell(vacume); } PdfPCell cell5 = new PdfPCell(new Paragraph("STD-4", font100)); table.addCell(cell5); if (TC6.getSelectedIndex() == 6) { PdfPCell cell11 = new PdfPCell(new Paragraph(TC11.getText(), font100)); PdfPCell cell12 = new PdfPCell( new Paragraph(((JTextField) TC12.getDateEditor().getUiComponent()).getText(), font100)); PdfPCell cell13 = new PdfPCell( new Paragraph(((JTextField) TC13.getDateEditor().getUiComponent()).getText(), font100)); ; PdfPCell cell14 = new PdfPCell(new Paragraph(TC14.getText(), font100)); PdfPCell cell15 = new PdfPCell(new Paragraph((String) TC15.getSelectedItem(), font100)); PdfPCell cell16 = new PdfPCell(new Paragraph(TC17.getText(), font100)); table.addCell(cell11); table.addCell(cell12); table.addCell(cell13); table.addCell(cell14); table.addCell(cell15); table.addCell(cell16); table.addCell(""); } else { for (int i = 0; i < 7; i++) table.addCell(vacume); } PdfPCell cell6 = new PdfPCell(new Paragraph("STD-5", font100)); table.addCell(cell6); if (TC6.getSelectedIndex() == 7) { PdfPCell cell11 = new PdfPCell(new Paragraph(TC11.getText(), font100)); PdfPCell cell12 = new PdfPCell( new Paragraph(((JTextField) TC12.getDateEditor().getUiComponent()).getText(), font100)); PdfPCell cell13 = new PdfPCell( new Paragraph(((JTextField) TC13.getDateEditor().getUiComponent()).getText(), font100)); ; PdfPCell cell14 = new PdfPCell(new Paragraph(TC14.getText(), font100)); PdfPCell cell15 = new PdfPCell(new Paragraph((String) TC15.getSelectedItem(), font100)); PdfPCell cell16 = new PdfPCell(new Paragraph(TC17.getText(), font100)); table.addCell(cell11); table.addCell(cell12); table.addCell(cell13); table.addCell(cell14); table.addCell(cell15); table.addCell(cell16); table.addCell(""); } else { for (int i = 0; i < 7; i++) table.addCell(vacume); } PdfPCell cell8 = new PdfPCell(new Paragraph("STD-6", font100)); table.addCell(cell8); if (TC6.getSelectedIndex() == 8) { PdfPCell cell11 = new PdfPCell(new Paragraph(TC11.getText(), font100)); PdfPCell cell12 = new PdfPCell( new Paragraph(((JTextField) TC12.getDateEditor().getUiComponent()).getText(), font100)); PdfPCell cell13 = new PdfPCell( new Paragraph(((JTextField) TC13.getDateEditor().getUiComponent()).getText(), font100)); ; PdfPCell cell14 = new PdfPCell(new Paragraph(TC14.getText(), font100)); PdfPCell cell15 = new PdfPCell(new Paragraph((String) TC15.getSelectedItem(), font100)); PdfPCell cell16 = new PdfPCell(new Paragraph(TC17.getText(), font100)); table.addCell(cell11); table.addCell(cell12); table.addCell(cell13); table.addCell(cell14); table.addCell(cell15); table.addCell(cell16); table.addCell(""); } else { for (int i = 0; i < 7; i++) table.addCell(vacume); } PdfPCell cell9 = new PdfPCell(new Paragraph("STD-7", font100)); table.addCell(cell9); if (TC6.getSelectedIndex() == 9) { PdfPCell cell11 = new PdfPCell(new Paragraph(TC11.getText(), font100)); PdfPCell cell12 = new PdfPCell( new Paragraph(((JTextField) TC12.getDateEditor().getUiComponent()).getText(), font100)); PdfPCell cell13 = new PdfPCell( new Paragraph(((JTextField) TC13.getDateEditor().getUiComponent()).getText(), font100)); ; PdfPCell cell14 = new PdfPCell(new Paragraph(TC14.getText(), font100)); PdfPCell cell15 = new PdfPCell(new Paragraph((String) TC15.getSelectedItem(), font100)); PdfPCell cell16 = new PdfPCell(new Paragraph(TC17.getText(), font100)); table.addCell(cell11); table.addCell(cell12); table.addCell(cell13); table.addCell(cell14); table.addCell(cell15); table.addCell(cell16); table.addCell(""); } else { for (int i = 0; i < 7; i++) table.addCell(vacume); } PdfPCell cell18 = new PdfPCell(new Paragraph("STD-8", font100)); table.addCell(cell18); if (TC6.getSelectedIndex() == 2) { PdfPCell cell11 = new PdfPCell(new Paragraph(TC11.getText(), font100)); PdfPCell cell12 = new PdfPCell( new Paragraph(((JTextField) TC12.getDateEditor().getUiComponent()).getText(), font100)); PdfPCell cell13 = new PdfPCell( new Paragraph(((JTextField) TC13.getDateEditor().getUiComponent()).getText(), font100)); ; PdfPCell cell14 = new PdfPCell(new Paragraph(TC14.getText(), font100)); PdfPCell cell15 = new PdfPCell(new Paragraph((String) TC15.getSelectedItem(), font100)); PdfPCell cell16 = new PdfPCell(new Paragraph(TC17.getText(), font100)); table.addCell(cell11); table.addCell(cell12); table.addCell(cell13); table.addCell(cell14); table.addCell(cell15); table.addCell(cell16); table.addCell(""); } else { for (int i = 0; i < 7; i++) table.addCell(vacume); } float[] ColumnWidths = new float[] { 8f, 12f, 12f, 12f, 22f, 8f, 15f, 7f }; table.setWidths(ColumnWidths); table.setWidthPercentage(106); table.setHorizontalAlignment(Element.ALIGN_LEFT); document.add(table); document.add(new Paragraph(" ")); document.add(new Paragraph(" ")); document.add(new Paragraph( "1. I certified that the entries as regard details of the student have been duly checked from the 'Admission form' and that they are complete.", FontFactory.getFont(FontFactory.TIMES_ROMAN, 10, Font.NORMAL, BaseColor.BLACK))); // document.add(new Paragraph(" ")); document.add(new Paragraph(" ")); document.add(new Paragraph( "2. Certified that the above Students register have been posted up-to date of students leaving as required by the departmental rules.", FontFactory.getFont(FontFactory.TIMES_ROMAN, 10, Font.NORMAL, BaseColor.BLACK))); document.add(new Paragraph(" ")); document.add(new Paragraph(" ")); document.add(new Paragraph( "Prepared by:-" + " " + "Date:-" + " " + new java.util.Date().toString() + " " + "Principal's Sign:-", FontFactory.getFont(FontFactory.TIMES_BOLD, 12, Font.NORMAL, BaseColor.BLACK))); document.add(new Paragraph(" ")); document.add(new Paragraph( "----------------------------------------------------------------------------------------------------------------------------------")); document.add(new Paragraph("An ISO 9001:2008 Certified School(Certificate Number:NOR/0712M/1505)", FontFactory.getFont(FontFactory.COURIER, 12, Font.NORMAL, BaseColor.BLUE))); document.add(new Paragraph("(Run By:Smart Educational Society)Regd.No.(DR/GGN/285)", FontFactory.getFont(FontFactory.COURIER, 12, Font.NORMAL, BaseColor.BLUE))); document.add(new Paragraph( "413A/23,Gali No:-2,Heera Nagar,Near Rajendra Hospital,Khandsa Road,Gurgaon(Haryana)", FontFactory.getFont(FontFactory.COURIER, 10, Font.NORMAL, BaseColor.BLUE))); cb.saveState(); cb.setColorStroke(BaseColor.BLACK); cb.rectangle(2, 2, 588, 828); cb.stroke(); cb.restoreState(); JOptionPane.showMessageDialog(this, "it is saved"); document.close(); } catch (Exception ee) { JOptionPane.showMessageDialog(this, ee); } // TODO add your handling code here: }
From source file:fxml.test.PDFService.java
private PdfPTable createDocumentHeader() throws IOException, BadElementException { //start creating header for the document...... PdfPTable headerTable = new PdfPTable(3); headerTable.setHorizontalAlignment(Element.ALIGN_LEFT); try {/*from w w w .j a va 2 s .c o m*/ headerTable.setTotalWidth(new float[] { 57.5f, 531.5f, 183f }); headerTable.setLockedWidth(true); } catch (DocumentException ex) { Logger.getLogger(PDFService.class.getName()).log(Level.SEVERE, null, ex); } Image image = Image.getInstance(getClass().getClassLoader().getResource("img/sust.jpg")); image.scalePercent(42f); image.setAlignment(Element.ALIGN_LEFT); PdfPCell imageCell = new PdfPCell(image, false); imageCell.setPaddingTop(6); imageCell.setBorder(Rectangle.NO_BORDER); headerTable.addCell(imageCell); //start info table..... PdfPTable infoTable = new PdfPTable(1); infoTable.getDefaultCell().setBorder(Rectangle.NO_BORDER); String universityText = "SHAHJALAL UNIVERSITY OF SCIENCE & TECHNOLOGY SYLHET, BANGLADESH"; String tabulationText = "TABULATION SHEET"; String deptText = inputs.get(0).trim(); String s1 = inputs.get(1).trim(); String s2 = inputs.get(2).trim(); String semesterText = ("B.Sc (Engg.) " + s1 + " SEMESTER EXAMINATION " + s2); String session = inputs.get(3).trim(); String date = inputs.get(4).trim(); String sessionDateText = ("SESSION:" + session + " EXAMINATION HELD IN: " + date); infoTable.addCell(getCellForHeaderString(universityText, 0, false, 0, Element.ALIGN_CENTER, font10, true)); infoTable.addCell(getCellForHeaderString(tabulationText, 0, false, 0, Element.ALIGN_CENTER, font10, false)); infoTable.addCell(getCellForHeaderString(deptText, 0, false, 0, Element.ALIGN_CENTER, font10, false)); infoTable.addCell(getCellForHeaderString(semesterText, 0, false, 0, Element.ALIGN_CENTER, font10, false)); infoTable .addCell(getCellForHeaderString(sessionDateText, 0, false, 0, Element.ALIGN_CENTER, font10, false)); //end info table..... PdfPCell infoCell = new PdfPCell(infoTable); infoCell.setBorder(Rectangle.NO_BORDER); headerTable.addCell(infoCell); PdfPCell resultPublishDateCell = new PdfPCell( new Paragraph("Result Published On............................", new Font(Font.FontFamily.TIMES_ROMAN, 10, Font.BOLD))); resultPublishDateCell.setBorder(Rectangle.NO_BORDER); resultPublishDateCell.setVerticalAlignment(Element.ALIGN_MIDDLE); resultPublishDateCell.setHorizontalAlignment(Element.ALIGN_RIGHT); headerTable.addCell(resultPublishDateCell); headerTable.setSpacingAfter(17.5f); // System.err.println("completed header table"); return headerTable; //end creating header for the document...... }