List of usage examples for com.itextpdf.text BaseColor BLACK
BaseColor BLACK
To view the source code for com.itextpdf.text BaseColor BLACK.
Click Source Link
From source file:br.com.tcc.view.FormaPagamentoView.java
private void btnImprimirActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnImprimirActionPerformed int row = tblRegistro.getSelectedRow(); int id = vendaRegistroList.get(row).getId(); Connection con = new ConnectionFactory().getConnection(); try {//from w w w . j a va2s. c om Statement stmt = con.createStatement(); ResultSet query = stmt.executeQuery( "SELECT produto.descricao, vendadetalhe.qtde, vendadetalhe.vlrUnitario, vendadetalhe.vlrTotal from vendadetalhe as vendadetalhe INNER JOIN produto as produto ON (vendadetalhe.idProduto = produto.ID) where idVendaRegistro = " + id); Document documento = new Document(); SimpleDateFormat horaformatada = new SimpleDateFormat("HH:mm:ss"); Date horaAtual = new Date(); hora = horaformatada.format(horaAtual); Date data = new Date(); // mes = ""+Data.getMonth();//0 a 11 dia = "" + data.getDate(); ano = "" + (1900 + data.getYear()); switch (data.getMonth()) { case 0: mes = "Janeiro"; break; case 1: mes = "Fevereiro"; break; case 2: mes = "Maro"; break; case 3: mes = "Abril"; break; case 4: mes = "Maio"; break; case 5: mes = "Junho"; break; case 6: mes = "Julho"; break; case 7: mes = "Agosto"; break; case 8: mes = "Setembro"; break; case 9: mes = "Outubro"; break; case 10: mes = "Novembro"; break; case 11: mes = "Dezembro"; break; } try { OutputStream outputStream = new FileOutputStream( "C:\\Users\\Leonardo P Souza\\Desktop\\Relat\\Registro da venda " + txtCodigo.getText() + ".pdf"); PdfWriter.getInstance(documento, outputStream); documento.open(); Font fonte = new Font(Font.FontFamily.TIMES_ROMAN, 36, Font.BOLD); Font fonteItem = new Font(Font.FontFamily.COURIER, 28, Font.BOLD); Paragraph cabecalho = new Paragraph("AGRO EMPRESARIAL - SISTEMA DE GERENCIAMENTO\n" + "RUA GONALVES CHAVES, 602 PELOTAS/RS\n" + "FONE:(53) 3232-3232 BAIRRO: CENTRO\n" + "CNPJ: 12.345.678/1011-12\n" + "-------------------------------------------\n" + dia + "/" + mes + "/" + ano + " " + hora + " COD: " + txtCodigo.getText()); cabecalho.setAlignment(Element.ALIGN_CENTER); documento.add(cabecalho); Paragraph paragrafo = new Paragraph("Relatrio da Venda", fonte); paragrafo.setAlignment(Element.ALIGN_CENTER); documento.add(paragrafo); Paragraph paragrafoCliente = new Paragraph("Cliente: " + cbxCliente.getSelectedItem().toString()); documento.add(paragrafoCliente); Paragraph paragrafoFuncionario = new Paragraph( "Funcionrio: " + cbxFuncionario.getSelectedItem().toString()); documento.add(paragrafoFuncionario); Paragraph paragrafoPagamento = new Paragraph( "Tipo de Pagamento: " + cbxTipoPagamento.getSelectedItem().toString()); documento.add(paragrafoPagamento); // Paragraph paragrafoParcela = new Paragraph("Parcelas: " + cbxParcelas.getSelectedItem().toString()); // documento.add(paragrafoParcela); // Paragraph paragrafoValor = new Paragraph("Valor R$: " + txtTotal.getText()); // documento.add(paragrafoValor); if (cbxTipoPagamento.getSelectedItem().toString().equals(" vista") || cbxTipoPagamento.getSelectedItem().toString().equals("C. Debito")) { Paragraph paragrafoValor = new Paragraph("Valor R$: " + txtCompra.getText()); documento.add(paragrafoValor); Paragraph paragrafoAVista = new Paragraph("Valor vista: " + txtTotal.getText()); documento.add(paragrafoAVista); } else { Paragraph paragrafoValor = new Paragraph("Valor R$: " + txtTotal.getText()); documento.add(paragrafoValor); int parcela = Integer.parseInt(cbxParcelas.getSelectedItem().toString()); double valorParcelas = Double.parseDouble(txtTotal.getText()); double total = valorParcelas / parcela; Paragraph paragrafoVezes = new Paragraph( cbxParcelas.getSelectedItem().toString() + " parcelas de R$: " + total); documento.add(paragrafoVezes); } Paragraph quebraLinha = new Paragraph("\n\n"); documento.add(quebraLinha); //we have two columns in our table PdfPTable LogTable = new PdfPTable(4); // Ttulo para a tabela Paragraph tableHeader = new Paragraph("Relatrio de Entrada de Estoque"); PdfPCell header = new PdfPCell(tableHeader); // Definindo que o header vai ocupar as 2 colunas header.setColspan(4); // Definindo alinhamento do header header.setHorizontalAlignment(Paragraph.ALIGN_CENTER); // Adicionando o header tabela Font fonte2 = new Font(Font.FontFamily.HELVETICA, 7, Font.BOLD, BaseColor.BLACK); Font fonteDados = new Font(Font.FontFamily.TIMES_ROMAN, 6, Font.NORMAL, BaseColor.BLACK); LogTable.addCell(header); LogTable.addCell(new Paragraph("Produto ", fonte2)); LogTable.addCell(new Paragraph("Quantidade", fonte2)); LogTable.addCell(new Paragraph("Valor Unitrio", fonte2)); LogTable.addCell(new Paragraph("Valor Total", fonte2)); //create a cell object // PdfPCell table_cell; while (query.next()) { String produto = query.getString("produto.descricao"); LogTable.addCell(new Paragraph(produto, fonteDados)); String quantidade = query.getString("qtde"); LogTable.addCell(new Paragraph(quantidade, fonteDados)); String vlrSugerido = query.getString("vlrUnitario"); LogTable.addCell(new Paragraph(vlrSugerido, fonteDados)); String vlrTotal = query.getString("vlrTotal"); LogTable.addCell(new Paragraph(vlrTotal, fonteDados)); } /* Attach report table to PDF */ documento.add(LogTable); // Paragraph paragrafoItemVenda = new Paragraph("Produtos da venda", fonteItem); // paragrafoItemVenda.setAlignment(Element.ALIGN_CENTER); // documento.add(paragrafoItemVenda); // Paragraph cabecalhoItemVenda = new Paragraph("Produto Qtde. Vlr Unit. Vlr Total"); // documento.add(cabecalhoItemVenda); // vendaDetalheQuery = entityManager.createQuery("from Vendadetalhe where idVendaRegistro=" + txtCodigo.getText()); // Paragraph paragrafoLista = new Paragraph(vendaDetalheQuery.getResultList().toString().substring(1, vendaDetalheQuery.getResultList().toString().length() - 1)); // documento.add(paragrafoLista); documento.close(); String file; file = "C:\\Users\\Leonardo P Souza\\Desktop\\Relat\\Registro da venda " + txtCodigo.getText() + ".pdf"; Runtime.getRuntime().exec("rundll32 SHELL32.DLL,ShellExec_RunDLL " + file); } catch (FileNotFoundException ex) { Logger.getLogger(MovimentoVendaView.class.getName()).log(Level.SEVERE, null, ex); } catch (DocumentException ex) { Logger.getLogger(MovimentoVendaView.class.getName()).log(Level.SEVERE, null, ex); } catch (IOException ex) { Logger.getLogger(FormaPagamentoView.class.getName()).log(Level.SEVERE, null, ex); } } catch (SQLException ex) { Logger.getLogger(FormaPagamentoView.class.getName()).log(Level.SEVERE, null, ex); } }
From source file:br.com.tcc.view.MovimentoEntradaView.java
private void relat(String sql) throws SQLException, DocumentException, FileNotFoundException, IOException { /* Create Connection objects */ Connection con = new ConnectionFactory().getConnection(); Statement stmt = con.createStatement(); int row = tblRegistro.getSelectedRow(); int id = entradaRegistroList.get(row).getId(); SimpleDateFormat horaformatada = new SimpleDateFormat("HH:mm:ss"); Date horaAtual = new Date(); hora = horaformatada.format(horaAtual); Date data = new Date(); // mes = ""+Data.getMonth();//0 a 11 dia = "" + data.getDate(); ano = "" + (1900 + data.getYear()); switch (data.getMonth()) { case 0:/*from w ww.j a v a2s. c om*/ mes = "Janeiro"; break; case 1: mes = "Fevereiro"; break; case 2: mes = "Maro"; break; case 3: mes = "Abril"; break; case 4: mes = "Maio"; break; case 5: mes = "Junho"; break; case 6: mes = "Julho"; break; case 7: mes = "Agosto"; break; case 8: mes = "Setembro"; break; case 9: mes = "Outubro"; break; case 10: mes = "Novembro"; break; case 11: mes = "Dezembro"; break; } /* Define the SQL query */ // sql = "SELECT cliente.nome, funcionario.nome, tipopagamento.descricao, vendaregistro.dataVenda, vendaregistro.vlrSugerido, vendaregistro.totalVenda, vendaregistro.parcela, vendaregistro.1vencimento, vendaregistro.ativo FROM vendaregistro as vendaregistro INNER JOIN cliente as cliente ON (vendaregistro.idCliente = cliente.id) \n" + //"INNER JOIN funcionario as funcionario ON (vendaregistro.idFuncionario = funcionario.id) INNER JOIN tipopagamento as tipopagamento ON (vendaregistro.idTipoPagamento = tipopagamento.id) WHERE dataVenda = CURRENT_DATE"; ResultSet query = stmt.executeQuery(sql); /* Step-2: Initialize PDF documents - logical objects */ Document PDFLogReport = new Document(); PdfWriter.getInstance(PDFLogReport, new FileOutputStream("C:\\Users\\Leonardo P Souza\\Desktop\\Relat\\Entrada " + id + ".pdf")); PDFLogReport.open(); Paragraph cabecalho = new Paragraph("AGRO EMPRESARIAL - SISTEMA DE GERENCIAMENTO\n" + "RUA GONALVES CHAVES, 602 PELOTAS/RS\n" + "FONE:(53) 3232-3232 BAIRRO: CENTRO\n" + "CNPJ: 12.345.678/1011-12\n" + "-------------------------------------------\n" + dia + "/" + mes + "/" + ano + " " + hora + " COD: " + id + " \n\n"); cabecalho.setAlignment(Element.ALIGN_CENTER); PDFLogReport.add(cabecalho); //we have two columns in our table PdfPTable LogTable = new PdfPTable(4); // Ttulo para a tabela Paragraph tableHeader = new Paragraph("Relatrio de Entrada de Estoque"); PdfPCell header = new PdfPCell(tableHeader); // Definindo que o header vai ocupar as 2 colunas header.setColspan(4); // Definindo alinhamento do header header.setHorizontalAlignment(Paragraph.ALIGN_CENTER); // Adicionando o header tabela Font fonte = new Font(Font.FontFamily.HELVETICA, 7, Font.BOLD, BaseColor.BLACK); Font fonteDados = new Font(Font.FontFamily.TIMES_ROMAN, 6, Font.NORMAL, BaseColor.BLACK); LogTable.addCell(header); LogTable.addCell(new Paragraph("Produto ", fonte)); LogTable.addCell(new Paragraph("Quantidade", fonte)); LogTable.addCell(new Paragraph("Valor Unitrio", fonte)); LogTable.addCell(new Paragraph("Valor Total", fonte)); //create a cell object // PdfPCell table_cell; while (query.next()) { String produto = query.getString("produto.descricao"); LogTable.addCell(new Paragraph(produto, fonteDados)); String quantidade = query.getString("qtde"); LogTable.addCell(new Paragraph(quantidade, fonteDados)); String vlrSugerido = query.getString("vlrUnitario"); LogTable.addCell(new Paragraph(vlrSugerido, fonteDados)); String vlrTotal = query.getString("vlrTotal"); LogTable.addCell(new Paragraph(vlrTotal, fonteDados)); } /* Attach report table to PDF */ PDFLogReport.add(LogTable); double valor = entradaRegistroList.get(row).getVlrTotal(); Paragraph paragrafoValor = new Paragraph("Valor R$: " + valor); paragrafoValor.setAlignment(Element.ALIGN_RIGHT); PDFLogReport.add(paragrafoValor); PDFLogReport.close(); /* Close all DB related objects */ query.close(); stmt.close(); con.close(); String file; file = "C:\\Users\\Leonardo P Souza\\Desktop\\Relat\\Entrada " + id + ".pdf"; Runtime.getRuntime().exec("rundll32 SHELL32.DLL,ShellExec_RunDLL " + file); }
From source file:br.com.tcc.view.MovimentoOrcamentoView.java
private void relat(String sql) throws IOException, DocumentException, SQLException { /* Create Connection objects */ Connection con = new ConnectionFactory().getConnection(); Statement stmt = con.createStatement(); int row = tblRegistro.getSelectedRow(); int id = orcamentoRegistroList.get(row).getId(); SimpleDateFormat horaformatada = new SimpleDateFormat("HH:mm:ss"); Date horaAtual = new Date(); hora = horaformatada.format(horaAtual); Date data = new Date(); // mes = ""+Data.getMonth();//0 a 11 dia = "" + data.getDate(); ano = "" + (1900 + data.getYear()); switch (data.getMonth()) { case 0://from w w w.j a v a2 s . c o m mes = "Janeiro"; break; case 1: mes = "Fevereiro"; break; case 2: mes = "Maro"; break; case 3: mes = "Abril"; break; case 4: mes = "Maio"; break; case 5: mes = "Junho"; break; case 6: mes = "Julho"; break; case 7: mes = "Agosto"; break; case 8: mes = "Setembro"; break; case 9: mes = "Outubro"; break; case 10: mes = "Novembro"; break; case 11: mes = "Dezembro"; break; } /* Define the SQL query */ // sql = "SELECT cliente.nome, funcionario.nome, tipopagamento.descricao, vendaregistro.dataVenda, vendaregistro.vlrSugerido, vendaregistro.totalVenda, vendaregistro.parcela, vendaregistro.1vencimento, vendaregistro.ativo FROM vendaregistro as vendaregistro INNER JOIN cliente as cliente ON (vendaregistro.idCliente = cliente.id) \n" + //"INNER JOIN funcionario as funcionario ON (vendaregistro.idFuncionario = funcionario.id) INNER JOIN tipopagamento as tipopagamento ON (vendaregistro.idTipoPagamento = tipopagamento.id) WHERE dataVenda = CURRENT_DATE"; ResultSet query = stmt.executeQuery(sql); /* Step-2: Initialize PDF documents - logical objects */ Document PDFLogReport = new Document(); PdfWriter.getInstance(PDFLogReport, new FileOutputStream("C:\\Users\\Leonardo P Souza\\Desktop\\Relat\\Oramento " + id + ".pdf")); PDFLogReport.open(); Paragraph cabecalho = new Paragraph("AGRO EMPRESARIAL - SISTEMA DE GERENCIAMENTO\n" + "RUA GONALVES CHAVES, 602 PELOTAS/RS\n" + "FONE:(53) 3232-3232 BAIRRO: CENTRO\n" + "CNPJ: 12.345.678/1011-12\n" + "-------------------------------------------\n" + dia + "/" + mes + "/" + ano + " " + hora + " COD: " + id + " \n\n"); cabecalho.setAlignment(Element.ALIGN_CENTER); PDFLogReport.add(cabecalho); //we have two columns in our table PdfPTable LogTable = new PdfPTable(4); // Ttulo para a tabela Paragraph tableHeader = new Paragraph("Oramento"); PdfPCell header = new PdfPCell(tableHeader); // Definindo que o header vai ocupar as 2 colunas header.setColspan(4); // Definindo alinhamento do header header.setHorizontalAlignment(Paragraph.ALIGN_CENTER); // Adicionando o header tabela Font fonte = new Font(Font.FontFamily.HELVETICA, 7, Font.BOLD, BaseColor.BLACK); Font fonteDados = new Font(Font.FontFamily.TIMES_ROMAN, 6, Font.NORMAL, BaseColor.BLACK); LogTable.addCell(header); LogTable.addCell(new Paragraph("Produto ", fonte)); LogTable.addCell(new Paragraph("Quantidade", fonte)); LogTable.addCell(new Paragraph("Valor Unitrio", fonte)); LogTable.addCell(new Paragraph("Valor Total", fonte)); //create a cell object // PdfPCell table_cell; while (query.next()) { String produto = query.getString("produto.descricao"); LogTable.addCell(new Paragraph(produto, fonteDados)); String quantidade = query.getString("qtde"); LogTable.addCell(new Paragraph(quantidade, fonteDados)); String vlrSugerido = query.getString("vlrUnitario"); LogTable.addCell(new Paragraph(vlrSugerido, fonteDados)); String vlrTotal = query.getString("vlrTotal"); LogTable.addCell(new Paragraph(vlrTotal, fonteDados)); } /* Attach report table to PDF */ PDFLogReport.add(LogTable); double valor = orcamentoRegistroList.get(row).getVlrTotalOrcamento(); Paragraph paragrafoValor = new Paragraph("Valor R$: " + valor); paragrafoValor.setAlignment(Element.ALIGN_RIGHT); PDFLogReport.add(paragrafoValor); PDFLogReport.close(); /* Close all DB related objects */ query.close(); stmt.close(); con.close(); String file; file = "C:\\Users\\Leonardo P Souza\\Desktop\\Relat\\Oramento " + id + ".pdf"; Runtime.getRuntime().exec("rundll32 SHELL32.DLL,ShellExec_RunDLL " + file); }
From source file:br.com.tcc.view.MovimentoPedidoView.java
private void relat(String sql) throws SQLException, DocumentException, FileNotFoundException, IOException { /* Create Connection objects */ Connection con = new ConnectionFactory().getConnection(); Statement stmt = con.createStatement(); int row = tblRegistro.getSelectedRow(); int id = pedidoRegistroList.get(row).getId(); SimpleDateFormat horaformatada = new SimpleDateFormat("HH:mm:ss"); Date horaAtual = new Date(); hora = horaformatada.format(horaAtual); Date data = new Date(); // mes = ""+Data.getMonth();//0 a 11 dia = "" + data.getDate(); ano = "" + (1900 + data.getYear()); switch (data.getMonth()) { case 0:/* w ww .ja va 2 s . c o m*/ mes = "Janeiro"; break; case 1: mes = "Fevereiro"; break; case 2: mes = "Maro"; break; case 3: mes = "Abril"; break; case 4: mes = "Maio"; break; case 5: mes = "Junho"; break; case 6: mes = "Julho"; break; case 7: mes = "Agosto"; break; case 8: mes = "Setembro"; break; case 9: mes = "Outubro"; break; case 10: mes = "Novembro"; break; case 11: mes = "Dezembro"; break; } /* Define the SQL query */ // sql = "SELECT cliente.nome, funcionario.nome, tipopagamento.descricao, vendaregistro.dataVenda, vendaregistro.vlrSugerido, vendaregistro.totalVenda, vendaregistro.parcela, vendaregistro.1vencimento, vendaregistro.ativo FROM vendaregistro as vendaregistro INNER JOIN cliente as cliente ON (vendaregistro.idCliente = cliente.id) \n" + //"INNER JOIN funcionario as funcionario ON (vendaregistro.idFuncionario = funcionario.id) INNER JOIN tipopagamento as tipopagamento ON (vendaregistro.idTipoPagamento = tipopagamento.id) WHERE dataVenda = CURRENT_DATE"; ResultSet query = stmt.executeQuery(sql); /* Step-2: Initialize PDF documents - logical objects */ Document PDFLogReport = new Document(); PdfWriter.getInstance(PDFLogReport, new FileOutputStream("C:\\Users\\Leonardo P Souza\\Desktop\\Relat\\Pedidos " + id + ".pdf")); PDFLogReport.open(); Paragraph cabecalho = new Paragraph("AGRO EMPRESARIAL - SISTEMA DE GERENCIAMENTO\n" + "RUA GONALVES CHAVES, 602 PELOTAS/RS\n" + "FONE:(53) 3232-3232 BAIRRO: CENTRO\n" + "CNPJ: 12.345.678/1011-12\n" + "-------------------------------------------\n" + dia + "/" + mes + "/" + ano + " " + hora + " COD: " + id + " \n\n"); cabecalho.setAlignment(Element.ALIGN_CENTER); PDFLogReport.add(cabecalho); //we have two columns in our table PdfPTable LogTable = new PdfPTable(4); // Ttulo para a tabela Paragraph tableHeader = new Paragraph("Lista de Pedidos"); PdfPCell header = new PdfPCell(tableHeader); // Definindo que o header vai ocupar as 2 colunas header.setColspan(4); // Definindo alinhamento do header header.setHorizontalAlignment(Paragraph.ALIGN_CENTER); // Adicionando o header tabela Font fonte = new Font(Font.FontFamily.HELVETICA, 7, Font.BOLD, BaseColor.BLACK); Font fonteDados = new Font(Font.FontFamily.TIMES_ROMAN, 6, Font.NORMAL, BaseColor.BLACK); LogTable.addCell(header); LogTable.addCell(new Paragraph("Produto ", fonte)); LogTable.addCell(new Paragraph("Quantidade", fonte)); LogTable.addCell(new Paragraph("Valor Unitrio", fonte)); LogTable.addCell(new Paragraph("Valor Total", fonte)); //create a cell object // PdfPCell table_cell; while (query.next()) { String produto = query.getString("produto.descricao"); LogTable.addCell(new Paragraph(produto, fonteDados)); String quantidade = query.getString("qtdePedido"); LogTable.addCell(new Paragraph(quantidade, fonteDados)); String vlrSugerido = query.getString("vlrUnitario"); LogTable.addCell(new Paragraph(vlrSugerido, fonteDados)); String vlrTotal = query.getString("vlrTotal"); LogTable.addCell(new Paragraph(vlrTotal, fonteDados)); } /* Attach report table to PDF */ PDFLogReport.add(LogTable); double valor = pedidoRegistroList.get(row).getVlrPedido(); Paragraph paragrafoValor = new Paragraph("Valor R$: " + valor); paragrafoValor.setAlignment(Element.ALIGN_RIGHT); PDFLogReport.add(paragrafoValor); PDFLogReport.close(); /* Close all DB related objects */ query.close(); stmt.close(); con.close(); String file; file = "C:\\Users\\Leonardo P Souza\\Desktop\\Relat\\Pedidos " + id + ".pdf"; Runtime.getRuntime().exec("rundll32 SHELL32.DLL,ShellExec_RunDLL " + file); }
From source file:BusinessLogic.Controller.HandleCertificate.java
public void downloadCertificate(ContractDAO contrDAO, CertificateDAO certificateDAO, UserDAO usDAO, HttpServletResponse response, int idUser, int option) throws DocumentException, IOException { User user = usDAO.searchByPkID(idUser); List<Certificate> certificateObject = certificateDAO.searchUserAproved(); List<Certificate> certificateReturn = new ArrayList<Certificate>(); if (certificateObject != null) { certificateReturn.clear();// w w w .ja v a2s. c o m for (int i = 0; i < certificateObject.size(); i++) { if (certificateObject.get(i).getFkuserID().getPkID().equals(user.getPkID())) { certificateReturn.add(certificateObject.get(i)); } } } Contract contractObject = contrDAO.getUserContract(new User(user.getPkID())); Certificate cert = certificateReturn.get(option); Document document = new Document(); ByteArrayOutputStream baos = new ByteArrayOutputStream(); PdfWriter.getInstance(document, baos); document.open(); Font fuente = new Font(); fuente.setStyle(Font.BOLD); fuente.setColor(BaseColor.BLACK); fuente.setFamily(Font.FontFamily.TIMES_ROMAN.toString()); fuente.setSize(15); Paragraph header = new Paragraph("\n\n\n\n\nEL DEPARTAMENTO DE GESTION HUMANA\n" + "DE TALENTO-HUMANO LTDA\n\n\n\n\n" + "CERTIFICA QUE:\n\n\n\n\n", fuente); header.setAlignment(Element.ALIGN_CENTER); Calendar fecha = new GregorianCalendar(); int annio = fecha.get(Calendar.YEAR); int mes = fecha.get(Calendar.MONTH) + 1; int dia = fecha.get(Calendar.DAY_OF_MONTH); Paragraph endtext = new Paragraph("\n\nSe expide la presente certificacion a solicitud" + " del interesado a la fecha de : " + dia + "/" + mes + "/" + annio + "\n\n\nCordialmente\n\n\nEdwin Alexander Bohorquez\nGERENTE GENERAL DE TALENTO-HUMANO LTDA"); endtext.setAlignment(Element.ALIGN_LEFT); String typeCertificate = ""; if (cert.getType().toLowerCase().equals("laboral")) { typeCertificate = "Laboral"; document.add(header); List<String> positionlist = new ArrayList<String>(); for (Position cargo : contractObject.getPositionSet()) { positionlist.add(cargo.getName()); } Paragraph body = new Paragraph(user.getName().toUpperCase() + " " + user.getLastname().toUpperCase() + " con cedula de ciudadania No." + user.getIdentifyCard() + ", trabaja en esta empresa" + " desde " + contractObject.getStartDate() + ", desempeandose actualmente como " + positionlist + " con una asignacion mensual de $" + contractObject.getSalary() + ".Su contrato de trabajo es a termino " + contractObject.getType() + "."); body.setAlignment(Element.ALIGN_JUSTIFIED_ALL); document.add(body); document.add(endtext); } else if (cert.getType().toLowerCase().equals("nmina")) { typeCertificate = "Nomina"; Paragraph Payroll_header = new Paragraph("DEPARTAMENTO DE CONTABILIDAD\n" + "TALENTO-HUMANO LTDA\n\n" + "LIQUIDACION DE NOMINA:\n" + "Nombre del empleado : " + user.getName() + " " + user.getLastname() + "\n" + "Cedula : " + user.getIdentifyCard() + "\n\n", fuente); Payroll_header.setAlignment(Element.ALIGN_CENTER); document.add(Payroll_header); double commissions = 10000; double extra_hours = 50000; double transportation_aid = 63600; double totalAccrued = contractObject.getSalary() + commissions + extra_hours + transportation_aid; PdfPTable basetable = new PdfPTable(2); PdfPCell headertable = new PdfPCell(new Paragraph("Tabla Base", fuente)); headertable.setColspan(2); basetable.addCell(headertable); PdfPCell cell1 = new PdfPCell(new Paragraph("Salario Basico : ")); PdfPCell cell2 = new PdfPCell(new Paragraph(String.valueOf(contractObject.getSalary()))); PdfPCell cell3 = new PdfPCell(new Paragraph("Comisiones : ")); PdfPCell cell4 = new PdfPCell(new Paragraph(String.valueOf(commissions))); PdfPCell cell5 = new PdfPCell(new Paragraph("Horas Extras : ")); PdfPCell cell6 = new PdfPCell(new Paragraph(String.valueOf(extra_hours))); PdfPCell cell7 = new PdfPCell(new Paragraph("Auxilio de transporte : ")); PdfPCell cell8 = new PdfPCell(new Paragraph(String.valueOf(transportation_aid))); PdfPCell ce9 = new PdfPCell(new Paragraph("Total Devengado : ")); PdfPCell ce10 = new PdfPCell(new Paragraph(" $ " + String.valueOf(totalAccrued))); basetable.setWidthPercentage(100F); basetable.setHorizontalAlignment(Element.ALIGN_CENTER); basetable.addCell(cell1); basetable.addCell(cell2); basetable.addCell(cell3); basetable.addCell(cell4); basetable.addCell(cell5); basetable.addCell(cell6); basetable.addCell(cell7); basetable.addCell(cell8); basetable.addCell(ce9); basetable.addCell(ce10); document.add(basetable); PdfPTable tableliquidation = new PdfPTable(2); PdfPCell title = new PdfPCell( new Paragraph("Liquidacion. Deducciones de nomina(Conceptos a cargo del empleado) ", fuente)); title.setColspan(2); tableliquidation.addCell(title); PdfPCell cell9 = new PdfPCell(new Paragraph("Salud (4%) : ")); PdfPCell cell10 = new PdfPCell(new Paragraph(String.valueOf(contractObject.getSalary() * 0.04))); PdfPCell cell11 = new PdfPCell(new Paragraph("Pension (4%) : ")); PdfPCell cell12 = new PdfPCell(new Paragraph(String.valueOf(contractObject.getSalary() * 0.04))); tableliquidation.setWidthPercentage(100F); tableliquidation.setHorizontalAlignment(Element.ALIGN_CENTER); tableliquidation.addCell(cell9); tableliquidation.addCell(cell10); tableliquidation.addCell(cell11); tableliquidation.addCell(cell12); document.add(tableliquidation); PdfPTable tablesocialSecurity = new PdfPTable(2); PdfPCell title2 = new PdfPCell(new Paragraph("Seguridad Social a cargo del empleador", fuente)); title2.setColspan(2); tablesocialSecurity.addCell(title2); PdfPCell cell13 = new PdfPCell(new Paragraph("Salud (8.5%) : ")); PdfPCell cell14 = new PdfPCell(new Paragraph(String.valueOf(contractObject.getSalary() * 0.085))); PdfPCell cell15 = new PdfPCell(new Paragraph("Pension (12%) : ")); PdfPCell cell16 = new PdfPCell(new Paragraph(String.valueOf(contractObject.getSalary() * 0.12))); PdfPCell cell17 = new PdfPCell(new Paragraph("A.R.P : ")); PdfPCell cell18 = new PdfPCell(new Paragraph(String.valueOf(contractObject.getSalary() * 0.00522))); tablesocialSecurity.setWidthPercentage(100F); tablesocialSecurity.setHorizontalAlignment(Element.ALIGN_CENTER); tablesocialSecurity.addCell(cell13); tablesocialSecurity.addCell(cell14); tablesocialSecurity.addCell(cell15); tablesocialSecurity.addCell(cell16); tablesocialSecurity.addCell(cell17); tablesocialSecurity.addCell(cell18); document.add(tablesocialSecurity); PdfPTable social_benefits = new PdfPTable(2); PdfPCell title3 = new PdfPCell(new Paragraph("Prestaciones Sociales", fuente)); title3.setColspan(2); social_benefits.addCell(title3); PdfPCell cell19 = new PdfPCell(new Paragraph("Prima de servicios : ")); PdfPCell cell20 = new PdfPCell(new Paragraph(String.valueOf(totalAccrued * 0.0833))); PdfPCell cell21 = new PdfPCell(new Paragraph("Cesantias : ")); PdfPCell cell22 = new PdfPCell(new Paragraph(String.valueOf(totalAccrued * 0.0833))); PdfPCell cell23 = new PdfPCell(new Paragraph("Intereses sobre las cesantias : ")); PdfPCell cell24 = new PdfPCell(new Paragraph(String.valueOf(totalAccrued * 0.0833 * 0.12))); PdfPCell cell25 = new PdfPCell(new Paragraph("Vacaciones : ")); PdfPCell cell26 = new PdfPCell(new Paragraph(String.valueOf(contractObject.getSalary() * 0.0417))); social_benefits.setWidthPercentage(100F); social_benefits.setHorizontalAlignment(Element.ALIGN_CENTER); social_benefits.addCell(cell19); social_benefits.addCell(cell20); social_benefits.addCell(cell21); social_benefits.addCell(cell22); social_benefits.addCell(cell23); social_benefits.addCell(cell24); social_benefits.addCell(cell25); social_benefits.addCell(cell26); document.add(social_benefits); PdfPTable fiscal_contributions = new PdfPTable(2); PdfPCell title4 = new PdfPCell(new Paragraph("Aportes Parafiscales", fuente)); title4.setColspan(2); fiscal_contributions.addCell(title4); PdfPCell cell27 = new PdfPCell(new Paragraph("Cajas de compensacion familiar (4%) : ")); PdfPCell cell28 = new PdfPCell( new Paragraph(String.valueOf((contractObject.getSalary() + extra_hours + commissions) * 0.04))); PdfPCell cell29 = new PdfPCell(new Paragraph("I.CB.F (3%) : ")); PdfPCell cell30 = new PdfPCell( new Paragraph(String.valueOf((contractObject.getSalary() + extra_hours + commissions) * 0.03))); PdfPCell cell31 = new PdfPCell(new Paragraph("Sena (2%) : ")); PdfPCell cell32 = new PdfPCell( new Paragraph(String.valueOf((contractObject.getSalary() + extra_hours + commissions) * 0.02))); fiscal_contributions.setWidthPercentage(100F); fiscal_contributions.setHorizontalAlignment(Element.ALIGN_CENTER); fiscal_contributions.addCell(cell27); fiscal_contributions.addCell(cell28); fiscal_contributions.addCell(cell29); fiscal_contributions.addCell(cell30); fiscal_contributions.addCell(cell31); fiscal_contributions.addCell(cell32); document.add(fiscal_contributions); PdfPTable totalValue = new PdfPTable(2); PdfPCell title5 = new PdfPCell(new Paragraph("Neto a pagar al empleado", fuente)); title5.setColspan(2); totalValue.addCell(title5); PdfPCell cell33 = new PdfPCell(new Paragraph(" Total devengado - salud - pension")); cell33.setColspan(2); PdfPCell cell34 = new PdfPCell(new Paragraph( " $ " + String.valueOf(totalAccrued - contractObject.getSalary() * 0.08), fuente)); cell34.setColspan(2); totalValue.setWidthPercentage(100F); totalValue.setHorizontalAlignment(Element.ALIGN_CENTER); totalValue.addCell(cell33); totalValue.addCell(cell34); document.add(totalValue); document.add(endtext); } else if (cert.getType().toLowerCase().equals("salud")) { typeCertificate = "Salud"; document.add(header); Paragraph body = new Paragraph(user.getName().toUpperCase() + " " + user.getLastname().toUpperCase() + " con cedula de ciudadania No." + user.getIdentifyCard() + ", esta afiliado desde " + contractObject.getStartHealthDate() + " a la empresa de salud " + contractObject.getHealthEnterprise() + "."); body.setAlignment(Element.ALIGN_JUSTIFIED_ALL); document.add(body); document.add(endtext); } else if (cert.getType().toLowerCase().equals("pensin")) { typeCertificate = "Pension"; document.add(header); Paragraph body = new Paragraph(user.getName().toUpperCase() + " " + user.getLastname().toUpperCase() + " con cedula de ciudadania No." + user.getIdentifyCard() + ", esta afiliado a la empresa de pension " + contractObject.getPensionEnterprise() + ".La fecha de inicio de pension es " + contractObject.getStartPensionDate() + "."); body.setAlignment(Element.ALIGN_JUSTIFIED_ALL); document.add(body); document.add(endtext); } document.close(); response.setHeader("Expires", "0"); response.setHeader("Cache-Control", "must-revalidate, post-check=0, pre-check=0"); response.setHeader("Pragma", "public"); response.setContentType("application/octet-strem"); File f = new File("Certificado" + typeCertificate + ".pdf"); response.setHeader("Content-Disposition", "attachment;filename=" + f.getName()); response.setContentLength(baos.size()); System.out.println("Hasta aca crea el pdf bien"); OutputStream os = response.getOutputStream(); System.out.println("Ac'a ya deberia haber descargado"); baos.writeTo(os); os.flush(); os.close(); }
From source file:classes.utils.crearPDF_Depreciacion.java
public String writePDF(String datos, Scene scene) throws FileNotFoundException, DocumentException, BadElementException, IOException { javafx.scene.control.TextField projectName = (TextField) scene.lookup(CNodeID.TEXTFIELD_PROJECT_NAME); String project = projectName.getText(); StringTokenizer st = new StringTokenizer(datos, "_"); principal = st.nextToken();/*from ww w .jav a2s . c om*/ salvageV = st.nextToken(); period = st.nextToken(); tax = st.nextToken(); periodSalvage = st.nextToken(); category = st.nextToken(); data = st.nextToken(); Document document = new Document(PageSize.LETTER, 80, 80, 50, 50); FileOutputStream salida = new FileOutputStream(project + "_depreciation.pdf"); PdfWriter writer = PdfWriter.getInstance(document, salida); writer.setInitialLeading(0); Paragraph paragraph = new Paragraph(); paragraph.setFont(new Font(FontFactory.getFont("Courier", 20, Font.BOLDITALIC, BaseColor.RED))); paragraph.add("\n\n\nDEPRECIACION"); paragraph.setAlignment(Paragraph.ALIGN_CENTER); //System.out.println(getClass().getResource("images/logo_report.png")); //Image image = Image.getInstance("/home/isaac/IdeaProjects/ProjectEvaluation/src/images/logo_report.png"); //image.scaleToFit(150, 150); Image image1 = Image.getInstance(project + "/" + project + "_DEP_TY.png"); image1.scaleToFit(300, 300); //image.setAlignment(Chunk.ALIGN_RIGHT); image1.setAlignment(Chunk.ALIGN_CENTER); Paragraph paragraph_2 = new Paragraph(); paragraph_2.setFont(new Font(FontFactory.getFont("Courier", 12, Font.BOLD, BaseColor.BLUE))); paragraph_2.add( "\n\n\n\n\n\n\n\n\n\n\nADMINISTRACION Y EVALUACION DE PROYECTOS\n\n SERGIO VALDES TORRES A01365520\n ERIK MARTIN A01365096\nISAAC SECUNDINO A01361162\n IVAN CABRER A01184937"); paragraph_2.setAlignment(Paragraph.ALIGN_RIGHT); Paragraph paragraph_3 = new Paragraph(); paragraph_3.setFont(new Font(FontFactory.getFont("Courier", 11, Font.BOLD, BaseColor.BLACK))); paragraph_3.add("\n " + data); paragraph_3.setAlignment(Paragraph.ALIGN_LEFT); Paragraph paragraph_5 = new Paragraph(); paragraph_5.setFont(new Font(FontFactory.getFont("Courier", 6, Font.BOLD, BaseColor.BLUE))); paragraph_5.add("\n\nP DEPRECIATON RATE ANNUAL DEPRECIATON CUMMULATIVE DEPRECIATON VALUE IN LEDGERS "); paragraph_5.setAlignment(Paragraph.ALIGN_LEFT); Paragraph paragraph_4 = new Paragraph(); paragraph_4.setFont(new Font(FontFactory.getFont("Courier", 9, Font.BOLD, BaseColor.BLACK))); paragraph_4.add("Nombre del Evaluador: \n Principal: " + principal + " \n Salvag Value: " + salvageV + " \n Numero de Periodos: " + period + "\n Tax: " + tax + " \n Salvage Period: " + periodSalvage + "\n Categoria: " + category); paragraph_4.setAlignment(Paragraph.ALIGN_LEFT); Paragraph paragraph_6 = new Paragraph(); paragraph_6.setFont(new Font(FontFactory.getFont("Courier", 15, Font.BOLD, BaseColor.GRAY))); paragraph_6.add("\n GRAFICAS\n"); paragraph_6.setAlignment(Paragraph.ALIGN_CENTER); document.open(); //document.add(image); document.add(paragraph); document.add(paragraph_4); document.add(paragraph_5); document.add(paragraph_3); document.add(paragraph_6); Image image2 = Image.getInstance(project + "/" + project + "_DEP_DR.png"); Image image3 = Image.getInstance(project + "/" + project + "_DEP_AD.png"); Image image4 = Image.getInstance(project + "/" + project + "_DEP_ACD.png"); Image image5 = Image.getInstance(project + "/" + project + "_DEP_LV.png"); document.add(image2); document.add(image3); document.add(image4); document.add(image5); document.add(image1); document.add(paragraph_2); document.close(); return null; }
From source file:classes.utils.createPDF_checkList.java
public String writePDF(Scene scene, String datos) throws FileNotFoundException, DocumentException, BadElementException, IOException { javafx.scene.control.TextField projectName = (javafx.scene.control.TextField) scene .lookup(CNodeID.TEXTFIELD_PROJECT_NAME); String project = projectName.getText(); StringTokenizer st = new StringTokenizer(datos, "*"); dato1 = st.nextToken();//w ww . jav a 2 s .com dato2 = st.nextToken(); dato3 = st.nextToken(); dato4 = st.nextToken(); dato5 = st.nextToken(); dato6 = st.nextToken(); dato7 = st.nextToken(); dato8 = st.nextToken(); dato9 = st.nextToken(); dato10 = st.nextToken(); dato11 = st.nextToken(); dato12 = st.nextToken(); dato13 = st.nextToken(); dato14 = st.nextToken(); dato15 = st.nextToken(); dato16 = st.nextToken(); dato17 = st.nextToken(); Document document = new Document(PageSize.LETTER, 80, 80, 50, 50); FileOutputStream salida = new FileOutputStream(project + "_CheckList.pdf"); PdfWriter writer = PdfWriter.getInstance(document, salida); writer.setInitialLeading(0); Paragraph paragraph = new Paragraph(); paragraph.setFont(new Font(FontFactory.getFont("Courier", 20, Font.BOLDITALIC, BaseColor.RED))); paragraph.add("\n\n\nCHECK LIST"); paragraph.setAlignment(Paragraph.ALIGN_CENTER); //Image image = Image.getInstance("/home/isaac/IdeaProjects/ProjectEvaluation/src/images/logo_report.png"); //image.scaleToFit(150, 150); //image.setAlignment(Chunk.ALIGN_RIGHT); Paragraph paragraph_2 = new Paragraph(); paragraph_2.setFont(new Font(FontFactory.getFont("Courier", 12, Font.BOLD, BaseColor.BLUE))); paragraph_2.add( "\n\n\n\n\n\n\nADMINISTRACION Y EVALUACION DE PROYECTOS\n\n SERGIO VALDES TORRES A01365520\n ERIK MARTIN A01365096\nISAAC SECUNDINO A01361162\n IVAN CABRER A01184937"); paragraph_2.setAlignment(Paragraph.ALIGN_RIGHT); Paragraph paragraph_4 = new Paragraph(); paragraph_4.setFont(new Font(FontFactory.getFont("Courier", 6, Font.BOLD, BaseColor.BLACK))); paragraph_4.add("Strategy---Alignment What specific organization strategy does this project align with?" + " " + dato1 + "\n" + "Driver---What business problem does the project solve?" + " " + dato2 + "\n" + "Success Metrics---How will measure success?" + " " + dato3 + "\n" + "Sponsorship---Who is the project sponsor?" + " " + dato4 + "\n" + "Risk---What is the impact of not doing this project?" + " " + dato5 + "\n" + "Risk---What is the project risk to our organization?" + " " + dato6 + "\n" + "Risk---Where does the proposed project fit in our risk profile?" + " " + dato7 + "\n" + "Benefits, value---What is the value of the project organization?" + " " + dato8 + "\n" + "Benefits, value---When will the project shows results?" + " " + dato9 + "\n" + "Objectives---What are the project objectives?" + " " + dato10 + "\n" + "Organization Culture---Is our organization culture right for this type of project?" + " " + dato11 + "\n" + "Resources---Will internal resources be available for this project?" + " " + dato12 + "\n" + "Approach---Will we build or buy?" + " " + dato13 + "\n" + "Schedule---How long will this project take?" + " " + dato14 + "\n" + "Schedule---Is the timeline realistic?" + " " + dato15 + "\n" + "Training/Resources---Will staff training be required?" + " " + dato16 + "\n" + "Finance/Portfolio---What is the estimated cost of the project?" + " " + dato17 + "\n"); /*+ "Portfolio---Is this a new initiative or path of an existing initiative?"+" "+dato18+"\n" + "Portfolio---How does this project interact with current projects?"+" "+dato19+"\n" + "Technology---Is the technology available or new?"+" "+dato20+""); */ paragraph_4.setAlignment(Paragraph.ALIGN_LEFT); document.open(); //document.add(image); document.add(paragraph); document.add(paragraph_4); document.add(paragraph_2); document.close(); return "pdf Creado"; }
From source file:classes.utils.createPDF_NetPresent.java
public String writePDF(Scene scene, String datos) throws FileNotFoundException, DocumentException, BadElementException, IOException { javafx.scene.control.TextField projectName = (javafx.scene.control.TextField) scene .lookup(CNodeID.TEXTFIELD_PROJECT_NAME); String project = projectName.getText(); StringTokenizer st = new StringTokenizer(datos, "_"); period = st.nextToken();/*from ww w. jav a 2 s .c om*/ principal = st.nextToken(); interestRate = st.nextToken(); tax = st.nextToken(); salvageV = st.nextToken(); periodSalvage = st.nextToken(); data = st.nextToken(); Document document = new Document(PageSize.LETTER, 80, 80, 50, 50); FileOutputStream salida = new FileOutputStream(project + "_NetPresentValue.pdf"); PdfWriter writer = PdfWriter.getInstance(document, salida); writer.setInitialLeading(0); Paragraph paragraph = new Paragraph(); paragraph.setFont(new Font(FontFactory.getFont("Courier", 20, Font.BOLDITALIC, BaseColor.RED))); paragraph.add("\n\n\nNET PRESENT VALUE"); paragraph.setAlignment(Paragraph.ALIGN_CENTER); //Image image = Image.getInstance("/home/isaac/IdeaProjects/ProjectEvaluation/src/images/logo_report.png"); //image.scaleToFit(150, 150); Image image1 = Image.getInstance(project + "/" + project + "_NPV_CCF.png"); image1.scaleToFit(300, 300); //image.setAlignment(Chunk.ALIGN_RIGHT); image1.setAlignment(Chunk.ALIGN_CENTER); Paragraph paragraph_2 = new Paragraph(); paragraph_2.setFont(new Font(FontFactory.getFont("Courier", 12, Font.BOLD, BaseColor.BLUE))); paragraph_2.add( "\n\n\n\n\n\n\n\n\n\n\nADMINISTRACION Y EVALUACION DE PROYECTOS\n\n SERGIO VALDES TORRES A01365520\n ERIK MARTIN A01365096\nISAAC SECUNDINO A01361162\n IVAN CABRER A01184937"); paragraph_2.setAlignment(Paragraph.ALIGN_RIGHT); Paragraph paragraph_3 = new Paragraph(); paragraph_3.setFont(new Font(FontFactory.getFont("Courier", 11, Font.BOLD, BaseColor.BLACK))); paragraph_3.add("\n " + data); paragraph_3.setAlignment(Paragraph.ALIGN_LEFT); Paragraph paragraph_5 = new Paragraph(); paragraph_5.setFont(new Font(FontFactory.getFont("Courier", 10, Font.BOLD, BaseColor.BLUE))); paragraph_5.add("\n\nP OUTFLOW INFLOW NET CASH FLOW CUMULATIVE CASH "); paragraph_5.setAlignment(Paragraph.ALIGN_LEFT); Paragraph paragraph_4 = new Paragraph(); paragraph_4.setFont(new Font(FontFactory.getFont("Courier", 9, Font.BOLD, BaseColor.BLACK))); paragraph_4.add("Nombre del Evaluador: \nPeriods: " + period + "\n Principal: " + principal + " \n Interest Rate%: " + interestRate + " \n Tax Rate %: " + tax + "\n Salvage Value: " + salvageV + " \n Period SV: " + periodSalvage); paragraph_4.setAlignment(Paragraph.ALIGN_LEFT); Paragraph paragraph_6 = new Paragraph(); paragraph_6.setFont(new Font(FontFactory.getFont("Courier", 15, Font.BOLD, BaseColor.GRAY))); paragraph_6.add("\n GRAFICAS\n"); paragraph_6.setAlignment(Paragraph.ALIGN_CENTER); document.open(); //document.add(image); document.add(paragraph); document.add(paragraph_4); document.add(paragraph_5); document.add(paragraph_3); document.add(paragraph_6); document.add(image1); Image image2 = Image.getInstance(project + "/" + project + "_NPV_NCF.png"); document.add(image2); document.add(paragraph_2); document.close(); return null; }
From source file:classes.utils.createPDF_PayBack.java
public String writePDF(Scene scene, String datos) throws FileNotFoundException, DocumentException, BadElementException, IOException { javafx.scene.control.TextField projectName = (javafx.scene.control.TextField) scene .lookup(CNodeID.TEXTFIELD_PROJECT_NAME); String project = projectName.getText(); StringTokenizer st = new StringTokenizer(datos, "_"); period = st.nextToken();//from ww w . j a v a 2 s. c om principal = st.nextToken(); interestRate = st.nextToken(); data = st.nextToken(); Document document = new Document(PageSize.LETTER, 80, 80, 50, 50); FileOutputStream salida = new FileOutputStream(project + "_PayBackPeriod.pdf"); PdfWriter writer = PdfWriter.getInstance(document, salida); writer.setInitialLeading(0); Paragraph paragraph = new Paragraph(); paragraph.setFont(new Font(FontFactory.getFont("Courier", 20, Font.BOLDITALIC, BaseColor.RED))); paragraph.add("\n\n\nPAYBACK PERIOD"); paragraph.setAlignment(Paragraph.ALIGN_CENTER); // TODO: Change absolute to relative //Image image = Image.getInstance("/home/isaac/IdeaProjects/ProjectEvaluation/src/images/logo_report.png"); //image.scaleToFit(150, 150); Image image1 = Image.getInstance(project + "/" + project + "_PBP_CCF.png"); image1.scaleToFit(300, 300); //image.setAlignment(Chunk.ALIGN_RIGHT); image1.setAlignment(Chunk.ALIGN_CENTER); Paragraph paragraph_2 = new Paragraph(); paragraph_2.setFont(new Font(FontFactory.getFont("Courier", 12, Font.BOLD, BaseColor.BLUE))); paragraph_2.add( "\n\n\n\n\n\n\n\n\n\n\nADMINISTRACION Y EVALUACION DE PROYECTOS\n\n SERGIO VALDES TORRES A01365520\n ERIK MARTIN A01365096\nISAAC SECUNDINO A01361162\n IVAN CABRER A01184937"); paragraph_2.setAlignment(Paragraph.ALIGN_RIGHT); Paragraph paragraph_3 = new Paragraph(); paragraph_3.setFont(new Font(FontFactory.getFont("Courier", 11, Font.BOLD, BaseColor.BLACK))); paragraph_3.add("\n " + data); paragraph_3.setAlignment(Paragraph.ALIGN_LEFT); Paragraph paragraph_5 = new Paragraph(); paragraph_5.setFont(new Font(FontFactory.getFont("Courier", 10, Font.BOLD, BaseColor.BLUE))); paragraph_5.add("\n\nP OUTFLOW INFLOW CUMMULATIVE CASH... "); paragraph_5.setAlignment(Paragraph.ALIGN_LEFT); Paragraph paragraph_4 = new Paragraph(); paragraph_4.setFont(new Font(FontFactory.getFont("Courier", 9, Font.BOLD, BaseColor.BLACK))); paragraph_4.add("Nombre del Evaluador: \n Principal: " + principal + " \n Numero de Periodos: " + period + "\nInterest Rate %" + interestRate); paragraph_4.setAlignment(Paragraph.ALIGN_LEFT); Paragraph paragraph_6 = new Paragraph(); paragraph_6.setFont(new Font(FontFactory.getFont("Courier", 15, Font.BOLD, BaseColor.GRAY))); paragraph_6.add("\n GRAFICAS\n"); paragraph_6.setAlignment(Paragraph.ALIGN_CENTER); document.open(); //document.add(image); document.add(paragraph); document.add(paragraph_4); document.add(paragraph_5); document.add(paragraph_3); document.add(paragraph_6); Image image2 = Image.getInstance(project + "/" + project + "_PBP_NCF.png"); document.add(image1); document.add(image2); document.add(paragraph_2); document.close(); return null; }
From source file:com.atacadao.almoxarifado.model.GerandoPDF.java
public void pdfDeSaida(ArrayList<Equipamento> equipamentos, String solicitante, String autorizante, String responsavel, String numeroSaida) { Document documento = new Document(); try {//from w w w . j a v a2s .c om Path path = Paths.get("\\files\\saidas.pdf"); if (!Files.isDirectory(path.getParent())) { Files.createDirectory(path.getParent()); Files.createFile(path); } PdfWriter pdf; pdf = PdfWriter.getInstance(documento, new FileOutputStream("\\files\\saidas.pdf")); documento.open(); documento.addTitle("SOLICITAO DE EQUIPAMENTOS E PRODUTOS"); /** * Responsavel pelo cabealho do documento */ Image imagem = Image.getInstance("atacadao.jpg"); imagem.setAlignment(Element.ALIGN_CENTER); documento.add(imagem); Paragraph titulo = new Paragraph("SOLICITAO DE EQUIPAMENTOS E PRODUTOS", new com.itextpdf.text.Font( com.itextpdf.text.Font.FontFamily.UNDEFINED, 16, 0, BaseColor.BLACK)); titulo.setAlignment(Element.ALIGN_CENTER); documento.add(titulo); documento.setMargins(0, 0, 18, 0); Date datas = new Date(); Locale local = new Locale("pt", "BR"); SimpleDateFormat sdf = new SimpleDateFormat("E dd/MM/yyyy", local); Paragraph espaco = new Paragraph( "\n\nDeclaro para os devidos fins que eu " + solicitante + " recebi na " + sdf.format(datas) + " os equipamentos abaixo relacionados da empresa " + "Atacado dos Pisos por " + autorizante + " e autorizado por " + responsavel + ".\n", new com.itextpdf.text.Font(com.itextpdf.text.Font.FontFamily.UNDEFINED, 12, 0, BaseColor.BLACK)); documento.add(espaco); documento.add(new Paragraph("\n Numero de registro : " + numeroSaida + "\n\n")); /** * Responsavel por cria a tabela da sada dos equipamentos */ PdfPTable pdfT = new PdfPTable(4); PdfPCell celulas = new PdfPCell(new Paragraph( "Relao de equipamentos solicitados para seus devidos fins." + " Favor caso haja devoluo manter o maximo possvel do estado atual dos mesmos. Grato !!!", new com.itextpdf.text.Font(com.itextpdf.text.Font.FontFamily.UNDEFINED, 11, 0, BaseColor.GRAY))); celulas.setColspan(4); PdfPCell patrimonio = new PdfPCell(new Paragraph("PATRIMONIO", new com.itextpdf.text.Font( com.itextpdf.text.Font.FontFamily.UNDEFINED, 12, 0, BaseColor.WHITE))); patrimonio.setBackgroundColor(BaseColor.GRAY); patrimonio.setPadding((float) 1); PdfPCell Nome = new PdfPCell(new Paragraph("NOME", new com.itextpdf.text.Font( com.itextpdf.text.Font.FontFamily.UNDEFINED, 12, 0, BaseColor.WHITE))); Nome.setBackgroundColor(BaseColor.GRAY); Nome.setPadding((float) 1); PdfPCell Situacao = new PdfPCell(new Paragraph("SITUAO", new com.itextpdf.text.Font( com.itextpdf.text.Font.FontFamily.UNDEFINED, 12, 0, BaseColor.WHITE))); Situacao.setBackgroundColor(BaseColor.GRAY); Situacao.setPadding((float) 1); PdfPCell valor = new PdfPCell(new Paragraph("DESTINO", new com.itextpdf.text.Font( com.itextpdf.text.Font.FontFamily.UNDEFINED, 12, 0, BaseColor.WHITE))); valor.setBackgroundColor(BaseColor.GRAY); valor.setPadding((float) 1); pdfT.addCell(celulas); pdfT.addCell(patrimonio); pdfT.addCell(Nome); pdfT.addCell(Situacao); pdfT.addCell(valor); for (Equipamento equipamento : equipamentos) { PdfPCell patrimonios = new PdfPCell( new Paragraph(equipamento.getPatrimonio(), new com.itextpdf.text.Font( com.itextpdf.text.Font.FontFamily.UNDEFINED, 10, 0, BaseColor.BLACK))); patrimonios.setBackgroundColor(BaseColor.WHITE); Situacao.setPadding((float) 0.8); pdfT.addCell(patrimonios); PdfPCell nomes = new PdfPCell(new Paragraph(equipamento.getNome(), new com.itextpdf.text.Font( com.itextpdf.text.Font.FontFamily.UNDEFINED, 10, 0, BaseColor.BLACK))); nomes.setBackgroundColor(BaseColor.WHITE); nomes.setPadding((float) 0.8); pdfT.addCell(nomes); PdfPCell situacoes = new PdfPCell( new Paragraph(equipamento.getSituacao(), new com.itextpdf.text.Font( com.itextpdf.text.Font.FontFamily.UNDEFINED, 10, 0, BaseColor.BLACK))); situacoes.setBackgroundColor(BaseColor.WHITE); situacoes.setPadding((float) 0.8); pdfT.addCell(situacoes); PdfPCell valores = new PdfPCell(new Paragraph(equipamento.getCodigo(), new com.itextpdf.text.Font( com.itextpdf.text.Font.FontFamily.UNDEFINED, 10, 0, BaseColor.BLACK))); valores.setBackgroundColor(BaseColor.WHITE); valores.setPadding((float) 0.8); pdfT.addCell(valores); } documento.add(pdfT); /** * Cria tabela para assinatura do solicitante e autorizado */ PdfPTable pdfTs = new PdfPTable(5); Paragraph sol = new Paragraph("\n\n" + solicitante, new com.itextpdf.text.Font(com.itextpdf.text.Font.FontFamily.UNDEFINED, 12, Font.ITALIC)); sol.setAlignment(Element.ALIGN_CENTER); PdfPCell ass = new PdfPCell(sol); ass.setBorder(0); ass.setBorderWidthTop(1); ass.setColspan(2); PdfPCell espacos = new PdfPCell(); espacos.setBorder(0); Paragraph auth = new Paragraph("\n\n" + autorizante, new com.itextpdf.text.Font(com.itextpdf.text.Font.FontFamily.UNDEFINED, 12, Font.ITALIC)); auth.setAlignment(Element.ALIGN_CENTER); PdfPCell ass2 = new PdfPCell(auth); ass2.setBorder(0); ass2.setBorderWidthTop(1); ass2.setColspan(2); pdfTs.addCell(ass); pdfTs.addCell(espacos); pdfTs.addCell(ass2); documento.add(new Paragraph("\n\n\n")); documento.add(pdfTs); documento.close(); ImpressaoDeDocumentos imprimir = new ImpressaoDeDocumentos("\\files\\saidas.pdf"); // Desktop.getDesktop().open(new File("\\files\\saidas.pdf")); } catch (DocumentException ex) { Logger.getLogger(GerandoPDF.class.getName()).log(Level.SEVERE, null, ex); } catch (FileNotFoundException ex) { Logger.getLogger(GerandoPDF.class.getName()).log(Level.SEVERE, null, ex); } catch (IOException ex) { Logger.getLogger(GerandoPDF.class.getName()).log(Level.SEVERE, null, ex); } }