List of usage examples for com.itextpdf.text.pdf PdfPTable setWidthPercentage
public void setWidthPercentage(final float widthPercentage)
From source file:Export.SeguroRoubo.java
public String criarDoc(String numApolice, String numCliente, RouboBean rb, Contrato c, String user, String arquivo) {/* www . j a v a 2 s.com*/ try { SimpleDateFormat sdf = 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(Fontes.FONTB, BaseFont.WINANSI, BaseFont.EMBEDDED, 9.5f); Font fontCorpo = FontFactory.getFont(Fontes.FONT, BaseFont.WINANSI, BaseFont.EMBEDDED, 8f); Font fontCorpoP = FontFactory.getFont(Fontes.FONT, BaseFont.WINANSI, BaseFont.EMBEDDED, 7f); Font fontCorpoN = FontFactory.getFont(Fontes.FONTB, BaseFont.WINANSI, BaseFont.EMBEDDED, 8f); Font fontCorpoNG = FontFactory.getFont(Fontes.FONTB, BaseFont.WINANSI, BaseFont.EMBEDDED, 8.5f); Font fontCorpoNGT = FontFactory.getFont(Fontes.FONTB, BaseFont.WINANSI, BaseFont.EMBEDDED, 10f); Font fontCabecalhoNG = FontFactory.getFont(Fontes.FONTB, BaseFont.WINANSI, BaseFont.EMBEDDED, 16f, Font.UNDERLINE); PdfPTable pTableEmpresaPricipal = new PdfPTable(new float[] { 25f, 75f }); PdfPTable pTableEmpresaInforImpres1 = new PdfPTable(1); PdfPTable pTableEmpresaInforImpres2 = 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(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); PdfPCell pCellPolice = new PdfPCell(new Phrase(Empresa.APOLICE + numApolice, fontCabecalhoN)); pCellPolice.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); pTableEmpresaInforImpres1.addCell(pCellPolice); 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.addCell(cellTabela6); pTableEmpresaPricipal.addCell(cellTabela5); PdfPTable pTableSeguro = new PdfPTable(1); PdfPTable pTableCliente = new PdfPTable(1); PdfPTable pTableTitulo = new PdfPTable(1); Phrase pTitulo = new Phrase("Formulario de SEguro Roubo".toUpperCase(), fontCorpoNGT); PdfPCell cellTitulo = new PdfPCell(pTitulo); cellTitulo.setBorder(0); cellTitulo.setHorizontalAlignment(Element.ALIGN_CENTER); pTableTitulo.addCell(cellTitulo); ClienteI ci = new ClienteI(numCliente); PdfPCell cellTituloTsbleSegurado = new PdfPCell( new Phrase("1 - Informaes Cliente".toUpperCase(), fontCorpoNG)); cellTituloTsbleSegurado.setBorder(0); Paragraph pCl = new Paragraph(); pCl.add(new Phrase(" " + ci.getNOMEL_(), fontCorpo)); pCl.add(new Phrase(ci.getNOME_(), fontCorpoN)); PdfPCell cellNome = new PdfPCell(new Phrase(pCl)); cellNome.setBorder(0); pCl = new Paragraph(); pCl.add(new Phrase(" " + ci.getENDERECOL_(), fontCorpo)); pCl.add(new Phrase(ci.getENDERECO_(), fontCorpoN)); PdfPCell cellEndereco = new PdfPCell(pCl); cellEndereco.setBorder(0); pCl = new Paragraph(); pCl.add(new Phrase(" " + ci.getNUNCLIENTEL_(), fontCorpo)); pCl.add(new Phrase(ci.getNUNCLIENTE_(), fontCorpoN)); PdfPCell cellNCliente = new PdfPCell(pCl); cellNCliente.setBorder(0); pCl = new Paragraph(); pCl.add(new Phrase(" " + ci.getPROFISSAOL_(), fontCorpo)); pCl.add(new Phrase(ci.getPROFISSAO_(), fontCorpoN)); PdfPCell cellProfissao = new PdfPCell(pCl); cellProfissao.setBorder(0); pCl = new Paragraph(); pCl.add(new Phrase(" " + ci.getLOCALTRABALHOL_(), fontCorpo)); pCl.add(new Phrase(ci.getLOCALTRABALHO_(), fontCorpoN)); PdfPCell cellLocalTrabalho = new PdfPCell(pCl); cellLocalTrabalho.setBorder(0); pTableCliente.addCell(cellTituloTsbleSegurado); pTableCliente.addCell(cellNome); pTableCliente.addCell(cellEndereco); pTableCliente.addCell(cellNCliente); pTableCliente.addCell(cellProfissao); pTableCliente.addCell(cellLocalTrabalho); PdfPTable pTableDadosTitulo = new PdfPTable(1); PdfPCell cellDadosTitulo = new PdfPCell(new Phrase()); cellDadosTitulo.setBorder(0); Paragraph pInfoTitulo = new Paragraph("2 - Informaes do(s) Objecto (s) Segurado(s)".toUpperCase(), fontCorpoN); Paragraph pInfo1 = new Paragraph(" O Segurado: ".toUpperCase() + rb.getRoubo().getTipoEdificio(), fontCorpo); Paragraph pInfo2 = new Paragraph(" Endereo: ".toUpperCase() + rb.getRoubo().getEnderecoEdificio(), fontCorpo); cellDadosTitulo.addElement(pInfoTitulo); cellDadosTitulo.addElement(pInfo1); cellDadosTitulo.addElement(pInfo2); pTableDadosTitulo.addCell(cellDadosTitulo); PdfPCell cellSeguro = new PdfPCell(new Phrase()); cellSeguro.setBorder(0); Paragraph pSegTitulo = new Paragraph("3 - Informaes Montante Segurado".toUpperCase(), fontCorpoN); Paragraph pSeg1 = new Paragraph( " A Propriendade SEgurada: ......................................................... veja a especificao I" .toUpperCase(), fontCorpo); Paragraph pSeg2 = new Paragraph(" Periodo Do Seguro ".toUpperCase(), fontCorpo); Paragraph pSeg3 = new Paragraph(" - DE " + sdf.format(c.getDataInicio()) + " At " + sdf.format(c.getDataFim()) + " (16:00 Da DATA DE Epirao): ".toUpperCase(), fontCorpo); Paragraph pSeg4 = new Paragraph(" Data de Renovao: " + ((c.getDataRenovacao() == null) ? "" : sdf.format(c.getDataRenovacao()).toUpperCase()), fontCorpo); Paragraph pSeg5 = new Paragraph(" Primeiro premio: ".toUpperCase() + c.getPrimeiroPremio(), fontCorpo); Paragraph pSeg6 = new Paragraph(" Prmeio Anual: ".toUpperCase() + c.getPremioAnual(), fontCorpo); Paragraph pSeg7 = new Paragraph( "Ojectos/Limite de responsabilidade dedutvel/prmio/observao/natureza/Do Risco/valor segurado/preo excesso" .toUpperCase(), fontCorpo); Paragraph pSeg8 = new Paragraph(" ".toUpperCase(), fontCorpo); Paragraph pSeg9 = new Paragraph(" Prmio grosso:".toUpperCase(), fontCorpo); Paragraph pSeg10 = new Paragraph(" MeNor: ".toUpperCase(), fontCorpo); Paragraph pSeg11 = new Paragraph(" Adiciona: ".toUpperCase(), fontCorpo); Paragraph pSeg12 = new Paragraph(" Prmio Liquido Pagvel: ".toUpperCase(), fontCorpo); Paragraph pSeg13 = new Paragraph( " outras condies/memorando .......................................................... queira por favor vira a pgina " .toUpperCase(), fontCorpo); Paragraph pSegData = new Paragraph(" Data Em ".toUpperCase() + sdf.format(new Date()).toUpperCase(), fontCorpo); cellSeguro.addElement(pSegTitulo); cellSeguro.addElement(pSeg1); cellSeguro.addElement(pSeg2); cellSeguro.addElement(pSeg3); cellSeguro.addElement(pSeg4); cellSeguro.addElement(pSeg5); cellSeguro.addElement(pSeg6); cellSeguro.addElement(pSeg8); cellSeguro.addElement(pSeg7); cellSeguro.addElement(pSeg8); cellSeguro.addElement(pSeg9); cellSeguro.addElement(pSeg10); cellSeguro.addElement(pSeg11); cellSeguro.addElement(pSeg12); cellSeguro.addElement(pSeg13); cellSeguro.addElement(pSeg8); cellSeguro.addElement(pSeg8); cellSeguro.addElement(pSegData); pTableSeguro.addCell(cellSeguro); PdfPTable pTableObs = new PdfPTable(1); PdfPCell cellObs = new PdfPCell(); cellObs.setBorder(0); Paragraph pObs = new Paragraph( "2.2 Especificao lidada e que faz parte de aplice de seguro contra Roubo N. 1" .toUpperCase(), fontCorpo); cellObs.addElement(pSeg8); cellObs.addElement(pSeg8); cellObs.setBorderWidthBottom(0.6f); cellObs.addElement(pObs); PdfPCell cellObs1 = new PdfPCell(); cellObs1.setBorder(0); Paragraph pObs1 = new Paragraph( "Sobre artigos domsticos e afetos pessoais incluindo mobilias e instalaes, a proprriedade do Seguro ou" + "ou em fiana ou sobre comisso do qual o Segurado responsavel enqunto estiver num edificio de contruo padro.", fontCorpo); cellObs1.addElement(pObs1); cellObs1.addElement(pSeg8); cellObs1.addElement(pSeg8); pTableObs.addCell(cellObs); pTableObs.addCell(cellObs1); PdfPTable pTableOjsSegurado = new PdfPTable(new float[] { 8, 40, 26, 26 }); pTableOjsSegurado.setWidthPercentage(90); PdfPTable pTableOjsSegurado1 = new PdfPTable(new float[] { 74, 26 }); pTableOjsSegurado1.setWidthPercentage(90); PdfPCell cellOjsSegurado1 = new PdfPCell(new Phrase("Quant.", fontCorpoNG)); PdfPCell cellOjsSegurado2 = new PdfPCell( new Phrase("Descrio de Propriedade".toUpperCase(), fontCorpoNG)); PdfPCell cellOjsSegurado3 = new PdfPCell( new Phrase("Modelo No/n DE Serie".toUpperCase(), fontCorpoNG)); PdfPCell cellOjsSegurado4 = new PdfPCell(new Phrase("Valor Segurado".toUpperCase(), fontCorpoNG)); cellOjsSegurado1.setHorizontalAlignment(Element.ALIGN_CENTER); cellOjsSegurado2.setHorizontalAlignment(Element.ALIGN_CENTER); cellOjsSegurado3.setHorizontalAlignment(Element.ALIGN_CENTER); cellOjsSegurado4.setHorizontalAlignment(Element.ALIGN_CENTER); pTableOjsSegurado.addCell(cellOjsSegurado1); pTableOjsSegurado.addCell(cellOjsSegurado2); pTableOjsSegurado.addCell(cellOjsSegurado3); pTableOjsSegurado.addCell(cellOjsSegurado4); Double valortotal = 0.0; for (Roubo r : rb.getInfo()) { cellOjsSegurado1 = new PdfPCell(new Phrase(r.getQuantidade(), fontCorpo)); cellOjsSegurado2 = new PdfPCell(new Phrase(r.getDescricao(), fontCorpo)); cellOjsSegurado3 = new PdfPCell(new Phrase(r.getModelo(), fontCorpo)); cellOjsSegurado4 = new PdfPCell(new Phrase(r.getValor(), fontCorpo)); valortotal += Double.valueOf(r.getValor()); cellOjsSegurado1.setHorizontalAlignment(Element.ALIGN_LEFT); cellOjsSegurado2.setHorizontalAlignment(Element.ALIGN_LEFT); cellOjsSegurado3.setHorizontalAlignment(Element.ALIGN_CENTER); cellOjsSegurado4.setHorizontalAlignment(Element.ALIGN_LEFT); pTableOjsSegurado.addCell(cellOjsSegurado1); pTableOjsSegurado.addCell(cellOjsSegurado2); pTableOjsSegurado.addCell(cellOjsSegurado3); pTableOjsSegurado.addCell(cellOjsSegurado4); } PdfPCell cellOjs1Segurado1 = new PdfPCell(new Phrase( "Somatrio ----------------------------------------------------------------------------------------------" .toUpperCase(), fontCorpo)); cellOjs1Segurado1.setHorizontalAlignment(Element.ALIGN_CENTER); PdfPCell cellOjs1Segurado2 = new PdfPCell(new Phrase(valortotal + "", fontCorpo)); cellOjs1Segurado2.setHorizontalAlignment(Element.ALIGN_LEFT); pTableOjsSegurado1.addCell(cellOjs1Segurado1); pTableOjsSegurado1.addCell(cellOjs1Segurado2); PdfPTable pTableAssinaturaTitulo = new PdfPTable(1); PdfPTable pTableAssinatura = new PdfPTable(new float[] { 50f, 50f }); PdfPCell cellAssinatora = new PdfPCell(new Phrase("Assinaturas".toUpperCase(), fontCorpoN)); cellAssinatora.setBorder(0); cellAssinatora.setHorizontalAlignment(Element.ALIGN_CENTER); PdfPCell celllinha1 = new PdfPCell( new Phrase("____________________________________________".toUpperCase(), fontCorpo)); celllinha1.setBorder(0); celllinha1.setHorizontalAlignment(Element.ALIGN_CENTER); PdfPCell celllinha2 = new PdfPCell( new Phrase("____________________________________________".toUpperCase(), fontCorpo)); celllinha2.setBorder(0); celllinha2.setHorizontalAlignment(Element.ALIGN_CENTER); PdfPCell celllinha11 = new PdfPCell(new Phrase("para nicon Seguro sa stp".toUpperCase(), fontCorpoP)); celllinha11.setBorder(0); celllinha11.setHorizontalAlignment(Element.ALIGN_CENTER); PdfPCell celllinha21 = new PdfPCell(new Phrase("o segurado ".toUpperCase(), fontCorpoP)); celllinha21.setBorder(0); celllinha21.setHorizontalAlignment(Element.ALIGN_CENTER); pTableAssinaturaTitulo.addCell(cellAssinatora); pTableAssinatura.addCell(celllinha1); pTableAssinatura.addCell(celllinha2); pTableAssinatura.addCell(celllinha11); pTableAssinatura.addCell(celllinha21); Document documento = new Document(); documento.setPageSize(PageSize.A4); documento.setMargins(20f, 20f, 35f, 5f); // File ff= new File("Documentos\\"+user+"\\Seguro Roubo\\"); // ff.mkdirs(); // ff =new File(ff.getAbsoluteFile()+"\\"+"Formulario Seguro Roubo "+sdf1.format(new Date())+".pdf"); File ff = new File(arquivo + "/" + user + "/Seguro Roubo/"); ff.mkdirs(); String Ddata = sdf1.format(new Date()); ff = new File(ff.getAbsoluteFile() + "/" + "Formulario Seguro Roubo " + Ddata + ".pdf"); reString = "../Documentos/" + user + "/Seguro Roubo/" + "Formulario Seguro Roubo " + Ddata + ".pdf"; OutputStream outputStraem = new FileOutputStream(ff); PdfWriter writer = PdfWriter.getInstance(documento, outputStraem); if (MarcaDAgua.isSimulation) { MarcaDAgua.SimulacaoVertical v = new MarcaDAgua.SimulacaoVertical(); writer.setPageEvent(v); } if (MarcaDAgua.isCanceled) { MarcaDAgua.AnulacaoVertical v = new MarcaDAgua.AnulacaoVertical(); writer.setPageEvent(v); } documento.open(); documento.add(pTableEmpresaPricipal); documento.add(pTableNull); documento.add(pTableTitulo); documento.add(pTableNull); documento.add(pTableCliente); documento.add(pTableNull); documento.add(pTableDadosTitulo); documento.add(pTableNull); documento.add(pTableSeguro); documento.add(pTableNull); documento.add(pTableAssinaturaTitulo); documento.add(pTableNull); documento.add(pTableNull); documento.add(pTableAssinatura); if (rb.getInfo().size() >= 10) { documento.newPage(); } documento.add(pTableObs); documento.add(pTableOjsSegurado); documento.add(pTableOjsSegurado1); documento.close(); // PrintPdf printPdf = new PrintPdf(ff.getAbsolutePath(), ff.getAbsolutePath(), 0, 595f,842f,"Enviar Para o OneNote 2013",1); //PrintPdf printPdf = new PrintPdf(ff.getAbsolutePath(), ff.getAbsolutePath(), 0, 595f,842f,"Hewlett-Packard HP LaserJet P2035",1); // printPdf.print(); } catch (BadElementException | IOException ex) { Logger.getLogger(SeguroAPG.class.getName()).log(Level.SEVERE, null, ex); } catch (DocumentException ex) { Logger.getLogger(SeguroAPG.class.getName()).log(Level.SEVERE, null, ex); } return reString; }
From source file:Export.SeguroViagem.java
public String criarDoc(ViagemBean vb, String numCriente, String user, String arquivo, Contrato c) { try {// www . j a v a2s .co m PdfPTable pTablePrincaipal; // PdfPTable pTableSegu1; PdfPTable pTableSegu2; SimpleDateFormat sdf = new SimpleDateFormat("dd-MM-yyyy hh'.'mm'.'ss"); SimpleDateFormat sdfPot = new SimpleDateFormat("dd/MM/yyyy"); Font fontCorpoN = FontFactory.getFont(Fontes.FONTB, BaseFont.WINANSI, BaseFont.EMBEDDED, 7.9f); Font fontCorpo = FontFactory.getFont(Fontes.FONT, BaseFont.WINANSI, BaseFont.EMBEDDED, 7.9f); // PdfPTable pTableLinha = new PdfPTable(1); // pTableLinha.setWidthPercentage(95); // PdfPCell linha= new PdfPCell(new Phrase(" ")); // // linha.setBorderWidthTop(0.5f); // linha.setBorderWidthBottom(0); // linha.setBorderWidthLeft(0); // linha.setBorderWidthRight(0); // pTableLinha.addCell(linha); Document documento = new Document(); documento.setPageSize(PageSize.A4); documento.setMargins(20f, 20f, 138f, 5f); File ff = new File(arquivo + "/" + user + "/Seguro Viagem/"); ff.mkdirs(); String Ddata = sdf.format(new Date()); ff = new File(ff.getAbsoluteFile() + "/" + "Doc Seguro Viagem " + Ddata + ".pdf"); reString = "../Documentos/" + user + "/Seguro Viagem/" + "Doc Seguro Viagem " + Ddata + ".pdf"; outputStraem = new FileOutputStream(ff); PdfWriter writer = PdfWriter.getInstance(documento, outputStraem); if (MarcaDAgua.isSimulation) { MarcaDAgua.SimulacaoVertical v = new MarcaDAgua.SimulacaoVertical(); writer.setPageEvent(v); } if (MarcaDAgua.isCanceled) { MarcaDAgua.AnulacaoVertical v = new MarcaDAgua.AnulacaoVertical(); writer.setPageEvent(v); } documento.open(); int total = vb.getInfoPessoaSegurada().size(); for (int i = 0; i < total; i++) { pTablePrincaipal = new PdfPTable(1); pTablePrincaipal.setWidthPercentage(98f); // pTableSegu1 = new PdfPTable(1); // pTableSegu1.setWidthPercentage(95); pTableSegu2 = new PdfPTable(new float[] { 55f, 45f }); pTableSegu2.setWidthPercentage(100f); // PdfPCell cellTitulo= new PdfPCell(new Phrase("Lista Pessoas Seguradas",fontCabecalhoN)); // cellTitulo.setBorder(0); PdfPCell cellNull = new PdfPCell(new Phrase(" ", fontCorpo)); cellNull.setBorder(0); // if(((i)%6)==0) // { // pTableSegu1.addCell(cellTitulo); // pTableSegu1.addCell(cellNull); // } // Paragraph pCl = new Paragraph(); pCl.add(new Phrase("Nome do Segurado: ".toUpperCase(), fontCorpo)); pCl.add(new Phrase(vb.getInfoPessoaSegurada().get(i).getNomePessoaSegurada().toUpperCase(), fontCorpoN)); PdfPCell cellNome = new PdfPCell(pCl); cellNome.setColspan(2); cellNome.setBorder(0); pTableSegu2.addCell(cellNome); // PdfPCell cellNum= new PdfPCell(new Phrase(""+(i+1),fontCorpo)); // cellNum.setBorder(0); // cellNum.setHorizontalAlignment(Element.ALIGN_RIGHT); // pTableSegu2.addCell(cellNum); pCl = new Paragraph(); pCl.add(new Phrase("Endereo: ".toUpperCase(), fontCorpo)); pCl.add(new Phrase(vb.getInfoPessoaSegurada().get(i).getEndereco().toUpperCase(), fontCorpoN)); PdfPCell cellEndereco = new PdfPCell(pCl); cellEndereco.setBorder(0); pTableSegu2.addCell(cellEndereco); pTableSegu2.addCell(cellNull); pCl = new Paragraph(); pCl.add(new Phrase("Data e Local Nascimento: ".toUpperCase(), fontCorpo)); pCl.add(new Phrase(vb.getInfoPessoaSegurada().get(i).getDataNascFormatada(), fontCorpoN)); pCl.add(new Phrase(" em ", fontCorpo)); pCl.add(new Phrase(vb.getInfoPessoaSegurada().get(i).getLocalNascimento(), fontCorpoN)); PdfPCell cellNascDaNascloc = new PdfPCell(pCl); cellNascDaNascloc.setBorder(0); pCl = new Paragraph(); pCl.add(new Phrase("Sexo: ".toUpperCase(), fontCorpo)); pCl.add(new Phrase(vb.getInfoPessoaSegurada().get(i).getSexo(), fontCorpoN)); pCl.add(new Phrase(" Tel.N ", fontCorpo)); pCl.add(new Phrase(vb.getInfoPessoaSegurada().get(i).getTelefone(), fontCorpoN)); PdfPCell cellSexo = new PdfPCell(pCl); cellSexo.setBorder(0); pTableSegu2.addCell(cellNascDaNascloc); pTableSegu2.addCell(cellSexo); pCl = new Paragraph(); pCl.add(new Phrase("Apolice: ".toUpperCase(), fontCorpo)); pCl.add(new Phrase(vb.getInfoPessoaSegurada().get(i).getNumApolice(), fontCorpoN)); PdfPCell cellApolice = new PdfPCell(pCl); cellApolice.setBorder(0); pCl = new Paragraph(); pCl.add(new Phrase("Cliente: ".toUpperCase(), fontCorpo)); String[] codCliente = vb.getInfoPessoaSegurada().get(i).getNumApolice().split("/"); pCl.add(new Phrase(((codCliente.length == 2) ? "TIN " + codCliente[1] : "TIN "), fontCorpoN)); PdfPCell cellCliente = new PdfPCell(pCl); cellCliente.setBorder(0); pTableSegu2.addCell(cellApolice); pTableSegu2.addCell(cellCliente); pCl = new Paragraph(); pCl.add(new Phrase("Durao: ".toUpperCase(), fontCorpo)); pCl.add(new Phrase(vb.getInfoPessoaSegurada().get(i).getNumDias() + " DIAS", fontCorpoN)); PdfPCell cellDuracao = new PdfPCell(pCl); cellDuracao.setBorder(0); pCl = new Paragraph(); pCl.add(new Phrase("Perodo: de ".toUpperCase(), fontCorpo)); pCl.add(new Phrase(sdfPot.format(vb.getInfoPessoaSegurada().get(i).getDataInicio()), fontCorpoN)); pCl.add(new Phrase(" ", fontCorpo)); pCl.add(new Phrase(((vb.getInfoPessoaSegurada().get(i).getDataFim() != null) ? sdfPot.format(vb.getInfoPessoaSegurada().get(i).getDataFim()) : " "), fontCorpoN)); PdfPCell cellPeriodo = new PdfPCell(pCl); cellPeriodo.setBorder(0); pTableSegu2.addCell(cellDuracao); pTableSegu2.addCell(cellPeriodo); pCl = new Paragraph(); pCl.add(new Phrase("Data de Emisso: ".toUpperCase(), fontCorpo)); pCl.add(new Phrase(sdfPot.format(c.getDataContrato()), fontCorpoN)); PdfPCell cellDataEmissao = new PdfPCell(pCl); cellDataEmissao.setBorder(0); pCl = new Paragraph(); pCl.add(new Phrase("Destino: ".toUpperCase(), fontCorpo)); pCl.add(new Phrase( ClienteDao.paisesSelected(vb.getInfoPessoaSegurada().get(i).getPaisDestino().toUpperCase()) + " ", fontCorpoN)); pCl.add(new Phrase("N de Pessoas: ", fontCorpo)); pCl.add(new Phrase((i + 1) + "", fontCorpoN)); PdfPCell cellDestino = new PdfPCell(pCl); cellDestino.setBorder(0); pTableSegu2.addCell(cellDataEmissao); pTableSegu2.addCell(cellDestino); pCl = new Paragraph(); pCl.add(new Phrase("Meio de Identificao: ".toUpperCase(), fontCorpo)); pCl.add(new Phrase( ((vb.getInfoPessoaSegurada().get(i).getTipoDoc().toUpperCase().equals("PASSAPORTE")) ? "PASS" : (vb.getInfoPessoaSegurada().get(i).getTipoDoc().toUpperCase() .equals("BILHETE IDENTIDADE") ? "BI" : vb.getInfoPessoaSegurada().get(i).getTipoDoc().toUpperCase())), fontCorpoN)); pCl.add(new Phrase(" N ", fontCorpo)); pCl.add(new Phrase(vb.getInfoPessoaSegurada().get(i).getNumDoc(), fontCorpoN)); PdfPCell cellEmiDocNum = new PdfPCell(pCl); cellEmiDocNum.setBorder(0); pCl = new Paragraph(); pCl.add(new Phrase("Emitido em: ".toUpperCase(), fontCorpo)); pCl.add(new Phrase(vb.getInfoPessoaSegurada().get(i).getLocalEmissao().toUpperCase() + " ", fontCorpoN)); pCl.add(new Phrase("em ", fontCorpo)); pCl.add(new Phrase(vb.getInfoPessoaSegurada().get(i).getDataEmissaoFormatada(), fontCorpoN)); PdfPCell cellEmiDoc = new PdfPCell(pCl); cellEmiDoc.setBorder(0); pTableSegu2.addCell(cellEmiDocNum); pTableSegu2.addCell(cellEmiDoc); pCl = new Paragraph(); pCl.add(new Phrase("Outras Informaes: ".toUpperCase(), fontCorpo)); pCl.add(new Phrase( ((vb.getInfoPessoaSegurada().get(i).getOutrasInformacoes() == null) ? " " : vb.getInfoPessoaSegurada().get(i).getOutrasInformacoes().toUpperCase()), fontCorpoN)); PdfPCell cellOutraInf = new PdfPCell(pCl); cellOutraInf.setColspan(2); cellOutraInf.setBorder(0); pTableSegu2.addCell(cellOutraInf); // PdfPCell cellSegui1 = new PdfPCell(); // cellSegui1.addElement(pTableSegu1); // cellSegui1.setBorder(0); PdfPCell cellSegui2 = new PdfPCell(); cellSegui2.addElement(pTableSegu2); cellSegui2.setBorder(0); // PdfPCell cellSeguiT = new PdfPCell(); // cellSeguiT.addElement(pTableLinha); // cellSeguiT.setBorder(0); // pTablePrincaipal.addCell(cellSegui1); pTablePrincaipal.addCell(cellSegui2); // if((i+1)<total&&((i+1)%6)!=0) // pTablePrincaipal.addCell(cellSeguiT); // documento.add(pTablePrincaipal); // // System.err.println((((i+1)%6)==0)+" "+(i+1)); if ((i + 1) != total) { documento.newPage(); } } documento.close(); return reString; } catch (DocumentException | IOException ex) { Logger.getLogger(SeguroViagem.class.getName()).log(Level.SEVERE, null, ex); return reString; } }
From source file:Export.SeguroViatura.java
public String criarDoc(String numApolice, String numCliente, Contrato c, VeiculoBean vb, String user, String arquivo) {/* ww w .j ava2s. c o m*/ try { SimpleDateFormat sdf = new SimpleDateFormat("dd-MM-yyyy"); SimpleDateFormat sdf1 = new SimpleDateFormat("dd-MM-yyyy hh'.'mm'.'ss"); Font fontCabecalhoN = FontFactory.getFont(Fontes.FONTB, BaseFont.WINANSI, BaseFont.EMBEDDED, 10.5f); Font fontCorpo = FontFactory.getFont(Fontes.FONT, BaseFont.WINANSI, BaseFont.EMBEDDED, 9f); Font fontCorpoTabT = FontFactory.getFont(Fontes.FONTB, BaseFont.WINANSI, BaseFont.EMBEDDED, 6.5f); Font fontCorpoTab = FontFactory.getFont(Fontes.FONT, BaseFont.WINANSI, BaseFont.EMBEDDED, 6.5f); Font fontCorpoP = FontFactory.getFont(Fontes.FONT, BaseFont.WINANSI, BaseFont.EMBEDDED, 8f); Font fontCorpoN = FontFactory.getFont(Fontes.FONTB, BaseFont.WINANSI, BaseFont.EMBEDDED, 9f); Font fontCorpoNG = FontFactory.getFont(Fontes.FONTB, BaseFont.WINANSI, BaseFont.EMBEDDED, 9.5f); Font fontCorpoNGT = FontFactory.getFont(Fontes.FONTB, BaseFont.WINANSI, BaseFont.EMBEDDED, 10f); Font fontCabecalhoNG = FontFactory.getFont(Fontes.FONTB, BaseFont.WINANSI, BaseFont.EMBEDDED, 16f, Font.UNDERLINE); Font fontUK = FontFactory.getFont(Fontes.FONT, BaseFont.WINANSI, BaseFont.EMBEDDED, 6f, Font.ITALIC); Font fontUKb = FontFactory.getFont(Fontes.FONTB, BaseFont.WINANSI, BaseFont.EMBEDDED, 6f, Font.ITALIC); PdfPTable pTableEmpresaPricipal = new PdfPTable(new float[] { 25f, 75f }); pTableEmpresaPricipal.setWidthPercentage(88f); PdfPTable pTableEmpresaInforImpres1 = new PdfPTable(1); // PdfPTable pTableEmpresaInforImpres2 = 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(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); PdfPCell pCellPolice = new PdfPCell(new Phrase(Empresa.APOLICE + numApolice, fontCabecalhoN)); pCellPolice.setBorder(0); Image imageEmpresa = Image.getInstance("logo.png"); imageEmpresa.scaleToFit(190f, 100f); pTableEmpresaInforImpres1.addCell(pCellNomeEmpresa); pTableEmpresaInforImpres1.addCell(pCellNomeEndereco); pTableEmpresaInforImpres1.addCell(pCellCaixaPostal); pTableEmpresaInforImpres1.addCell(pCellTeleFax); pTableEmpresaInforImpres1.addCell(pCellSociedade); pTableEmpresaInforImpres1.addCell(pCellPolice); 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.addCell(cellTabela6); pTableEmpresaPricipal.addCell(cellTabela5); PdfPTable pTableSeguro = new PdfPTable(1); pTableSeguro.setWidthPercentage(88f); PdfPTable pTableCliente = new PdfPTable(1); pTableCliente.setWidthPercentage(88f); PdfPTable pTableTitulo = new PdfPTable(1); pTableTitulo.setWidthPercentage(88f); Paragraph paTitulo = new Paragraph(); Paragraph pTitulo = new Paragraph("resumo de aplice para Automvel".toUpperCase(), fontCorpoNGT); Paragraph pTituloUk = new Paragraph("\nthe motor policy sumay".toUpperCase(), fontUKb); paTitulo.add(pTitulo); paTitulo.add(pTituloUk); PdfPCell cellTitulo = new PdfPCell(paTitulo); cellTitulo.setBorder(0); cellTitulo.setHorizontalAlignment(Element.ALIGN_CENTER); pTableTitulo.addCell(cellTitulo); ClienteI ci = new ClienteI(numCliente); Paragraph para = new Paragraph(); Paragraph phrase = new Paragraph("1 - Informaes Do Cliente".toUpperCase(), fontCorpoNG); Paragraph paraUK = new Paragraph("\n1 - Customer information".toUpperCase(), fontUKb); para.add(phrase); para.add(paraUK); PdfPCell cellTituloTsbleSegurado = new PdfPCell(para); cellTituloTsbleSegurado.setBorder(0); Paragraph pCl = new Paragraph(); pCl.add(new Phrase(ci.getNOMEL_(), fontCorpo)); pCl.add(new Phrase(ci.getNOME_(), fontCorpoN)); pCl.add(new Phrase("\nNAME:", fontUK)); PdfPCell cellNome = new PdfPCell(new Phrase(pCl)); cellNome.setBorder(0); pCl = new Paragraph(); pCl.add(new Phrase(ci.getENDERECOL_(), fontCorpo)); pCl.add(new Phrase(ci.getENDERECO_(), fontCorpoN)); pCl.add(new Phrase("\nADDRESS:", fontUK)); PdfPCell cellEndereco = new PdfPCell(pCl); cellEndereco.setBorder(0); /** pCl = new Paragraph(); pCl.add(new Phrase(" " +ci.getNUNCLIENTEL_(),fontCorpo)); pCl.add(new Phrase(ci.getNUNCLIENTE_(),fontCorpoN)); PdfPCell cellNCliente = new PdfPCell( pCl ); cellNCliente.setBorder(0); * */ pCl = new Paragraph(); pCl.add(new Phrase(ci.getPROFISSAOL_(), fontCorpo)); pCl.add(new Phrase(ci.getPROFISSAO_(), fontCorpoN)); pCl.add(new Phrase("\nPROFISSION/OCCUPATION/ACTIVITY AREA:", fontUK)); PdfPCell cellProfissao = new PdfPCell(pCl); cellProfissao.setBorder(0); pCl = new Paragraph(); pCl.add(new Phrase(ci.getLOCALTRABALHOL_(), fontCorpo)); pCl.add(new Phrase(ci.getLOCALTRABALHO_(), fontCorpoN)); pCl.add(new Phrase("\nPLACE OF WORK", fontUK)); PdfPCell cellLocalTrabalho = new PdfPCell(pCl); cellLocalTrabalho.setBorder(0); cellNome.setPaddingTop(7f); cellNome.setPaddingBottom(7f); cellNome.setBorder(0); cellEndereco.setPaddingTop(7f); cellEndereco.setPaddingBottom(7f); cellEndereco.setBorder(0); // PdfPCell cellNCliente= new PdfPCell( new Phrase(" "+ci.getNUNCLIENTE(),fontCorpo));cellNome.setPaddingTop(5f); // cellNCliente.setPaddingTop(7f); // cellNCliente.setPaddingBottom(7f); // cellNCliente.setBorder(0); cellProfissao.setPaddingTop(7f); cellProfissao.setPaddingBottom(7f); cellProfissao.setBorder(0); cellLocalTrabalho.setPaddingTop(7f); cellLocalTrabalho.setPaddingBottom(7f); cellLocalTrabalho.setBorder(0); pTableCliente.addCell(cellTituloTsbleSegurado); pTableCliente.addCell(cellNome); pTableCliente.addCell(cellEndereco); // pTableCliente.addCell(cellNCliente); pTableCliente.addCell(cellProfissao); pTableCliente.addCell(cellLocalTrabalho); para = new Paragraph(); Paragraph p = new Paragraph("3 - Premio E Cobertura".toUpperCase(), fontCorpoNG); Paragraph p1 = new Paragraph("\n3 - PREMIUM AND COVER".toUpperCase(), fontUKb); para.add(p); para.add(p1); PdfPCell cellTiltuloSegro = new PdfPCell(para); cellTiltuloSegro.setPaddingTop(7f); cellTiltuloSegro.setPaddingBottom(7f); cellTiltuloSegro.setBorder(0); // PdfPCell cellApolice= new PdfPCell( new Phrase(" N Aplice: ".toUpperCase()+numApolice,fontCorpo)); // cellApolice.setPaddingTop(7f); // cellApolice.setPaddingBottom(7f); // cellApolice.setBorder(0); Paragraph pTotalSegurado = new Paragraph(); pTotalSegurado.add(new Phrase("Prmio: ".toUpperCase().toUpperCase(), fontCorpo)); /** * * * ildo - premio liquido -> */ pTotalSegurado.add(new Phrase( ((c.getPremioLiquidoMoeda() == null /*&& vb.getVeiculo().getTipoCobertura().equals("41") */ ) ? " " : c.getPremioLiquidoMoeda() + " " + c.getSigla()), fontCorpoN)); pTotalSegurado.add(new Phrase("\nPREMIUM", fontUK)); PdfPCell cellTotalSegurado = new PdfPCell(pTotalSegurado); cellTotalSegurado.setPaddingTop(7f); cellTotalSegurado.setPaddingBottom(7f); cellTotalSegurado.setBorder(0); Paragraph pExcesso = new Paragraph(); pExcesso.add(new Phrase("Excesso: ".toUpperCase(), fontCorpo)); pExcesso.add(new Phrase((c.getFranquia() == null) ? "No aplicvel".toUpperCase() : c.getFranquia(), fontCorpoN)); pExcesso.add(new Phrase("\nEXCESS: ", fontUK)); PdfPCell cellExcesso = new PdfPCell(pExcesso); cellExcesso.setPaddingTop(7f); cellExcesso.setPaddingBottom(7f); cellExcesso.setBorder(0); // PdfPCell cellValor1Preminio= new PdfPCell( new Phrase(" Valor Primeiro Premio: ".toUpperCase()+((c.getPrimeiroPremio()==null)?" ":c.getPrimeiroPremio()),fontCorpo)); // cellValor1Preminio.setPaddingTop(7f); // cellValor1Preminio.setPaddingBottom(7f); // cellValor1Preminio.setBorder(0); // // PdfPCell cellTotalPremioAnual= new PdfPCell( new Phrase(" Valor Premio Anual: ".toUpperCase()+((c.getPremioAnual()==null)?" ":c.getPremioAnual()),fontCorpo)); // cellTotalPremioAnual.setPaddingTop(7f); // cellTotalPremioAnual.setPaddingBottom(7f); // cellTotalPremioAnual.setBorder(0); // PdfPCell cellPeriodo= new PdfPCell( new Phrase(" Periodo Do Seguro: ".toUpperCase()+((c.getDataInicio()!= null) ? sdf.format(c.getDataInicio()): " " )+" "+((c.getDataFim()!= null) ? sdf.format(c.getDataFim()): " " ),fontCorpo)); // cellPeriodo.setPaddingTop(7f); // cellPeriodo.setPaddingBottom(7f); // cellPeriodo.setBorder(0) Paragraph pDataRenovacao = new Paragraph(); pDataRenovacao.add(new Phrase("Data Renovao de Seguro: ".toUpperCase(), fontCorpo)); pDataRenovacao.add(new Phrase(((c.getDataRenovacao() != null) ? sdf.format(c.getDataRenovacao()) : " "), fontCorpoN)); pDataRenovacao.add(new Phrase("\nRENEWAL DATE OF COVER", fontUK)); PdfPCell cellDataRenovacao = new PdfPCell(pDataRenovacao); cellDataRenovacao.setPaddingTop(7f); cellDataRenovacao.setPaddingBottom(7f); cellDataRenovacao.setBorder(0); Paragraph pTipoCobert = new Paragraph(); pTipoCobert.add(new Phrase("Tipo De Cobertura: ".toUpperCase(), fontCorpo)); pTipoCobert .add(new Phrase( ((vb.getVeiculo().getTipoCobertura() != null) ? (vb.getVeiculo().getTipoCobertura().equals("41") ? "Contra Terceiros".toUpperCase() : (vb.getVeiculo().getTipoCobertura().equals("42") ? "CONTRA Todos os riscos".toUpperCase() : (vb.getVeiculo().getTipoCobertura().equals("43") ? "Compreensivo limitado".toUpperCase() : vb.getVeiculo().getTipoCobertura()))) : " "), fontCorpoN)); pTipoCobert.add(new Phrase("\nTYPE OF CAVER", fontUK)); PdfPCell cellTipoCobert = new PdfPCell(pTipoCobert); cellTipoCobert.setPaddingTop(7f); cellTipoCobert.setPaddingBottom(7f); cellTipoCobert.setBorder(0); Paragraph pLimiteArea = new Paragraph(); pLimiteArea.add(new Phrase("Limite de rea geogrfica: ".toUpperCase(), fontCorpo)); pLimiteArea.add(new Phrase("so Tom e principe".toUpperCase(), fontCorpoN)); pLimiteArea.add(new Phrase("\nLIMIT OF GEOGRAPHICAL AREA".toUpperCase(), fontUK)); PdfPCell cellLimiteArea = new PdfPCell(pLimiteArea); cellLimiteArea.setPaddingTop(7f); cellLimiteArea.setPaddingBottom(7f); cellLimiteArea.setBorder(0); Paragraph pLeis = new Paragraph(); pLeis.add(new Phrase("legislao: ".toUpperCase(), fontCorpo)); pLeis.add(new Phrase("artigos 1 36, lei n 30/2000 da repblica democrtica de stp".toUpperCase(), fontCorpoN)); pLeis.add(new Phrase("\nLEGISLATION: ", fontUK)); pLeis.add(new Phrase("ARTICLES 1 TO 36, LAW NO 30/2000 OF THE DEMOCRATIC REPUBLIC OF STP", fontUKb)); PdfPCell cellLeis = new PdfPCell(pLeis); cellLeis.setPaddingTop(7f); cellLeis.setPaddingBottom(7f); cellLeis.setBorder(0); pTableSeguro.addCell(cellTiltuloSegro); // pTableSeguro.addCell(cellApolice); pTableSeguro.addCell(cellTotalSegurado); // pTableSeguro.addCell(cellValor1Preminio); // pTableSeguro.addCell(cellTotalPremioAnual); pTableSeguro.addCell(cellExcesso); pTableSeguro.addCell(cellDataRenovacao); pTableSeguro.addCell(cellTipoCobert); pTableSeguro.addCell(cellLimiteArea); pTableSeguro.addCell(cellLeis); PdfPTable pTableDadosTitulo = new PdfPTable(1); pTableDadosTitulo.setWidthPercentage(88f); para = new Paragraph(); Phrase PDadosTitulo = new Phrase("2 - Informaes do(s) Veculo(s)".toUpperCase(), fontCorpoN); Phrase PDadosTitulos = new Phrase("\n2 - VEHICLE (S) INFORMATIONS".toUpperCase(), fontUKb); para.add(PDadosTitulo); para.add(PDadosTitulos); PdfPCell cellDadosTitulo = new PdfPCell(para); cellDadosTitulo.setBorder(0); pTableDadosTitulo.addCell(cellDadosTitulo); pTableDadosTitulo.addCell(cellNull); PdfPTable pTableDados = new PdfPTable(new float[] { 13.5f, 13.5f, 14, 17, 16, 12, 14 }); pTableDados.setWidthPercentage(88f); para = new Paragraph(); Phrase PMarca = new Phrase("Marca".toUpperCase(), fontCorpoTabT); Phrase PMarcaUK = new Phrase("\nMARK".toUpperCase(), fontUK); para.add(PMarca); para.add(PMarcaUK); PdfPCell cellMarca = new PdfPCell(para); cellMarca.setPaddingTop(5f); cellMarca.setPaddingBottom(5f); cellMarca.setHorizontalAlignment(Element.ALIGN_CENTER); para = new Paragraph(); Paragraph PModelo = new Paragraph("Modelo".toUpperCase(), fontCorpoTabT); Paragraph PModeloUK = new Paragraph("\nMODEL".toUpperCase(), fontUK); para.add(PModelo); para.add(PModeloUK); PdfPCell cellModelo = new PdfPCell(para); cellModelo.setHorizontalAlignment(Element.ALIGN_CENTER); cellModelo.setPaddingTop(5f); cellModelo.setPaddingBottom(5f); para = new Paragraph(); Phrase PMatricula = new Phrase("NO DE MATR?CULA".toUpperCase(), fontCorpoTabT); Phrase PMatriculaUK = new Phrase("\nREG. NUMBER".toUpperCase(), fontUK); para.add(PMatricula); para.add(PMatriculaUK); PdfPCell cellMatricula = new PdfPCell(para); cellMatricula.setHorizontalAlignment(Element.ALIGN_CENTER); cellMatricula.setPaddingTop(5f); cellMatricula.setPaddingBottom(5f); para = new Paragraph(); Phrase PChasii = new Phrase("No. de chissi/Motor".toUpperCase(), fontCorpoTabT); Phrase PChasiiUK = new Phrase("\nchissiS/ENGINE NO.".toUpperCase(), fontUK); para.add(PChasii); para.add(PChasiiUK); PdfPCell cellChasii = new PdfPCell(para); cellChasii.setHorizontalAlignment(Element.ALIGN_CENTER); cellChasii.setPaddingTop(5f); cellChasii.setPaddingBottom(5f); para = new Paragraph(); Phrase PAnoFabricoCompra = new Phrase("ano de Fabrico/Compra".toUpperCase(), fontCorpoTabT); Phrase PAnoFabricoCompraUK = new Phrase("\nYear of Manufacture/PURCHASE".toUpperCase(), fontUK); para.add(PAnoFabricoCompra); para.add(PAnoFabricoCompraUK); PdfPCell cellAnoFabricoCompra = new PdfPCell(para); cellAnoFabricoCompra.setHorizontalAlignment(Element.ALIGN_CENTER); cellAnoFabricoCompra.setPaddingTop(5f); cellAnoFabricoCompra.setPaddingBottom(5f); para = new Paragraph(); Phrase PTotalLuagares = new Phrase("lotao".toUpperCase(), fontCorpoTabT); Phrase PTotalLuagaresUK = new Phrase("\nSTOCKING", fontUK); para.add(PTotalLuagares); para.add(PTotalLuagaresUK); PdfPCell cellTotalLuagares = new PdfPCell(para); cellTotalLuagares.setHorizontalAlignment(Element.ALIGN_CENTER); cellTotalLuagares.setPaddingTop(5f); cellTotalLuagares.setPaddingBottom(5f); para = new Paragraph(); Phrase PDadosValorSeguro = new Phrase("Estimativa / Valor Segurado".toUpperCase(), fontCorpoTabT); Phrase PDadosValorSeguroUK = new Phrase("\nEstimation / Amount Insured".toUpperCase(), fontUK); para.add(PDadosValorSeguro); para.add(PDadosValorSeguroUK); PdfPCell cellDadosValorSeguro = new PdfPCell(para); cellDadosValorSeguro.setHorizontalAlignment(Element.ALIGN_CENTER); cellDadosValorSeguro.setPaddingTop(5f); cellDadosValorSeguro.setPaddingBottom(5f); pTableDados.addCell(cellMarca); pTableDados.addCell(cellModelo); pTableDados.addCell(cellMatricula); pTableDados.addCell(cellChasii); pTableDados.addCell(cellAnoFabricoCompra); pTableDados.addCell(cellTotalLuagares); pTableDados.addCell(cellDadosValorSeguro); int total = vb.getInfo().size(); for (int i = 0; i < total; i++) { cellMarca = new PdfPCell( new Phrase((vb.getInfo().get(i).getMarca() == null) ? " " : vb.getInfo().get(i).getMarca(), fontCorpoTab)); cellMarca.setHorizontalAlignment(Element.ALIGN_CENTER); cellModelo = new PdfPCell(new Phrase( (vb.getInfo().get(i).getModelo() == null) ? " " : vb.getInfo().get(i).getModelo(), fontCorpoTab)); cellModelo.setHorizontalAlignment(Element.ALIGN_CENTER); cellMatricula = new PdfPCell( new Phrase(((vb.getInfo().get(i).getNumeroMatricula() == null) ? ".........." : vb.getInfo().get(i).getNumeroMatricula()), fontCorpoTab)); cellMatricula.setHorizontalAlignment(Element.ALIGN_CENTER); cellDadosValorSeguro = new PdfPCell(new Phrase( ((vb.getInfo().get(i).getValorAtual() == null || vb.getInfo().get(i).getValorAtual().isEmpty() || vb.getVeiculo().getTipoCobertura().equals("41")) ? " NA " : Moeda.format(Double.valueOf(vb.getInfo().get(i).getValorAtual()))), fontCorpoTab)); cellDadosValorSeguro.setHorizontalAlignment(Element.ALIGN_CENTER); cellAnoFabricoCompra = new PdfPCell(new Phrase(((vb.getInfo().get(i).getAnoFabrico() == null || (vb.getInfo().get(i).getAnoFabrico().isEmpty())) ? "......." : vb.getInfo().get(i).getAnoFabrico()) + "/" + ((vb.getInfo().get(i).getAnoCompra() == null || (vb.getInfo().get(i).getAnoCompra().isEmpty())) ? "......." : vb.getInfo().get(i).getAnoCompra()), fontCorpoTab)); cellAnoFabricoCompra.setHorizontalAlignment(Element.ALIGN_CENTER); cellTotalLuagares = new PdfPCell( new Phrase(vb.getInfo().get(i).getCapacidade() + " LUGARES", fontCorpoTab)); cellTotalLuagares.setHorizontalAlignment(Element.ALIGN_CENTER); cellChasii = new PdfPCell(new Phrase(vb.getInfo().get(i).getChassi() + " ", fontCorpoTab)); cellChasii.setHorizontalAlignment(Element.ALIGN_CENTER); float pad = getPadding(total); cellMarca.setPaddingTop(pad); cellMarca.setPaddingBottom(pad); pTableDados.addCell(cellMarca); cellModelo.setPaddingTop(pad); cellModelo.setPaddingBottom(pad); pTableDados.addCell(cellModelo); cellMatricula.setPaddingTop(pad); cellMatricula.setPaddingBottom(pad); pTableDados.addCell(cellMatricula); cellChasii.setPaddingTop(pad); cellChasii.setPaddingBottom(pad); pTableDados.addCell(cellChasii); cellAnoFabricoCompra.setPaddingTop(pad); cellAnoFabricoCompra.setPaddingBottom(pad); pTableDados.addCell(cellAnoFabricoCompra); cellTotalLuagares.setPaddingTop(pad); cellTotalLuagares.setPaddingBottom(pad); pTableDados.addCell(cellTotalLuagares); cellDadosValorSeguro.setPaddingTop(pad); cellDadosValorSeguro.setPaddingBottom(pad); pTableDados.addCell(cellDadosValorSeguro); } // PdfPTable pTableAssinaturaTitulo= new PdfPTable(1); // pTableAssinaturaTitulo.setWidthPercentage(88f); // PdfPTable pTableAssinatura= new PdfPTable( new float[]{50f,50f}); // pTableAssinatura.setWidthPercentage(88f); // PdfPCell cellAssinatora= new PdfPCell(new Phrase("Assinaturas".toUpperCase(),fontCorpoN)); // cellAssinatora.setBorder(0); // cellAssinatora.setHorizontalAlignment(Element.ALIGN_CENTER); // PdfPCell celllinha1= new PdfPCell(new Phrase("____________________________________________".toUpperCase(),fontCorpo)); // celllinha1.setBorder(0); // celllinha1.setHorizontalAlignment(Element.ALIGN_CENTER); // PdfPCell celllinha2= new PdfPCell(new Phrase("____________________________________________".toUpperCase(),fontCorpo)); // celllinha2.setBorder(0); // celllinha2.setHorizontalAlignment(Element.ALIGN_CENTER); // PdfPCell celllinha11= new PdfPCell(new Phrase("para nicon Seguro sa stp".toUpperCase(),fontCorpoP)); // celllinha11.setBorder(0); // celllinha11.setHorizontalAlignment(Element.ALIGN_CENTER); // PdfPCell celllinha21= new PdfPCell(new Phrase("o segurado ".toUpperCase(),fontCorpoP)); // celllinha21.setBorder(0); // celllinha21.setHorizontalAlignment(Element.ALIGN_CENTER); // pTableAssinaturaTitulo.addCell(cellAssinatora); // pTableAssinatura.addCell(celllinha1); // pTableAssinatura.addCell(celllinha2); // pTableAssinatura.addCell(celllinha11); // pTableAssinatura.addCell(celllinha21); Document documento = new Document(); documento.setPageSize(PageSize.A4); documento.setMargins(20f, 20f, 35f, 5f); // File ff= new File("Documentos\\"+user+"\\Seguro Automovel\\"); // ff.mkdirs(); // ff =new File(ff.getAbsoluteFile()+"\\"+"Formulario Seguro Automovel "+sdf1.format(new Date())+".pdf"); File ff = new File(arquivo + "/" + user + "/Seguro Automovel/"); ff.mkdirs(); String Ddata = sdf1.format(new Date()); ff = new File(ff.getAbsoluteFile() + "/" + "Formulario Seguro Automovel " + Ddata + ".pdf"); reString = "../Documentos/" + user + "/Seguro Automovel/" + "Formulario Seguro Automovel " + Ddata + ".pdf"; OutputStream outputStraem = new FileOutputStream(ff); PdfWriter writer = PdfWriter.getInstance(documento, outputStraem); if (MarcaDAgua.isSimulation) { MarcaDAgua.SimulacaoVertical v = new MarcaDAgua.SimulacaoVertical(); writer.setPageEvent(v); } if (MarcaDAgua.isCanceled) { MarcaDAgua.AnulacaoVertical v = new MarcaDAgua.AnulacaoVertical(); writer.setPageEvent(v); } PdfPTable pTableLinha = new PdfPTable(1); pTableLinha.setWidthPercentage(88f); PdfPCell cellLinha = new PdfPCell(new Phrase( "----------------------------------------------------------------------------------------------------------------------", fontCorpo)); cellLinha.setBorder(0); pTableLinha.addCell(cellLinha); cellLinha.setPaddingTop(-9f); pTableLinha.addCell(cellLinha); PdfPTable pTableApoliceAndPeriodo = new PdfPTable(new float[] { 40, 60 }); pTableApoliceAndPeriodo.setWidthPercentage(88f); Paragraph pApolice = new Paragraph(); pApolice.add(new Phrase("N Aplice: ".toUpperCase(), fontCorpo)); pApolice.add(new Phrase(numApolice, fontCorpoN)); pApolice.add(new Phrase("\nPOLICY NO:", fontUK)); PdfPCell cellApolice = new PdfPCell(pApolice); // cellApolice.setPaddingTop(-2); // cellApolice.setPaddingBottom(4.5f); cellApolice.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE); pTableApoliceAndPeriodo.addCell(cellApolice); Paragraph pPeriodo = new Paragraph(); pPeriodo.add(new Phrase("Periodo Do Seguro: ".toUpperCase(), fontCorpo)); pPeriodo.add(new Phrase(((c.getDataInicio() != null) ? sdf.format(c.getDataInicio()) : " ") + " " + ((c.getDataFim() != null) ? sdf.format(c.getDataFim()) : " "), fontCorpoN)); pPeriodo.add(new Phrase("\nPERIOD OF INSURANCE:", fontUK)); PdfPCell cellPeriodo = new PdfPCell(pPeriodo); // cellPeriodo.setPaddingTop(-2); // cellPeriodo.setPaddingBottom(4.5f); cellPeriodo.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE); pTableApoliceAndPeriodo.addCell(cellPeriodo); documento.open(); documento.add(pTableEmpresaPricipal); documento.add(pTableNull); documento.add(pTableTitulo); documento.add(pTableNull); documento.add(pTableApoliceAndPeriodo); documento.add(pTableNull); documento.add(pTableCliente); documento.add(pTableNull); documento.add(pTableLinha); documento.add(pTableNull); documento.add(pTableDadosTitulo); documento.add(pTableDados); documento.add(pTableNull); documento.add(pTableLinha); documento.add(pTableNull); documento.add(pTableSeguro); // documento.add(pTableNull); // documento.add(pTableAssinaturaTitulo); // documento.add(pTableNull); // documento.add(pTableNull); // documento.add(pTableAssinatura); documento.close(); // PrintPdf printPdf = new PrintPdf(ff.getAbsolutePath(), ff.getAbsolutePath(), 0, 595f,842f,"Enviar Para o OneNote 2013",1); // //PrintPdf printPdf = new PrintPdf(ff.getAbsolutePath(), ff.getAbsolutePath(), 0, 595f,842f,"Hewlett-Packard HP LaserJet P2035",1); // // printPdf.print(); } catch (BadElementException | IOException ex) { Logger.getLogger(SeguroAPG.class.getName()).log(Level.SEVERE, null, ex); } catch (DocumentException ex) { Logger.getLogger(SeguroAPG.class.getName()).log(Level.SEVERE, null, ex); } return reString; }
From source file:Export.TableOfSalary.java
public static void ciarDoc(String user, String idProcesso, String data) { FileOutputStream outputStraem; try {// ww w . j av a 2 s . co m Font fontCabecalhoN = FontFactory.getFont(ConfigDoc.Fontes.FONTB, BaseFont.WINANSI, BaseFont.EMBEDDED, 9f); Font fontCorpo = FontFactory.getFont(ConfigDoc.Fontes.FONT, BaseFont.WINANSI, BaseFont.EMBEDDED, 6f); Font fontCorpoN = FontFactory.getFont(ConfigDoc.Fontes.FONTB, BaseFont.WINANSI, BaseFont.EMBEDDED, 7f); 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() + "/" + "Tabela de Salrio " + Ddata + ".pdf"); outputStraem = new FileOutputStream(ff); String reString = "../Documentos/" + user + "/Relatorio/Tabela de Salrio " + Ddata + ".pdf"; PdfPTable pTableEmpresaPricipal = new PdfPTable(new float[] { 7f, 93f }); 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.A3.rotate()); PdfWriter writer = PdfWriter.getInstance(documento, outputStraem); PdfPTable pTableDados = new PdfPTable(new float[] { 2.5f, 7.5f, 2, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4 }); pTableDados.setWidthPercentage(105); /** * primeira linha de titulo inicio */ PdfPCell cellDados; Paragraph pTitile = new Paragraph(); // SimpleDateFormat sdfPT = new SimpleDateFormat("MMMM yyyy",new Locale("pt", "BR")); pTitile.add(new Paragraph(ConfigDoc.Empresa.NOME + "\n" + "TABELA SAL?RIO REFERENTE A " + data, fontCorpoN)); cellDados = new PdfPCell(pTitile); cellDados.setColspan(10); cellDados.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE); pTableDados.addCell(cellDados); cellDados = new PdfPCell(new Phrase("F\nSOC. SEGU. 4%", fontCorpoN)); cellDados.setHorizontalAlignment(PdfPCell.ALIGN_CENTER); cellDados.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE); pTableDados.addCell(cellDados); cellDados = new PdfPCell(new Phrase("G", fontCorpoN)); cellDados.setHorizontalAlignment(PdfPCell.ALIGN_CENTER); cellDados.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE); pTableDados.addCell(cellDados); cellDados = new PdfPCell(new Phrase("H", fontCorpoN)); cellDados.setHorizontalAlignment(PdfPCell.ALIGN_CENTER); cellDados.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE); pTableDados.addCell(cellDados); cellDados = new PdfPCell(new Phrase("I", fontCorpoN)); cellDados.setHorizontalAlignment(PdfPCell.ALIGN_CENTER); cellDados.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE); pTableDados.addCell(cellDados); cellDados = new PdfPCell(new Phrase("IMPOSTO\n18% : 20%", fontCorpoN)); cellDados.setHorizontalAlignment(PdfPCell.ALIGN_CENTER); cellDados.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE); pTableDados.addCell(cellDados); for (int j = 0; j < 8; j++) { cellDados = new PdfPCell(new Phrase(" ", fontCorpo)); pTableDados.addCell(cellDados); } cellDados = new PdfPCell(new Phrase("6\nSOC. SEGU.", fontCorpoN)); cellDados.setHorizontalAlignment(PdfPCell.ALIGN_CENTER); cellDados.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE); pTableDados.addCell(cellDados); cellDados = new PdfPCell(new Phrase(" ", fontCorpoN)); cellDados.setHorizontalAlignment(PdfPCell.ALIGN_CENTER); pTableDados.addCell(cellDados); /** * primeira linha de titulo Fim */ /** * Segunda linha de titulo Inicio */ for (int j = 0; j < 3; j++) { cellDados = new PdfPCell(new Phrase(" ", fontCorpo)); pTableDados.addCell(cellDados); } cellDados = new PdfPCell(new Phrase("A", fontCorpoN)); cellDados.setHorizontalAlignment(PdfPCell.ALIGN_CENTER); cellDados.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE); pTableDados.addCell(cellDados); cellDados = new PdfPCell(new Phrase("B", fontCorpoN)); cellDados.setHorizontalAlignment(PdfPCell.ALIGN_CENTER); cellDados.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE); pTableDados.addCell(cellDados); cellDados = new PdfPCell(new Phrase("C", fontCorpoN)); cellDados.setHorizontalAlignment(PdfPCell.ALIGN_CENTER); cellDados.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE); pTableDados.addCell(cellDados); cellDados = new PdfPCell(new Phrase("D", fontCorpoN)); cellDados.setHorizontalAlignment(PdfPCell.ALIGN_CENTER); cellDados.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE); pTableDados.addCell(cellDados); cellDados = new PdfPCell(new Phrase("E", fontCorpoN)); cellDados.setHorizontalAlignment(PdfPCell.ALIGN_CENTER); cellDados.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE); pTableDados.addCell(cellDados); cellDados = new PdfPCell(new Phrase("SUBSIDIO DE", fontCorpoN)); cellDados.setHorizontalAlignment(PdfPCell.ALIGN_CENTER); cellDados.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE); pTableDados.addCell(cellDados); cellDados = new PdfPCell(new Phrase("VALOR A SER", fontCorpoN)); cellDados.setHorizontalAlignment(PdfPCell.ALIGN_CENTER); cellDados.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE); pTableDados.addCell(cellDados); cellDados = new PdfPCell(new Phrase("F=(E*4%)", fontCorpoN)); cellDados.setHorizontalAlignment(PdfPCell.ALIGN_CENTER); cellDados.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE); pTableDados.addCell(cellDados); cellDados = new PdfPCell(new Phrase("G=(E-F)", fontCorpoN)); cellDados.setHorizontalAlignment(PdfPCell.ALIGN_CENTER); cellDados.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE); pTableDados.addCell(cellDados); cellDados = new PdfPCell(new Phrase(" ", fontCorpoN)); cellDados.setHorizontalAlignment(PdfPCell.ALIGN_CENTER); pTableDados.addCell(cellDados); cellDados = new PdfPCell(new Phrase("I=G+", fontCorpoN)); cellDados.setHorizontalAlignment(PdfPCell.ALIGN_CENTER); cellDados.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE); pTableDados.addCell(cellDados); cellDados = new PdfPCell(new Phrase("J=", fontCorpoN)); cellDados.setHorizontalAlignment(PdfPCell.ALIGN_CENTER); cellDados.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE); pTableDados.addCell(cellDados); for (int j = 0; j < 4; j++) { cellDados = new PdfPCell(new Phrase(" ", fontCorpo)); pTableDados.addCell(cellDados); } cellDados = new PdfPCell(new Phrase("SUBSIDIO DE", fontCorpoN)); cellDados.setHorizontalAlignment(PdfPCell.ALIGN_CENTER); pTableDados.addCell(cellDados); cellDados = new PdfPCell(new Phrase("k=E-(F+G)", fontCorpoN)); cellDados.setHorizontalAlignment(PdfPCell.ALIGN_CENTER); pTableDados.addCell(cellDados); cellDados = new PdfPCell(new Phrase("PYT", fontCorpoN)); cellDados.setHorizontalAlignment(PdfPCell.ALIGN_CENTER); pTableDados.addCell(cellDados); cellDados = new PdfPCell(new Phrase(" ", fontCorpoN)); cellDados.setHorizontalAlignment(PdfPCell.ALIGN_CENTER); pTableDados.addCell(cellDados); cellDados = new PdfPCell(new Phrase("I", fontCorpoN)); cellDados.setHorizontalAlignment(PdfPCell.ALIGN_CENTER); pTableDados.addCell(cellDados); cellDados = new PdfPCell(new Phrase("J", fontCorpoN)); cellDados.setHorizontalAlignment(PdfPCell.ALIGN_CENTER); pTableDados.addCell(cellDados); /** * Segunda linha de titulo Fim */ /** * Terceira linha de titulo Inicio */ for (int i = 0; i < 25; i++) { cellDados = new PdfPCell(new Phrase(getTitile(i), fontCorpoN)); cellDados.setHorizontalAlignment(PdfPCell.ALIGN_CENTER); cellDados.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE); pTableDados.addCell(cellDados); } /** * Terceira linha de titulo FIM */ ArrayList<Processo> ps = getListData(idProcesso); for (Processo p : ps) { cellDados = new PdfPCell(new Phrase(p.CODIGO1, fontCorpo)); cellDados.setHorizontalAlignment(PdfPCell.ALIGN_CENTER); pTableDados.addCell(cellDados); cellDados = new PdfPCell(new Phrase(p.NOME2, fontCorpo)); pTableDados.addCell(cellDados); cellDados = new PdfPCell(new Phrase(p.DIAS3, fontCorpo)); cellDados.setHorizontalAlignment(PdfPCell.ALIGN_CENTER); pTableDados.addCell(cellDados); cellDados = new PdfPCell(new Phrase(p.S_BASE4, fontCorpo)); cellDados.setHorizontalAlignment(PdfPCell.ALIGN_RIGHT); pTableDados.addCell(cellDados); cellDados = new PdfPCell(new Phrase(p.S_ALOJAMENTO5, fontCorpo)); cellDados.setHorizontalAlignment(PdfPCell.ALIGN_RIGHT); pTableDados.addCell(cellDados); cellDados = new PdfPCell(new Phrase(p.S_TRANSPORTE6, fontCorpo)); cellDados.setHorizontalAlignment(PdfPCell.ALIGN_RIGHT); pTableDados.addCell(cellDados); cellDados = new PdfPCell(new Phrase(p.S_ALMOCO7, fontCorpo)); cellDados.setHorizontalAlignment(PdfPCell.ALIGN_RIGHT); pTableDados.addCell(cellDados); cellDados = new PdfPCell(new Phrase(p.TT_SEM8, fontCorpo)); cellDados.setHorizontalAlignment(PdfPCell.ALIGN_RIGHT); pTableDados.addCell(cellDados); cellDados = new PdfPCell(new Phrase(p.ALMOCOLIVREIMPOSTO9, fontCorpo)); cellDados.setHorizontalAlignment(PdfPCell.ALIGN_RIGHT); pTableDados.addCell(cellDados); cellDados = new PdfPCell(new Phrase(p.TRIBUTADO10, fontCorpo)); cellDados.setHorizontalAlignment(PdfPCell.ALIGN_RIGHT); pTableDados.addCell(cellDados); cellDados = new PdfPCell(new Phrase(p.SSFUNCIONARIO11, fontCorpo)); cellDados.setHorizontalAlignment(PdfPCell.ALIGN_RIGHT); pTableDados.addCell(cellDados); cellDados = new PdfPCell(new Phrase(p.MENOS_SS_FUNCIONARIO12, fontCorpo)); cellDados.setHorizontalAlignment(PdfPCell.ALIGN_RIGHT); pTableDados.addCell(cellDados); cellDados = new PdfPCell(new Phrase(p.COMISOES13, fontCorpo)); cellDados.setHorizontalAlignment(PdfPCell.ALIGN_RIGHT); pTableDados.addCell(cellDados); cellDados = new PdfPCell(new Phrase(p.TOTAL_E_COMISAO14, fontCorpo)); cellDados.setHorizontalAlignment(PdfPCell.ALIGN_RIGHT); pTableDados.addCell(cellDados); cellDados = new PdfPCell(new Phrase(p.IRS15, fontCorpo)); cellDados.setHorizontalAlignment(PdfPCell.ALIGN_RIGHT); pTableDados.addCell(cellDados); cellDados = new PdfPCell(new Phrase(p.PARCELABATER16, fontCorpo)); cellDados.setHorizontalAlignment(PdfPCell.ALIGN_RIGHT); pTableDados.addCell(cellDados); cellDados = new PdfPCell(new Phrase(p.IRSAPURADO17, fontCorpo)); cellDados.setHorizontalAlignment(PdfPCell.ALIGN_RIGHT); pTableDados.addCell(cellDados); cellDados = new PdfPCell(new Phrase(p.SITUAFAMILIAR18, fontCorpo)); cellDados.setHorizontalAlignment(PdfPCell.ALIGN_RIGHT); pTableDados.addCell(cellDados); cellDados = new PdfPCell(new Phrase(p.IRSLIQUIDO19, fontCorpo)); cellDados.setHorizontalAlignment(PdfPCell.ALIGN_RIGHT); pTableDados.addCell(cellDados); cellDados = new PdfPCell(new Phrase(p.ALMOCO20, fontCorpo)); cellDados.setHorizontalAlignment(PdfPCell.ALIGN_RIGHT); pTableDados.addCell(cellDados); cellDados = new PdfPCell(new Phrase(p.SALARIOLIQUIDO21, fontCorpo)); cellDados.setHorizontalAlignment(PdfPCell.ALIGN_RIGHT); pTableDados.addCell(cellDados); cellDados = new PdfPCell(new Phrase(p.AVANCO22, fontCorpo)); cellDados.setHorizontalAlignment(PdfPCell.ALIGN_RIGHT); pTableDados.addCell(cellDados); cellDados = new PdfPCell(new Phrase(p.NETOUT23, fontCorpo)); cellDados.setHorizontalAlignment(PdfPCell.ALIGN_RIGHT); pTableDados.addCell(cellDados); cellDados = new PdfPCell(new Phrase(p.SSEMPRESA24, fontCorpo)); cellDados.setHorizontalAlignment(PdfPCell.ALIGN_RIGHT); pTableDados.addCell(cellDados); cellDados = new PdfPCell(new Phrase(p.TOTAL25, fontCorpo)); cellDados.setHorizontalAlignment(PdfPCell.ALIGN_RIGHT); pTableDados.addCell(cellDados); } PdfPTable pTableRodape = new PdfPTable(new float[] { 33.333333333f, 33.333333333f, 33.333333333f }); PdfPTable pTableSegurancaSocial = new PdfPTable( new float[] { 35f, 21.666666667f, 21.666666667f, 21.666666667f }); pTableSegurancaSocial.setWidthPercentage(75f); PdfPTable pTableImpostoSalario = new PdfPTable(new float[] { 25f, 25f, 25f, 25f }); pTableImpostoSalario.setWidthPercentage(75f); PdfPTable pTableNetSalaryPayble = new PdfPTable(new float[] { 70f, 30f }); pTableNetSalaryPayble.setWidthPercentage(75f); PdfPTable pTableAssinatura = new PdfPTable(new float[] { 25f, 25f, 25f, 25f }); /** * segurano social inicio */ cellDados = new PdfPCell(new Phrase("SEGURANA SOCIAL", fontCorpoN)); cellDados.setBorder(PdfPCell.NO_BORDER); cellDados.setHorizontalAlignment(PdfPCell.ALIGN_CENTER); cellDados.setPaddingTop(8.5f); pTableRodape.addCell(cellDados); /** * segurano social Fim */ /** * IMPOSTO DE SAL?RIO inicio */ cellDados = new PdfPCell(new Phrase("IMPOSTO DE SAL?RIO", fontCorpoN)); cellDados.setBorder(PdfPCell.NO_BORDER); cellDados.setHorizontalAlignment(PdfPCell.ALIGN_CENTER); cellDados.setPaddingTop(8.5f); pTableRodape.addCell(cellDados); /** * IMPOSTO DE SAL?RIO Fim */ /** * NET SALARY PAYABLE incial */ cellDados = new PdfPCell(new Phrase("NET SALARY PAYABLE", fontCorpoN)); cellDados.setHorizontalAlignment(PdfPCell.ALIGN_CENTER); cellDados.setBorder(PdfPCell.NO_BORDER); cellDados.setPaddingTop(8.5f); pTableRodape.addCell(cellDados); /** * NET SALARY PAYABLE Fim */ /** * segurano social inicio */ cellDados = new PdfPCell(new Phrase(" ", fontCorpoN)); cellDados.setHorizontalAlignment(PdfPCell.ALIGN_CENTER); cellDados.setBorder(PdfPCell.NO_BORDER); pTableSegurancaSocial.addCell(cellDados); cellDados = new PdfPCell(new Phrase("4%", fontCorpoN)); cellDados.setHorizontalAlignment(PdfPCell.ALIGN_CENTER); pTableSegurancaSocial.addCell(cellDados); cellDados = new PdfPCell(new Phrase("6%", fontCorpoN)); cellDados.setHorizontalAlignment(PdfPCell.ALIGN_CENTER); pTableSegurancaSocial.addCell(cellDados); cellDados = new PdfPCell(new Phrase("TOTAL", fontCorpoN)); cellDados.setHorizontalAlignment(PdfPCell.ALIGN_CENTER); pTableSegurancaSocial.addCell(cellDados); cellDados = new PdfPCell(new Phrase("TOTAL", fontCorpoN)); cellDados.setHorizontalAlignment(PdfPCell.ALIGN_CENTER); pTableSegurancaSocial.addCell(cellDados); cellDados = new PdfPCell(new Phrase( Moeda.format(Double.valueOf(psList.get(0).SSFUNCIONARIO11.replace(',', '.'))), fontCorpoN)); cellDados.setHorizontalAlignment(PdfPCell.ALIGN_RIGHT); pTableSegurancaSocial.addCell(cellDados); cellDados = new PdfPCell(new Phrase( Moeda.format(Double.valueOf(psList.get(0).SSEMPRESA24.replace(',', '.'))), fontCorpoN)); cellDados.setHorizontalAlignment(PdfPCell.ALIGN_CENTER); pTableSegurancaSocial.addCell(cellDados); cellDados = new PdfPCell( new Phrase(Moeda.format((Double.valueOf(psList.get(0).SSFUNCIONARIO11.replace(',', '.')) + Double.valueOf(psList.get(0).SSEMPRESA24.replace(',', '.')))), fontCorpoN)); cellDados.setHorizontalAlignment(PdfPCell.ALIGN_CENTER); pTableSegurancaSocial.addCell(cellDados); pTableSegurancaSocial.setComplete(true); cellDados = new PdfPCell(pTableSegurancaSocial); cellDados.setHorizontalAlignment(PdfPCell.ALIGN_CENTER); cellDados.setBorder(PdfPCell.NO_BORDER); cellDados.setPadding(8.5f); // cellDados.setCalculatedHeight(100); pTableRodape.addCell(cellDados); /** * segurano social Fim */ /** * IMPOSTO DE SAL?RIO inicio */ cellDados = new PdfPCell(new Phrase("TOTAL", fontCorpoN)); cellDados.setHorizontalAlignment(PdfPCell.ALIGN_CENTER); pTableImpostoSalario.addCell(cellDados); cellDados = new PdfPCell(new Phrase(" ", fontCorpoN)); cellDados.setHorizontalAlignment(PdfPCell.ALIGN_CENTER); pTableImpostoSalario.addCell(cellDados); cellDados = new PdfPCell(new Phrase(" ", fontCorpoN)); cellDados.setHorizontalAlignment(PdfPCell.ALIGN_CENTER); pTableImpostoSalario.addCell(cellDados); cellDados = new PdfPCell(new Phrase( Moeda.format(Double.valueOf(psList.get(0).IRSLIQUIDO19.replace(',', '.'))), fontCorpoN)); cellDados.setHorizontalAlignment(PdfPCell.ALIGN_CENTER); pTableImpostoSalario.addCell(cellDados); pTableImpostoSalario.setComplete(true); cellDados = new PdfPCell(pTableImpostoSalario); cellDados.setHorizontalAlignment(PdfPCell.ALIGN_CENTER); // cellDados.setCalculatedHeight(100); cellDados.setBorder(PdfPCell.NO_BORDER); cellDados.setPadding(8.5f); pTableRodape.addCell(cellDados); /** * IMPOSTO DE SAL?RIO Fim */ /** * NET SALARY PAYABLE incial */ for (Map.Entry<String, TotalBank> entrySet : tbs.entrySet()) { cellDados = new PdfPCell( new Phrase(((entrySet.getValue().nome.isEmpty()) ? "INDEFINIDO" : entrySet.getValue().nome), fontCorpoN)); cellDados.setHorizontalAlignment(PdfPCell.ALIGN_LEFT); pTableNetSalaryPayble.addCell(cellDados); cellDados = new PdfPCell(new Phrase(Moeda.format(entrySet.getValue().value), fontCorpoN)); cellDados.setHorizontalAlignment(PdfPCell.ALIGN_RIGHT); pTableNetSalaryPayble.addCell(cellDados); } cellDados = new PdfPCell(pTableNetSalaryPayble); cellDados.setHorizontalAlignment(PdfPCell.ALIGN_CENTER); // cellDados.setCalculatedHeight(100); cellDados.setBorder(PdfPCell.NO_BORDER); cellDados.setPadding(8.5f); pTableRodape.addCell(cellDados); /** * NET SALARY PAYABLE Fim */ /** * Asssinatura inicio */ cellDados = new PdfPCell(new Phrase("VISTO\nRESPONS?VEL CONTABILIDADE", fontCorpoN)); cellDados.setBorder(PdfPCell.NO_BORDER); cellDados.setHorizontalAlignment(PdfPTable.ALIGN_CENTER); cellDados.setPaddingBottom(20.f); pTableAssinatura.addCell(cellDados); cellDados = new PdfPCell(new Phrase("VISTO\nDIRETOR ADMINISTRATIVO & FINANCEIRO", fontCorpoN)); cellDados.setBorder(PdfPCell.NO_BORDER); cellDados.setHorizontalAlignment(PdfPTable.ALIGN_CENTER); cellDados.setPaddingBottom(20.f); pTableAssinatura.addCell(cellDados); cellDados = new PdfPCell(new Phrase("VISTO\nDIRETOR GERAL", fontCorpoN)); cellDados.setBorder(PdfPCell.NO_BORDER); cellDados.setHorizontalAlignment(PdfPTable.ALIGN_CENTER); cellDados.setPaddingBottom(20.f); pTableAssinatura.addCell(cellDados); cellDados = new PdfPCell(new Phrase("VISTO\nAUDITOR INTERNO", fontCorpoN)); cellDados.setBorder(PdfPCell.NO_BORDER); cellDados.setHorizontalAlignment(PdfPTable.ALIGN_CENTER); cellDados.setPaddingBottom(20.f); pTableAssinatura.addCell(cellDados); cellDados = new PdfPCell( new Phrase("______________________________________________________", fontCorpoN)); cellDados.setBorder(PdfPCell.NO_BORDER); cellDados.setHorizontalAlignment(PdfPTable.ALIGN_CENTER); cellDados.setPaddingBottom(5.f); pTableAssinatura.addCell(cellDados); cellDados = new PdfPCell( new Phrase("______________________________________________________", fontCorpoN)); cellDados.setBorder(PdfPCell.NO_BORDER); cellDados.setHorizontalAlignment(PdfPTable.ALIGN_CENTER); pTableAssinatura.addCell(cellDados); cellDados = new PdfPCell( new Phrase("______________________________________________________", fontCorpoN)); cellDados.setBorder(PdfPCell.NO_BORDER); cellDados.setHorizontalAlignment(PdfPTable.ALIGN_CENTER); pTableAssinatura.addCell(cellDados); cellDados = new PdfPCell( new Phrase("______________________________________________________", fontCorpoN)); cellDados.setBorder(PdfPCell.NO_BORDER); cellDados.setHorizontalAlignment(PdfPTable.ALIGN_CENTER); pTableAssinatura.addCell(cellDados); cellDados = new PdfPCell(pTableAssinatura); cellDados.setBorder(PdfPCell.NO_BORDER); cellDados.setHorizontalAlignment(PdfPTable.ALIGN_CENTER); cellDados.setColspan(3); pTableRodape.addCell(cellDados); /** * Asssinatura fim */ cellDados = new PdfPCell(pTableRodape); cellDados.setColspan(25); pTableDados.addCell(cellDados); documento.open(); documento.add(pTableEmpresaPricipal); documento.add(pTableDados); documento.close(); psList = new ArrayList<>(); tbs = new LinkedHashMap<>(); RequestContext.getCurrentInstance().execute("openAllDocument('" + reString + "')"); } catch (FileNotFoundException ex) { Logger.getLogger(TableOfSalary.class.getName()).log(Level.SEVERE, null, ex); } catch (BadElementException ex) { Logger.getLogger(TableOfSalary.class.getName()).log(Level.SEVERE, null, ex); } catch (IOException | DocumentException ex) { Logger.getLogger(TableOfSalary.class.getName()).log(Level.SEVERE, null, ex); } }
From source file:femr.ui.controllers.PDFController.java
License:Open Source License
/** * Builds the page header - Title and Empty cell (for border) * * @return PdfPTable the itext table to add to the document *///from ww w . j av a2 s .co m public PdfPTable createHeaderTable() { PdfPTable table = new PdfPTable(2); table.setSpacingAfter(10); table.setWidthPercentage(100); Paragraph title = new Paragraph("Medical Record", new Font(Font.FontFamily.TIMES_ROMAN, 18, Font.BOLD)); PdfPCell cell = new PdfPCell(title); cell.setVerticalAlignment(Element.ALIGN_BOTTOM); cell.setBorder(PdfPCell.NO_BORDER); cell.setBorderColorBottom(BaseColor.BLACK); cell.setBorderWidthBottom(1); cell.setPaddingBottom(5); table.addCell(cell); //Paragraph encounterId = new Paragraph("Encounter ID: " + patientEncounter.getId(), new Font(Font.FontFamily.TIMES_ROMAN, 12, Font.NORMAL)); cell = new PdfPCell(table.getDefaultCell()); cell.setVerticalAlignment(Element.ALIGN_BOTTOM); cell.setBorder(PdfPCell.NO_BORDER); cell.setBorderColorBottom(BaseColor.BLACK); cell.setBorderWidthBottom(1); cell.setHorizontalAlignment(Element.ALIGN_RIGHT); cell.setPaddingBottom(5); table.addCell(cell); return table; }
From source file:femr.ui.controllers.PDFController.java
License:Open Source License
/** * Builds a table with numColumns with the base stylins * @param numColumns the number of columns the table will have * @return an instantiated PdfPTable object */// ww w . ja va 2 s. co m private PdfPTable getDefaultTable(int numColumns) { PdfPTable table = new PdfPTable(numColumns); table.setWidthPercentage(100); table.setSpacingAfter(10); table.getDefaultCell().setPaddingBottom(5); table.getDefaultCell().setBorder(PdfPCell.NO_BORDER); return table; }
From source file:fenix.planner.pdf.PDFGenerator.java
License:Open Source License
private void createAndAddEventTable() throws DocumentException { PdfPTable table = new PdfPTable(new float[] { 1, 7, 1.2f }); table.setWidthPercentage(100f); table.getDefaultCell().setUseAscender(true); table.getDefaultCell().setUseDescender(true); table.setSpacingBefore(20);//from ww w . jav a 2s . c om table.setSpacingAfter(20); // Header row table.getDefaultCell().setBorderWidthLeft(0); table.getDefaultCell().setBorderWidthTop(0); table.getDefaultCell().setBorderWidthRight(0); table.getDefaultCell().setPadding(5); table.getDefaultCell().setHorizontalAlignment(Element.ALIGN_LEFT); table.addCell(new Phrase("Datum", headerFont)); table.addCell(new Phrase("mne", headerFont)); table.addCell(new Phrase("Ansvarig", headerFont)); table.setHeaderRows(1); table.getDefaultCell().setBackgroundColor(null); // Events for (Event event : program.getSortedCopyOfEvents()) { if (event.getDate().getMonthOfYear() % 2 == 0) { table.getDefaultCell().setBackgroundColor(new BaseColor(0xdd, 0xdd, 0xdd)); } else { table.getDefaultCell().setBackgroundColor(null); } if (!event.getType().getBackgroundColor().equals(Color.WHITE)) { table.getDefaultCell() .setBackgroundColor(awtColorToBaseColor(event.getType().getBackgroundColor())); } final BaseColor textColor = awtColorToBaseColor(event.getType().getForegroundColor()); PdfPCell dateCell = new PdfPCell(table.getDefaultCell()); dateCell.addElement( new Phrase(event.getDate().toString("dd.MM", locale), changeColor(subjectFont, textColor))); table.addCell(dateCell); PdfPCell subjectCell = new PdfPCell(table.getDefaultCell()); subjectCell.addElement(new Phrase(event.getSubject(), changeColor(subjectFont, textColor))); if (event.getDescription().length() > 0) { subjectCell.addElement(new Phrase(event.getDescription(), changeColor(descriptionFont, textColor))); } if (event.getOrganizer() == null) { subjectCell.setColspan(2); } table.addCell(subjectCell); if (event.getOrganizer() != null) { PdfPCell organizerCell = new PdfPCell(table.getDefaultCell()); organizerCell.addElement( new Phrase(event.getOrganizer().getInitials(), changeColor(subjectFont, textColor))); table.addCell(organizerCell); } } document.add(table); }
From source file:fenix.planner.pdf.PDFGenerator.java
License:Open Source License
private void createAndAddOrganizerTable() throws DocumentException { PdfPTable table = new PdfPTable(new float[] { 1, 3, 4, 2 }); table.setSpacingBefore(20);//from w w w.j av a 2s . co m table.setWidthPercentage(100f); table.getDefaultCell().setUseAscender(true); table.getDefaultCell().setUseDescender(true); // Header row table.getDefaultCell().setBorder(0); table.getDefaultCell().setPadding(5); table.getDefaultCell().setHorizontalAlignment(Element.ALIGN_LEFT); table.getDefaultCell().setBackgroundColor(null); for (Organizer organizer : program.getSortedCopyOfOrganizers()) { table.addCell(new Phrase(organizer.getInitials(), organizerFont)); table.addCell(new Phrase(organizer.getFullName(), organizerFont)); table.addCell(new Phrase(organizer.getEmail(), organizerFont)); table.addCell(new Phrase(organizer.getPhoneNumber(), organizerFont)); } document.add(table); }
From source file:file.PDFWriter.java
License:Open Source License
/** * Adds the table of possible errors to the PDF * @param errorIX the specific error to be bolded * @throws DocumentException /* w w w.j a v a2s .c om*/ */ private void addErrorTableToPDF(int errorIX) throws DocumentException { PdfPTable errorTable = new PdfPTable(7); errorTable.setWidthPercentage(100); for (int i = 0; i < errorOutput.length; i++) { errorFont.setStyle(Font.ITALIC); PdfPCell cell; if (i == errorIX) { cell = new PdfPCell(new Paragraph(errorOutput[i], errorFontBold)); } else { cell = new PdfPCell(new Paragraph(errorOutput[i], errorFont)); } cell.setBorder(PdfPCell.NO_BORDER); errorTable.addCell(cell); } document.add(errorTable); }
From source file:file.PDFWriter.java
License:Open Source License
/** * Add the page number and line to the PDF * @param splitLines the array of line segments to print * @param page the page number the line was on * @throws DocumentException //from w ww .j a v a2 s . c o m */ private void addLineTableToPDF(String[] splitLines, String page) throws DocumentException { PdfPTable lineTable = new PdfPTable(2); PdfPCell pageCell = new PdfPCell(new Paragraph("Page: " + page, lineFont)); pageCell.setPadding(20); pageCell.setPaddingLeft(0); pageCell.setBorder(PdfPCell.NO_BORDER); Chunk lineSegment1 = new Chunk(splitLines[0]); lineSegment1.setFont(lineFont); Chunk error1 = new Chunk(splitLines[1]); error1.setFont(lineFontBold); Chunk lineSegment2 = new Chunk(splitLines[2]); lineSegment2.setFont(lineFont); Chunk error2 = new Chunk(splitLines[3]); error2.setFont(lineFontBold); Chunk lineSegment3 = new Chunk(splitLines[4]); lineSegment3.setFont(lineFont); Phrase line = new Phrase(lineSegment1); line.add(error1); line.add(lineSegment2); line.add(error2); line.add(lineSegment3); PdfPCell lineCell = new PdfPCell(line); lineCell.setPadding(20); lineCell.setBorder(PdfPCell.NO_BORDER); lineTable.setWidthPercentage(100); lineTable.setWidths(new int[] { 2, 10 }); lineTable.setSpacingBefore(1f); lineTable.setSpacingAfter(1f); lineTable.addCell(pageCell); lineTable.addCell(lineCell); document.add(lineTable); document.add(Chunk.NEWLINE); }