List of usage examples for com.itextpdf.text.pdf PdfPCell setPaddingTop
public void setPaddingTop(float paddingTop)
From source file:Export.ListaVeiculo.java
public static void criarDocPdf(List<Veiculo> ls, String user) { @SuppressWarnings("UnusedAssignment") OutputStream outputStraem = null; try {//from www .j a va 2s.c o m Font fontCabecalhoN = FontFactory.getFont(ConfigDoc.Fontes.FONTB, BaseFont.WINANSI, BaseFont.EMBEDDED, 10f); Font fontCorpo = FontFactory.getFont(ConfigDoc.Fontes.FONT, BaseFont.WINANSI, BaseFont.EMBEDDED, 9f); Font fontCorpoTable = FontFactory.getFont(ConfigDoc.Fontes.FONT, BaseFont.WINANSI, BaseFont.EMBEDDED, 8f); Font fontCorpoTableN = FontFactory.getFont(ConfigDoc.Fontes.FONTB, BaseFont.WINANSI, BaseFont.EMBEDDED, 8f); Font fontCorpoNG = FontFactory.getFont(ConfigDoc.Fontes.FONTB, BaseFont.WINANSI, BaseFont.EMBEDDED, 9f); Font fontCorpoTitile = FontFactory.getFont(ConfigDoc.Fontes.FONTB, BaseFont.WINANSI, BaseFont.EMBEDDED, 11.5f); Font fontCabecalhoNG = FontFactory.getFont(ConfigDoc.Fontes.FONTB, BaseFont.WINANSI, BaseFont.EMBEDDED, 16f, Font.UNDERLINE); PdfPTable pTableEmpresaPricipal = new PdfPTable(new float[] { 15f, 85 }); PdfPTable pTableEmpresaInforImpres1 = new PdfPTable(1); PdfPTable pTableEmpresaInforImpres5 = new PdfPTable(1); PdfPTable pTableNull = new PdfPTable(1); PdfPCell cellNull = new PdfPCell(new Phrase(" ", fontCorpo)); cellNull.setBorder(0); pTableNull.addCell(cellNull); PdfPCell pCellNomeEmpresa = new PdfPCell(new Phrase(ConfigDoc.Empresa.NOME, fontCabecalhoNG)); pCellNomeEmpresa.setBorder(0); PdfPCell pCellNomeEndereco = new PdfPCell(new Phrase(ConfigDoc.Empresa.ENDERECO, fontCabecalhoN)); pCellNomeEndereco.setBorder(0); PdfPCell pCellCaixaPostal = new PdfPCell(new Phrase(ConfigDoc.Empresa.CAIXAPOSTAL, fontCabecalhoN)); pCellCaixaPostal.setBorder(0); PdfPCell pCellTeleFax = new PdfPCell( new Phrase(ConfigDoc.Empresa.TELEFAX + " " + ConfigDoc.Empresa.EMAIL, fontCabecalhoN)); pCellTeleFax.setBorder(0); PdfPCell pCellSociedade = new PdfPCell(new Phrase(ConfigDoc.Empresa.SOCIEDADE, fontCabecalhoN)); pCellSociedade.setBorder(0); Image imageEmpresa = Image.getInstance("logo.png"); imageEmpresa.scaleToFit(120f, 85f); pTableEmpresaInforImpres1.addCell(pCellNomeEmpresa); pTableEmpresaInforImpres1.addCell(pCellNomeEndereco); pTableEmpresaInforImpres1.addCell(pCellCaixaPostal); pTableEmpresaInforImpres1.addCell(pCellTeleFax); pTableEmpresaInforImpres1.addCell(pCellSociedade); PdfPCell cellTabela3 = new PdfPCell(pTableEmpresaInforImpres1); cellTabela3.setBorder(0); pTableEmpresaInforImpres5.addCell(cellTabela3); PdfPCell cellTabela5 = new PdfPCell(pTableEmpresaInforImpres5); cellTabela5.setBorder(0); PdfPCell cellTabela6 = new PdfPCell(imageEmpresa); cellTabela6.setBorder(0); pTableEmpresaPricipal.setWidthPercentage(97); pTableEmpresaPricipal.addCell(cellTabela6); pTableEmpresaPricipal.addCell(cellTabela5); Document documento = new Document(PageSize.A4.rotate()); 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() + "/" + "Lista de Veiculos" + " " + Ddata + ".pdf"); outputStraem = new FileOutputStream(ff); String reString = "../Documentos/" + user + "/Relatorio/" + "Lista de Veiculos" + " " + Ddata + ".pdf"; PdfWriter writer = PdfWriter.getInstance(documento, outputStraem); BaseColor colorAzul = new BaseColor(176, 196, 222); BaseColor colorCinza = new BaseColor(240, 240, 240); // BaseColor colorAzulEscuro = new BaseColor(100, 149, 237); PdfPTable pTableSubTitile = new PdfPTable(new float[] { 100 }); pTableSubTitile.setWidthPercentage(97f); PdfPCell cellSubTitile = new PdfPCell(new Paragraph("Lista de Veiculos", fontCorpoTitile)); cellSubTitile.setBorder(PdfPCell.NO_BORDER); cellSubTitile.setPaddingTop(0f); cellSubTitile.setPaddingBottom(0f); pTableSubTitile.addCell(cellSubTitile); PdfPTable tableDados = new PdfPTable( new float[] { 12.8f, 12.8f, 12.8f, 12.8f, 12.8f, 12.8f, 12.8f, 12.8f }); tableDados.setWidthPercentage(97f); for (int i = 0; i < 8; i++) { PdfPCell cellTitileTable = new PdfPCell(new Phrase(getList(i), fontCorpoNG)); cellTitileTable.setBorderWidth(1f); cellTitileTable.setPaddingTop(8f); cellTitileTable.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE); cellTitileTable.setHorizontalAlignment(PdfPCell.ALIGN_CENTER); cellTitileTable.setBackgroundColor(colorAzul); cellTitileTable.setPaddingBottom(8f); tableDados.addCell(cellTitileTable); } PdfPCell dados; for (int i = 0; i < ls.size(); i++) { dados = new PdfPCell(new Phrase(ls.get(i).getNumeroMatricula(), fontCorpoTable)); dados.setPaddingTop(5f); dados.setPaddingBottom(5f); dados.setBackgroundColor(((i % 2 != 0) ? colorCinza : null)); tableDados.addCell(dados); dados = new PdfPCell(new Phrase(ls.get(i).getMarca(), fontCorpoTable)); dados.setPaddingTop(5f); dados.setPaddingBottom(5f); dados.setBackgroundColor(((i % 2 != 0) ? colorCinza : null)); tableDados.addCell(dados); dados = new PdfPCell(new Phrase(ls.get(i).getModelo(), fontCorpoTable)); dados.setPaddingTop(5f); dados.setPaddingBottom(5f); dados.setBackgroundColor(((i % 2 != 0) ? colorCinza : null)); tableDados.addCell(dados); dados = new PdfPCell(new Phrase(ls.get(i).getNumMotor(), fontCorpoTable)); dados.setPaddingTop(5f); dados.setPaddingBottom(5f); dados.setBackgroundColor(((i % 2 != 0) ? colorCinza : null)); tableDados.addCell(dados); dados = new PdfPCell(new Phrase(ls.get(i).getChassi(), fontCorpoTable)); dados.setPaddingTop(5f); dados.setPaddingBottom(5f); dados.setBackgroundColor(((i % 2 != 0) ? colorCinza : null)); tableDados.addCell(dados); dados = new PdfPCell(new Phrase(ls.get(i).getAnoFabrico(), fontCorpoTable)); dados.setPaddingTop(5f); dados.setPaddingBottom(5f); dados.setBackgroundColor(((i % 2 != 0) ? colorCinza : null)); tableDados.addCell(dados); dados = new PdfPCell(new Phrase(ls.get(i).getAnoCompra(), fontCorpoTable)); dados.setPaddingTop(5f); dados.setPaddingBottom(5f); dados.setBackgroundColor(((i % 2 != 0) ? colorCinza : null)); tableDados.addCell(dados); dados = new PdfPCell(new Phrase(ls.get(i).getCapacidade(), fontCorpoTable)); dados.setPaddingTop(5f); dados.setPaddingBottom(5f); dados.setBackgroundColor(((i % 2 != 0) ? colorCinza : null)); tableDados.addCell(dados); } documento.open(); documento.add(pTableEmpresaPricipal); documento.add(pTableNull); documento.add(pTableNull); documento.add(pTableSubTitile); documento.add(pTableNull); documento.add(tableDados); documento.close(); RequestContext.getCurrentInstance().execute("openAllDocument('" + reString + "')"); } catch (FileNotFoundException | DocumentException ex) { Logger.getLogger(ListaVeiculo.class.getName()).log(Level.SEVERE, null, ex); } catch (IOException ex) { Logger.getLogger(ListaVeiculo.class.getName()).log(Level.SEVERE, null, ex); } }
From source file:Export.ReciboPagamento.java
public PdfPTable detaDoc(HashMap<String, Object> map, Font fontTitile, Font fontRecibo, Font fontTitileShort, Font fontReciboTxt, Font fontConteudo, Font fontConteudoTxt, Font fontConteudoTxtUl) throws DocumentException { PdfPTable pTablePrincipal = new PdfPTable(new float[] { 100 }); try {/* ww w. ja v a 2 s .c o m*/ pTablePrincipal.setWidthPercentage(100f); PdfPTable pTableTitulo = new PdfPTable(new float[] { 60, 40 }); pTableTitulo.setWidthPercentage(100); PdfPTable pTableTituloImage = new PdfPTable(new float[] { 20, 80 }); pTableTituloImage.setWidthPercentage(100); PdfPCell cellTitulo = new PdfPCell(new Phrase(ConfigDoc.Empresa.NOME, fontTitile)); cellTitulo.setHorizontalAlignment(Element.ALIGN_CENTER); cellTitulo.setBorder(0); cellTitulo.setPaddingTop(20f); cellTitulo.setPaddingLeft(70f); pTableTitulo.addCell(cellTitulo); cellTitulo = new PdfPCell(new Phrase("Recibo N ".toUpperCase() + map.get(IDAMORTIZACAO), fontRecibo)); cellTitulo.setVerticalAlignment(Element.ALIGN_BOTTOM); cellTitulo.setHorizontalAlignment(Element.ALIGN_RIGHT); cellTitulo.setBorder(0); pTableTitulo.addCell(cellTitulo); cellTitulo = new PdfPCell(new Phrase(ConfigDoc.Empresa.ENDERECO + ", " + ConfigDoc.Empresa.CAIXAPOSTAL + ", " + ConfigDoc.Empresa.TELEFAX, fontTitileShort)); cellTitulo.setHorizontalAlignment(Element.ALIGN_CENTER); cellTitulo.setPaddingLeft(70f); cellTitulo.setBorder(0); pTableTitulo.addCell(cellTitulo); cellTitulo = new PdfPCell(new Phrase(" ", fontTitileShort)); cellTitulo.setPaddingBottom(0f); cellTitulo.setPaddingTop(0f); cellTitulo.setBorder(0); pTableTitulo.addCell(cellTitulo); cellTitulo = new PdfPCell(new Phrase(ConfigDoc.Empresa.REPUBLICA, fontTitileShort)); cellTitulo.setHorizontalAlignment(Element.ALIGN_CENTER); cellTitulo.setBorder(0); cellTitulo.setPaddingLeft(70f); pTableTitulo.addCell(cellTitulo); cellTitulo = new PdfPCell(new Phrase(" ", fontTitileShort)); cellTitulo.setPaddingBottom(0f); cellTitulo.setPaddingTop(0f); cellTitulo.setBorder(0); pTableTitulo.addCell(cellTitulo); cellTitulo = new PdfPCell(new Phrase(ConfigDoc.Empresa.EMAIL, fontTitileShort)); cellTitulo.setHorizontalAlignment(Element.ALIGN_CENTER); cellTitulo.setBorder(0); cellTitulo.setPaddingLeft(70f); pTableTitulo.addCell(cellTitulo); cellTitulo = new PdfPCell(new Phrase(" ", fontTitileShort)); cellTitulo.setPaddingBottom(0f); cellTitulo.setPaddingTop(0f); cellTitulo.setBorder(0); pTableTitulo.addCell(cellTitulo); cellTitulo = new PdfPCell(new Phrase("Ordem de receita / recibo".toUpperCase(), fontRecibo)); cellTitulo.setHorizontalAlignment(Element.ALIGN_CENTER); cellTitulo.setBorder(0); cellTitulo.setPaddingLeft(70f); pTableTitulo.addCell(cellTitulo); cellTitulo = new PdfPCell(new Phrase(" ", fontTitileShort)); cellTitulo.setVerticalAlignment(Element.ALIGN_TOP); cellTitulo.setPaddingBottom(30f); cellTitulo.setPaddingTop(0f); cellTitulo.setBorder(0); pTableTitulo.addCell(cellTitulo); Image imageEmpresa = Image.getInstance("logo.png"); imageEmpresa.scaleToFit(120f, 85f); imageEmpresa.setAlignment(Image.ALIGN_CENTER); PdfPCell cellImagem = new PdfPCell(imageEmpresa); cellImagem.setBorder(PdfPCell.NO_BORDER); cellImagem.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE); cellImagem.setHorizontalAlignment(PdfPCell.ALIGN_RIGHT); PdfPCell cellpTableTitulo = new PdfPCell(pTableTitulo); cellpTableTitulo.setBorder(PdfPCell.NO_BORDER); cellpTableTitulo.setHorizontalAlignment(PdfPCell.ALIGN_CENTER); pTableTituloImage.addCell(cellImagem); pTableTituloImage.addCell(cellpTableTitulo); PdfPCell cellpTableTituloPrincipal = new PdfPCell(pTableTituloImage); cellpTableTituloPrincipal.setBorder(PdfPCell.NO_BORDER); pTablePrincipal.addCell(cellpTableTituloPrincipal); PdfPTable pTableDataCaixaMontante = new PdfPTable(new float[] { 35f, 5f, 60f }); pTableDataCaixaMontante.setWidthPercentage(100f); PdfPCell cellDataCaixaMontante = new PdfPCell(new Phrase(" ", fontRecibo)); cellDataCaixaMontante.setBorder(0); pTableDataCaixaMontante.addCell(cellDataCaixaMontante); pTableDataCaixaMontante.addCell(cellDataCaixaMontante); cellDataCaixaMontante = new PdfPCell(); cellDataCaixaMontante.setBorder(0); Paragraph p = new Paragraph(); p.add(new Phrase("Data: ".toUpperCase(), fontRecibo)); p.add(new Phrase(converterData(map.get(REGISTROAMORTIZACAO), 1), fontReciboTxt)); p.setAlignment(Element.ALIGN_RIGHT); cellDataCaixaMontante.addElement(p); cellDataCaixaMontante.setPaddingBottom(5f); pTableDataCaixaMontante.addCell(cellDataCaixaMontante); cellDataCaixaMontante = new PdfPCell(); p = new Paragraph(); p.add(new Phrase("Caixa de: ".toUpperCase(), fontRecibo)); p.add(new Phrase("So Tom", fontReciboTxt)); p.setAlignment(Element.ALIGN_LEFT); cellDataCaixaMontante.addElement(p); cellDataCaixaMontante.setPaddingTop(-2f); cellDataCaixaMontante.setPaddingBottom(5f); cellDataCaixaMontante.setBorderColor(BaseColor.BLUE.darker().darker().darker()); pTableDataCaixaMontante.addCell(cellDataCaixaMontante); cellDataCaixaMontante = new PdfPCell(new Phrase(" ", fontRecibo)); cellDataCaixaMontante.setBorder(0); pTableDataCaixaMontante.addCell(cellDataCaixaMontante); cellDataCaixaMontante = new PdfPCell(); p = new Paragraph(); p.add(new Phrase("Montante: ".toUpperCase(), fontRecibo)); Double montade = Moeda.arrendodamento(toString(map.get(VALORAMORTIZADO))); // SimpleDateFormat sdf = new SimpleDateFormat("dd-MM-yyyy HH:"); Object dRegistro = map.get(DATAREGAPOLICE); montade *= valorCompra(map.get(SIGLAMOEDA) + "", dRegistro); p.add(new Phrase(converterMoeda(montade, "STD") + "", fontReciboTxt)); p.setAlignment(Element.ALIGN_LEFT); cellDataCaixaMontante.addElement(p); cellDataCaixaMontante.setPaddingTop(-2f); cellDataCaixaMontante.setPaddingBottom(5f); cellDataCaixaMontante.setBorderColor(BaseColor.BLUE.darker().darker().darker()); pTableDataCaixaMontante.addCell(cellDataCaixaMontante); PdfPCell cellDataCaixaMontantePrincipal = new PdfPCell(pTableDataCaixaMontante); cellDataCaixaMontantePrincipal.setBorder(PdfPCell.NO_BORDER); pTablePrincipal.addCell(cellDataCaixaMontantePrincipal); PdfPTable pTableConteudo = new PdfPTable(new float[] { 40, 60 }); pTableConteudo.setWidthPercentage(100f); PdfPCell cellConteudo = new PdfPCell(); cellConteudo.setBorder(0); Paragraph pConteudo = new Paragraph(); pConteudo.add(new Phrase("N Assegurado: ".toUpperCase(), fontConteudo)); pConteudo.add(new Phrase(map.get(NUMREGISTRO) + "\n", fontConteudoTxt)); /** * For alter */ pConteudo.add(new Phrase("Prmio Liquido: ".toUpperCase(), fontConteudo)); pConteudo.add(new Phrase(converterMoeda(map.get(TOTALBRUTO), map.get(SIGLAMOEDA) + "") + "\n", fontConteudoTxt)); pConteudo.add(new Phrase("Impostos: ".toUpperCase(), fontConteudo)); pConteudo.add(new Phrase(converterMoeda(impostosCalculo(map.get(TOTAl), map.get(IMPOSTOCONSUMO)), map.get(SIGLAMOEDA) + "") + "\n", fontConteudoTxt)); pConteudo.add(new Phrase("Impostos Selo: ".toUpperCase(), fontConteudo)); pConteudo.add(new Phrase( converterMoeda(impostosCalculo(map.get(TOTAl), map.get(IMPOSTOSELO)), map.get(SIGLAMOEDA) + "") + "\n", fontConteudoTxt)); pConteudo.add(new Phrase("FGA: ", fontConteudo)); pConteudo.add(new Phrase( converterMoeda(impostosCalculo(map.get(TOTAl), map.get(MOTORFOUND)), map.get(SIGLAMOEDA) + "") + "\n", fontConteudoTxt)); pConteudo.add(new Phrase("Total: ".toUpperCase(), fontConteudo)); pConteudo.add( new Phrase(converterMoeda(map.get(TOTAl), map.get(SIGLAMOEDA) + "") + "\n", fontConteudoTxt)); pConteudo.add(new Phrase("Efeito: ".toUpperCase(), fontConteudo)); pConteudo.add(new Phrase(converterData(map.get(EFEITO), 1) + "\n", fontConteudoTxt)); pConteudo.add(new Phrase("Vencimento: ".toUpperCase(), fontConteudo)); pConteudo.add(new Phrase(converterData(map.get(VENCIMENTO), 1) + "\n", fontConteudoTxt)); cellConteudo.addElement(pConteudo); pTableConteudo.addCell(cellConteudo); cellConteudo = new PdfPCell(); cellConteudo.setBorder(0); pConteudo = new Paragraph(); pConteudo.add(new Phrase("Recebido do Sr: ".toUpperCase(), fontConteudo)); pConteudo.add(new Phrase(map.get(CLIENTE) + "\n", fontConteudoTxt)); PdfPTable pTableNomeCod = new PdfPTable(new float[] { 70, 30 }); pTableNomeCod.setWidthPercentage(100); Paragraph pNomeCod = new Paragraph(); pNomeCod.add(new Phrase("Nome do Assegurado/Pagador: ".toUpperCase(), fontConteudo)); pNomeCod.add(new Phrase(map.get(CLIENTE) + "", fontConteudoTxt)); PdfPCell cellNomeCod = new PdfPCell(); cellNomeCod.addElement(pNomeCod); cellNomeCod.setBorder(0); cellNomeCod.setPaddingTop(-2f); cellNomeCod.setPaddingBottom(2f); pTableNomeCod.addCell(cellNomeCod); cellNomeCod = new PdfPCell(); pNomeCod = new Paragraph(); pNomeCod.add(new Phrase("Codigo: ".toUpperCase(), fontConteudo)); pNomeCod.add(new Phrase(" ", fontConteudoTxt)); cellNomeCod.addElement(pNomeCod); cellNomeCod.setBorder(0); cellNomeCod.setPaddingTop(-2f); cellNomeCod.setPaddingBottom(2f); pTableNomeCod.addCell(cellNomeCod); pNomeCod = new Paragraph(); pNomeCod.add(new Phrase("Nome do Intermedirio: ".toUpperCase(), fontConteudo)); pNomeCod.add(new Phrase(" ", fontConteudoTxt)); cellNomeCod = new PdfPCell(); cellNomeCod.addElement(pNomeCod); cellNomeCod.setBorder(0); cellNomeCod.setPaddingTop(-2f); cellNomeCod.setPaddingBottom(2f); pTableNomeCod.addCell(cellNomeCod); cellNomeCod = new PdfPCell(); pNomeCod = new Paragraph(); pNomeCod.add(new Phrase("Codigo: ".toUpperCase(), fontConteudo)); pNomeCod.add(new Phrase(" ", fontConteudoTxt)); cellNomeCod.addElement(pNomeCod); cellNomeCod.setBorder(0); cellNomeCod.setPaddingTop(-2f); cellNomeCod.setPaddingBottom(2f); pTableNomeCod.addCell(cellNomeCod); pConteudo.add(pTableNomeCod); JTextPane jtp = new JTextPane(); Double valor = Moeda.arrendodamento((map.get(VALORPRESTACAO) + "")); valor *= valorCompra(map.get(SIGLAMOEDA) + "", dRegistro); Moeda.EscreverEstenso(valor, jtp, "Dobras"); pConteudo.add(new Phrase("A soma (por extenso) ".toUpperCase(), fontConteudo)); pConteudo.add(new Phrase(jtp.getText().trim() + "\n", fontConteudoTxt)); PdfPTable pTableApoliceDatasP = new PdfPTable(new float[] { 20, 80 }); pTableApoliceDatasP.setWidthPercentage(100); PdfPTable pTableApoliceDatas = new PdfPTable(new float[] { 60, 40 }); pTableApoliceDatas.setWidthPercentage(100); for (int i = 0; i < 1; i++) { PdfPCell cellApolice = new PdfPCell(); Paragraph pApolice = new Paragraph(); pApolice.add(new Phrase("N ", fontConteudo)); pApolice.add(new Phrase(map.get(APOLICA) + "", fontConteudoTxt)); cellApolice.addElement(pApolice); cellApolice.setPaddingTop(-2f); cellApolice.setPaddingBottom(2f); cellApolice.setBorder(0); pTableApoliceDatas.addCell(cellApolice); PdfPCell cellDatas = new PdfPCell(); Paragraph pDatas = new Paragraph(); pDatas.add(new Phrase("Data: ".toUpperCase(), fontConteudo)); pDatas.add(new Phrase(converterData(map.get(DATAREGAPOLICE), 2) + "", fontConteudoTxt)); cellDatas.addElement(pDatas); cellDatas.setBorder(0); cellDatas.setPaddingTop(-2f); cellDatas.setPaddingBottom(2f); pTableApoliceDatas.addCell(cellDatas); } PdfPCell cellApoliceP = new PdfPCell(new Phrase("Apolices".toUpperCase(), fontConteudo)); cellApoliceP.setVerticalAlignment(Element.ALIGN_MIDDLE); cellApoliceP.setBorder(0); pTableApoliceDatasP.addCell(cellApoliceP); cellApoliceP = new PdfPCell(pTableApoliceDatas); cellApoliceP.setBorder(0); pTableApoliceDatasP.addCell(cellApoliceP); pConteudo.add(pTableApoliceDatasP); // PdfPTable pTableTipoPagemento = new PdfPTable(new float[] { 70f, 30f }); pTableTipoPagemento.setWidthPercentage(100f); PdfPCell cellTipoPageme = new PdfPCell(); Paragraph pDatas = new Paragraph(); pDatas.add(new Phrase("Pagamento: ".toUpperCase(), fontConteudo)); pDatas.add(new Phrase(map.get(TIPOPAGAMENTO) + " ", fontConteudoTxt)); cellTipoPageme.addElement(pDatas); cellTipoPageme.setBorder(0); cellTipoPageme.setPaddingTop(-2f); cellTipoPageme.setPaddingBottom(2f); // cellTipoPageme.setBorderColor(BaseColor.BLUE.darker().darker().darker()); // cellTipoPageme.setBorderWidthTop((i==0)?0.5f:0f); // cellTipoPageme.setBorderWidthBottom(0.5f); pTableTipoPagemento.addCell(cellTipoPageme); cellTipoPageme = new PdfPCell(); pDatas = new Paragraph(); pDatas.add(new Phrase("N ".toUpperCase(), fontConteudo)); pDatas.add(new Phrase(toString(map.get(DOCUMENTOAMORTIZACAO)) + " ", fontConteudoTxt)); cellTipoPageme.addElement(pDatas); cellTipoPageme.setBorder(0); cellTipoPageme.setPaddingTop(-2f); cellTipoPageme.setPaddingBottom(2f); // cellTipoPageme.setBorderColor(BaseColor.BLUE.darker().darker().darker()); // cellTipoPageme.setBorderWidthTop((i==0)?0.5f:0f); // cellTipoPageme.setBorderWidthBottom(0.5f); pTableTipoPagemento.addCell(cellTipoPageme); pConteudo.add(pTableTipoPagemento); cellConteudo.addElement(pConteudo); pTableConteudo.addCell(cellConteudo); PdfPCell cellConteudoPrincipal = new PdfPCell(new PdfPTable(pTableConteudo)); cellConteudoPrincipal.setBorder(PdfPCell.NO_BORDER); pTablePrincipal.addCell(cellConteudoPrincipal); PdfPTable pTableAssinatura = new PdfPTable(new float[] { 50f, 50f }); pTableAssinatura.setWidthPercentage(100f); Font fontConteudoTxt_acess = FontFactory.getFont(ConfigDoc.Fontes.FONT, BaseFont.WINANSI, BaseFont.EMBEDDED, 5f, Font.ITALIC, BaseColor.BLACK.darker().darker().darker()); Font fontConteudo_acess = FontFactory.getFont(ConfigDoc.Fontes.FONTB, BaseFont.WINANSI, BaseFont.EMBEDDED, 5f, Font.NORMAL, BaseColor.BLUE.darker().darker()); PdfPCell cellAcessorio = new PdfPCell(); Paragraph pAcessorio = new Paragraph(); pAcessorio.add(new Phrase("Acessrios: ".toUpperCase(), fontConteudo_acess)); pAcessorio.add(new Phrase( (map.get(ACCESSORIO) == null) ? " " : (map.get(ACCESSORIO) + "").replaceAll("\n", " "), fontConteudoTxt_acess)); cellAcessorio.addElement(pAcessorio); cellAcessorio.setColspan(2); cellAcessorio.setBorder(0); cellAcessorio.setPaddingBottom(4f); cellAcessorio.setPaddingTop(-2f); pTableAssinatura.addCell(cellAcessorio); PdfPCell cellLinhaAssina = new PdfPCell(); Paragraph pAssinatura = new Paragraph(); pAssinatura.add(new Paragraph("_________________________________", fontConteudo)); pAssinatura.add(new Paragraph(" Carimbo e Assinatura", fontConteudo)); pAssinatura.setAlignment(Element.ALIGN_CENTER); cellLinhaAssina.addElement(pAssinatura); cellLinhaAssina.setPaddingBottom(2f); cellLinhaAssina.setBorder(0); cellLinhaAssina.setPaddingTop(25f); pTableAssinatura.addCell(cellLinhaAssina); PdfPCell cellCambio = new PdfPCell(); Paragraph pCombio = new Paragraph(); pCombio.add(new Phrase("Cambio (USD): ".toUpperCase(), fontConteudo)); pCombio.add(new Phrase(converterMoeda(valorCompra("USD", dRegistro), "") + "\n", fontConteudoTxt)); pCombio.add(new Phrase("Cambio (EUR): ".toUpperCase(), fontConteudo)); pCombio.add(new Phrase(converterMoeda(valorCompra("EUR", dRegistro), "") + "\n", fontConteudoTxt)); cellCambio.addElement(pCombio); cellCambio.setBorder(0); cellCambio.setPaddingTop(-2f); cellCambio.setPaddingBottom(2f); pTableAssinatura.addCell(cellCambio); PdfPCell cellpTableAssinaturaPrincipal = new PdfPCell(pTableAssinatura); cellpTableAssinaturaPrincipal.setBorder(PdfPCell.NO_BORDER); pTablePrincipal.addCell(new PdfPCell(cellpTableAssinaturaPrincipal)); // pTableAssinatura.writeSelectedRows(-1, 2, 10, 70, writer.getDirectContent()); // pTableImagem.writeSelectedRows(-1, 2, 52.5f, 402.5f, writer.getDirectContent()); } catch (BadElementException | IOException ex) { Logger.getLogger(ReciboPagamento.class.getName()).log(Level.SEVERE, null, ex); } return pTablePrincipal; }
From source file:Export.SeguroAPG.java
public String criarDoc(String numApolice, String numCliente, Contrato c, AcidentePGBean apg, String user, String moeda, String arquivo) { try {/*from w w w . j a va 2 s. com*/ 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, 10.5f); Font fontCorpo = FontFactory.getFont(Fontes.FONT, BaseFont.WINANSI, BaseFont.EMBEDDED, 9f); Font fontCorpoTab = FontFactory.getFont(Fontes.FONT, BaseFont.WINANSI, BaseFont.EMBEDDED, 7.5f); Font fontCorpoP = FontFactory.getFont(Fontes.FONT, BaseFont.WINANSI, BaseFont.EMBEDDED, 7.5f); Font fontCorpoN = FontFactory.getFont(Fontes.FONTB, BaseFont.WINANSI, BaseFont.EMBEDDED, 9f); Font fontCorpoNTable = FontFactory.getFont(Fontes.FONTB, BaseFont.WINANSI, BaseFont.EMBEDDED, 8f); Font fontCorpoNG = FontFactory.getFont(Fontes.FONTB, BaseFont.WINANSI, BaseFont.EMBEDDED, 10.5f); Font fontCorpoNGT = FontFactory.getFont(Fontes.FONTB, BaseFont.WINANSI, BaseFont.EMBEDDED, 11f); Font fontCabecalhoNG = FontFactory.getFont(Fontes.FONTB, BaseFont.WINANSI, BaseFont.EMBEDDED, 16f, Font.UNDERLINE); // Font fontCorpoNGTi= FontFactory.getFont(Fontes.FONTB, BaseFont.WINANSI, BaseFont.EMBEDDED ,10f ); 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 Acidente Para grupo".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); PdfPCell cellTiltuloSegro = new PdfPCell( new Phrase("2 - Informaes Premio".toUpperCase(), fontCorpoNG)); cellTiltuloSegro.setBorder(0); PdfPCell cellApolice = new PdfPCell( new Phrase(" N Aplice: ".toUpperCase() + numApolice, fontCorpo)); cellApolice.setBorder(0); PdfPCell cellPropriedadeSegurada = new PdfPCell( new Phrase( " Propriedade segurada: ".toUpperCase() + apg.getInfo().size() + " " + "Trabalhodor".toUpperCase() + ((apg.getInfo().size() > 1) ? "ES" : ""), fontCorpo)); cellPropriedadeSegurada.setBorder(0); PdfPCell cellTotalSegurado = new PdfPCell( new Phrase(" Valor Total segrurado: ".toUpperCase() + c.getTotalSeguradoMoeda() + " " + moeda, fontCorpo)); cellTotalSegurado.setBorder(0); PdfPCell cellValor1Preminio = new PdfPCell(new Phrase( " Valor Primeiro Premio: ".toUpperCase() + ((c.getPrimeiroPremio() == null) ? "" : c.getPrimeiroPremio() + " " + moeda), fontCorpo)); cellValor1Preminio.setBorder(0); PdfPCell cellTotalPremioAnual = new PdfPCell(new Phrase(" Valor Premio Anual: ".toUpperCase() + ((c.getPremioAnual() == null) ? " " : c.getPremioAnual() + " " + moeda), fontCorpo)); 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.setBorder(0); PdfPCell cellDataRenovacao = new PdfPCell(new Phrase( " Data Renovao: ".toUpperCase() + ((c.getDataRenovacao() == null) ? " " : c.getDataRenovacao() + " " + moeda), fontCorpo)); cellDataRenovacao.setBorder(0); Paragraph p = new Paragraph(); Phrase p1 = new Phrase("BEnefcio (s) De Peessoa e Plano: ".toUpperCase(), fontCorpoN); Phrase p2 = new Phrase( "O Seguro Sob esta seco se aplique apenas as pessoas ou grupo das pessoas seguradas indicadas" .toUpperCase() + " e apenas de acordo com s coberturas para qual o valor foi especificado. o Valor especificado ser aplicado para " .toUpperCase() + "cada pessoa segurada por sinistro subjeito a todos os termos da apolice." .toUpperCase(), fontCorpo); p.add(p1); p.add(p2); PdfPCell cellNotaBenefi = new PdfPCell(p); cellNotaBenefi.setBorder(0); cellNotaBenefi.setHorizontalAlignment(Element.ALIGN_JUSTIFIED); PdfPCell cellCobertura = new PdfPCell(new Phrase( "Cobertuta Diria: ".toUpperCase() + ((apg.getAcidentePG().getTipoCobertura().equals("1")) ? "Apenas em situao de acidente de trabalho" : ((apg.getAcidentePG().getTipoCobertura().equals("2") ? "24 horas" : apg.getAcidentePG().getTipoCobertura()))), fontCorpo)); cellCobertura.setBorder(0); PdfPCell cellLimiteBeneficio = new PdfPCell( new Phrase("3 - Informaes de Limites de Benefcio:".toUpperCase(), fontCorpoNG)); cellLimiteBeneficio.setBorder(0); PdfPCell cellLimiteA = new PdfPCell(new Phrase(" Benefcio A: Morte: ".toUpperCase() + apg.getAcidentePG().getPremioMorteMoeda() + " " + moeda, fontCorpo)); cellLimiteA.setBorder(0); PdfPCell cellLimiteB = new PdfPCell(new Phrase(" Benefcio B: Invalidez permanete: ".toUpperCase() + apg.getAcidentePG().getPremioIncapacidadePermanenteMoeda() + " " + moeda, fontCorpo)); cellLimiteB.setBorder(0); PdfPCell cellLimiteC = new PdfPCell( new Phrase(" Benefcio C: Reembolso das despesas Mdica Acidental: ".toUpperCase() + apg.getAcidentePG().getPremioDespesaMedicaMoeda() + " " + moeda, fontCorpo)); cellLimiteC.setBorder(0); PdfPCell cellLimiteGlobal = new PdfPCell( new Phrase(" Limite Global de Responsabilidade: ".toUpperCase() + c.getTotalSeguradoMoeda() + " " + moeda, fontCorpo)); cellLimiteGlobal.setBorder(0); pTableSeguro.addCell(cellTiltuloSegro); pTableSeguro.addCell(cellApolice); pTableSeguro.addCell(cellPropriedadeSegurada); pTableSeguro.addCell(cellTotalSegurado); pTableSeguro.addCell(cellValor1Preminio); pTableSeguro.addCell(cellTotalPremioAnual); pTableSeguro.addCell(cellPeriodo); pTableSeguro.addCell(cellDataRenovacao); pTableSeguro.addCell(cellNull); pTableSeguro.addCell(cellNotaBenefi); pTableSeguro.addCell(cellNull); pTableSeguro.addCell(cellCobertura); pTableSeguro.addCell(cellNull); pTableSeguro.addCell(cellLimiteBeneficio); pTableSeguro.addCell(cellLimiteA); pTableSeguro.addCell(cellLimiteB); pTableSeguro.addCell(cellLimiteC); pTableSeguro.addCell(cellLimiteGlobal); PdfPTable pTableDados = new PdfPTable(new float[] { 7, 15.5f, 15.5f, 15.5f, 15.f, 15.5f, 15.5f }); PdfPCell cellDadosNum = new PdfPCell(new Phrase("No.".toUpperCase(), fontCorpoNTable)); cellDadosNum.setBorderWidth(1); PdfPCell cellDadosSegurado = new PdfPCell(new Phrase("Nome Segurado".toUpperCase(), fontCorpoNTable)); cellDadosSegurado.setBorderWidth(1); PdfPCell cellDadosCategoria = new PdfPCell( new Phrase("Categoria do Segurado".toUpperCase(), fontCorpoNTable)); cellDadosCategoria.setBorderWidth(1); PdfPCell cellDadosBeneficioMorte = new PdfPCell( new Phrase("Beneficio Em caso de morte por pessoa".toUpperCase(), fontCorpoNTable)); cellDadosBeneficioMorte.setBorderWidth(1); PdfPCell cellDadosInvalidez = new PdfPCell(new Phrase( "Beneficio Em caso de Invalidez permanente por pessoa".toUpperCase(), fontCorpoNTable)); cellDadosInvalidez.setBorderWidth(1); PdfPCell cellDadosTemporaria = new PdfPCell(new Phrase( "Beneficio Em caso de Invalidez temporaria por pessoa".toUpperCase(), fontCorpoNTable)); cellDadosTemporaria.setBorderWidth(1); PdfPCell cellDadosDepesasMedica = new PdfPCell( new Phrase("Despesa Medica Por Pessoa".toUpperCase(), fontCorpoNTable)); cellDadosDepesasMedica.setBorderWidth(1); pTableDados.addCell(cellDadosNum); pTableDados.addCell(cellDadosSegurado); pTableDados.addCell(cellDadosCategoria); pTableDados.addCell(cellDadosBeneficioMorte); pTableDados.addCell(cellDadosInvalidez); pTableDados.addCell(cellDadosTemporaria); pTableDados.addCell(cellDadosDepesasMedica); int total = (apg.getInfo() == null) ? 0 : apg.getInfo().size(); for (int i = 0; i < total; i++) { cellDadosNum = new PdfPCell(new Phrase((i + 1) + " ", fontCorpoTab)); cellDadosNum.setBorderWidth(1); cellDadosNum.setPaddingTop(5f); cellDadosNum.setPaddingBottom(5f); cellDadosSegurado = new PdfPCell(new Phrase(apg.getInfo().get(i).getNome(), fontCorpoTab)); cellDadosSegurado.setBorderWidth(1); cellDadosSegurado.setPaddingTop(5f); cellDadosSegurado.setPaddingBottom(5f); cellDadosCategoria = new PdfPCell(new Phrase(apg.getInfo().get(i).getCategoria(), fontCorpoTab)); cellDadosCategoria.setHorizontalAlignment(Element.ALIGN_CENTER); cellDadosCategoria.setBorderWidth(1); cellDadosCategoria.setPaddingTop(5f); cellDadosCategoria.setPaddingBottom(5f); cellDadosBeneficioMorte = new PdfPCell( new Phrase(apg.getInfo().get(i).getValorMorte() + " " + moeda, fontCorpoTab)); cellDadosBeneficioMorte.setHorizontalAlignment(Element.ALIGN_CENTER); cellDadosBeneficioMorte.setBorderWidth(1); cellDadosBeneficioMorte.setPaddingTop(5f); cellDadosBeneficioMorte.setPaddingBottom(5f); cellDadosInvalidez = new PdfPCell( new Phrase(apg.getInfo().get(i).getIncapacidadeTotal() + " " + moeda, fontCorpoTab)); cellDadosInvalidez.setHorizontalAlignment(Element.ALIGN_CENTER); cellDadosInvalidez.setBorderWidth(1); cellDadosInvalidez.setPaddingTop(5f); cellDadosInvalidez.setPaddingBottom(5f); cellDadosTemporaria = new PdfPCell(new Phrase( apg.getInfo().get(i).getIncapacidadeTotalTemporaria() + " " + moeda, fontCorpoTab)); cellDadosTemporaria.setHorizontalAlignment(Element.ALIGN_CENTER); cellDadosTemporaria.setBorderWidth(1); cellDadosTemporaria.setPaddingTop(5f); cellDadosTemporaria.setPaddingBottom(5f); cellDadosDepesasMedica = new PdfPCell( new Phrase(apg.getInfo().get(i).getDespesaMedica() + " " + moeda, fontCorpoTab)); cellDadosDepesasMedica.setHorizontalAlignment(Element.ALIGN_CENTER); cellDadosDepesasMedica.setBorderWidth(1); cellDadosDepesasMedica.setPaddingTop(5f); cellDadosDepesasMedica.setPaddingBottom(5f); pTableDados.addCell(cellDadosNum); pTableDados.addCell(cellDadosSegurado); pTableDados.addCell(cellDadosCategoria); pTableDados.addCell(cellDadosBeneficioMorte); pTableDados.addCell(cellDadosInvalidez); pTableDados.addCell(cellDadosTemporaria); pTableDados.addCell(cellDadosDepesasMedica); } PdfPTable pTableRenovacaoDataHoje = new PdfPTable(1); PdfPCell cellRenovacao = new PdfPCell(new Phrase("Prmio de renovao: ".toUpperCase() + ((c.getPremioAnual() == null) ? " " : c.getPremioAnual() + " " + moeda), fontCorpo)); cellRenovacao.setBorder(0); PdfPCell cellData = new PdfPCell( new Phrase("Data: ".toUpperCase() + sdf.format(new Date()), fontCorpo)); cellData.setBorder(0); pTableRenovacaoDataHoje.addCell(cellRenovacao); pTableRenovacaoDataHoje.addCell(cellData); 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 Acidente para Grupo\\"); // ff.mkdirs(); // ff =new File(ff.getAbsoluteFile()+"\\"+"Formulario Seguro Acidente Para Grupo "+sdf1.format(new Date())+".pdf"); File ff = new File(arquivo + "/" + user + "/Seguro Acidente Para Grupo/"); ff.mkdirs(); String Ddata = sdf1.format(new Date()); System.err.println(ff.getAbsoluteFile()); ff = new File(ff.getAbsoluteFile() + "/" + "Formulario Seguro Acidente Para Grupo " + Ddata + ".pdf"); reString = "../Documentos/" + user + "/Seguro Acidente Para Grupo/" + "Formulario Seguro Acidente Para Grupo " + 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(pTableNull); documento.add(pTableNull); documento.add(pTableTitulo); documento.add(pTableNull); documento.add(pTableNull); documento.add(pTableCliente); documento.add(pTableNull); documento.add(pTableSeguro); documento.newPage(); documento.add(pTableDados); documento.add(pTableNull); documento.add(pTableRenovacaoDataHoje); 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.SeguroCoberturaViagem.java
private static void criarDoc(Document documento, ViagemBean vb, String numCriente, String user, Contrato c, int i) throws DocumentException, FileNotFoundException, IOException, BadElementException { BaseColor colorVermelho = new BaseColor(193, 51, 51); BaseColor coloAzul = new BaseColor(0, 0, 179); Font fontCabecalhoN = FontFactory.getFont(Fontes.FONTB, BaseFont.WINANSI, BaseFont.EMBEDDED, 10.5f, Font.NORMAL, coloAzul); Font fontCabecalhoTitile = FontFactory.getFont(Fontes.FONTB, BaseFont.WINANSI, BaseFont.EMBEDDED, 14.5f, Font.UNDERLINE, colorVermelho); Font fontTableSimple = FontFactory.getFont(Fontes.FONT, BaseFont.WINANSI, BaseFont.EMBEDDED, 8.5f); Font fontTableNegrito = FontFactory.getFont(Fontes.FONTB, BaseFont.WINANSI, BaseFont.EMBEDDED, 8.5f); Font fontTableSimpleMenor = FontFactory.getFont(Fontes.FONT, BaseFont.WINANSI, BaseFont.EMBEDDED, 8f); Font fontTableItalico = FontFactory.getFont(Fontes.FONTBI, BaseFont.WINANSI, BaseFont.EMBEDDED, 8f); Font fontTableNormal = FontFactory.getFont(Fontes.FONT, BaseFont.WINANSI, BaseFont.EMBEDDED, 8f); Font fontTableSimpleCausulas = FontFactory.getFont(Fontes.FONT, BaseFont.WINANSI, BaseFont.EMBEDDED, 8.999999f);/*from w w w. ja va 2 s. com*/ // SimpleDateFormat sdf= new SimpleDateFormat("dd-MM-yyyy"); Font fontCabecalhoNP = FontFactory.getFont(Fontes.FONTB, BaseFont.WINANSI, BaseFont.EMBEDDED, 9.5f); Font fontCorpo = FontFactory.getFont(Fontes.FONT, BaseFont.WINANSI, BaseFont.EMBEDDED, 8.5f); Font fontCabecalhoNG = FontFactory.getFont(Fontes.FONTB, BaseFont.WINANSI, BaseFont.EMBEDDED, 16f, Font.UNDERLINE, coloAzul); PdfPTable pTableEmpresaPricipal = new PdfPTable(new float[] { 23f, 77f }); pTableEmpresaPricipal.setWidthPercentage(92); 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); 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 cellTabela1 = new PdfPCell(pTableEmpresaInforImpres2); cellTabela1.setBorder(0); 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 pTableTitulo = new PdfPTable(1); pTableTitulo.setWidthPercentage(92f); PdfPCell paragraphTitulo = new PdfPCell(new Phrase("SEGURO DE VIAGEM", fontCabecalhoTitile)); paragraphTitulo.setHorizontalAlignment(Element.ALIGN_CENTER); paragraphTitulo.setBorder(0); pTableTitulo.addCell(paragraphTitulo); PdfPTable pTablePrincipalSegurado = new PdfPTable(new float[] { 55, 45 }); pTablePrincipalSegurado.setWidthPercentage(92); Paragraph pa = new Paragraph(new Phrase("NOME DO SEGURADO: ", fontTableSimple)); pa.add(new Phrase(vb.getInfoPessoaSegurada().get(i).getNomePessoaSegurada().toUpperCase(), fontTableNegrito)); PdfPCell cellSegurado02 = new PdfPCell(pa); pa = new Paragraph(new Phrase("Endereo: ".toUpperCase(), fontTableSimple)); pa.add(new Phrase(vb.getInfoPessoaSegurada().get(i).getEndereco().toUpperCase(), fontTableNegrito)); PdfPCell cellSegurado12 = new PdfPCell(pa); pa = new Paragraph(new Phrase("Data e Local de Nascimento: ".toUpperCase(), fontTableSimple)); pa.add(new Phrase(vb.getInfoPessoaSegurada().get(i).getDataNascFormatada().toUpperCase(), fontTableNegrito)); pa.add(new Phrase(" EM", fontTableSimple)); pa.add(new Phrase(" " + vb.getInfoPessoaSegurada().get(i).getLocalNascimento().toUpperCase(), fontTableNegrito)); PdfPCell cellSegurado21 = new PdfPCell(pa); pa = new Paragraph(new Phrase("Sexo: ".toUpperCase(), fontTableSimple)); pa.add(new Phrase(vb.getInfoPessoaSegurada().get(i).getSexo().toUpperCase(), fontTableNegrito)); pa.add(new Phrase(" Tel: ".toUpperCase(), fontTableSimple)); pa.add(new Phrase(vb.getInfoPessoaSegurada().get(i).getTelefone().toUpperCase(), fontTableNegrito)); PdfPCell cellSegurado22 = new PdfPCell(pa); pa = new Paragraph(new Phrase("Aplice: ".toUpperCase(), fontTableSimple)); pa.add(new Phrase(vb.getInfoPessoaSegurada().get(i).getNumApolice().toUpperCase(), fontTableNegrito)); PdfPCell cellSegurado31 = new PdfPCell(pa); String[] codCliente = vb.getInfoPessoaSegurada().get(i).getNumApolice().split("/"); pa = new Paragraph(new Phrase("Cliente: ".toUpperCase(), fontTableSimple)); pa.add(new Phrase(((codCliente.length == 2) ? "TIN " + codCliente[1] : "TIN ").toUpperCase(), fontTableNegrito)); PdfPCell cellSegurado32 = new PdfPCell(pa); pa = new Paragraph(new Phrase("Durao: ".toUpperCase(), fontTableSimple)); pa.add(new Phrase(vb.getInfoPessoaSegurada().get(i).getNumDias() + " DIAS", fontTableNegrito)); PdfPCell cellSegurado41 = new PdfPCell(pa); pa = new Paragraph(new Phrase("Perodo: DE ".toUpperCase(), fontTableSimple)); pa.add(new Phrase(sdfPot.format(vb.getInfoPessoaSegurada().get(i).getDataInicio()).toUpperCase(), fontTableNegrito)); pa.add(new Phrase(" ".toUpperCase(), fontTableSimple)); pa.add(new Phrase(((vb.getInfoPessoaSegurada().get(i).getDataFim() != null) ? sdfPot.format(vb.getInfoPessoaSegurada().get(i).getDataFim()) : " ").toUpperCase(), fontTableNegrito)); PdfPCell cellSegurado42 = new PdfPCell(pa); pa = new Paragraph(new Phrase("Data de Emisso: ".toUpperCase(), fontTableSimple)); pa.add(new Phrase(sdfPot.format(c.getDataContrato()).toUpperCase(), fontTableNegrito)); PdfPCell cellSegurado51 = new PdfPCell(pa); pa = new Paragraph(new Phrase("Destino: ".toUpperCase(), fontTableSimple)); pa.add(new Phrase( ClienteDao.paisesSelected(vb.getInfoPessoaSegurada().get(i).getPaisDestino().toUpperCase()), fontTableNegrito)); pa.add(new Phrase(" N de Pessoas: ".toUpperCase(), fontTableSimple)); pa.add(new Phrase((i + 1) + "".toUpperCase(), fontTableNegrito)); PdfPCell cellSegurado52 = new PdfPCell(pa); // PASSAPORTE BILHETE IDENTIDADE pa = new Paragraph(new Phrase("Meio de Identificao: ".toUpperCase(), fontTableSimple)); pa.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())), fontTableNegrito)); pa.add(new Phrase(" N ".toUpperCase(), fontTableSimple)); pa.add(new Phrase(vb.getInfoPessoaSegurada().get(i).getNumDoc().toUpperCase(), fontTableNegrito)); PdfPCell cellSegurado61 = new PdfPCell(pa); pa = new Paragraph(new Phrase("Emitido EM: ".toUpperCase(), fontTableSimple)); pa.add(new Phrase(vb.getInfoPessoaSegurada().get(i).getLocalEmissao().toUpperCase() + " ".toUpperCase(), fontTableNegrito)); pa.add(new Phrase(" em ".toUpperCase(), fontTableSimple)); pa.add(new Phrase(vb.getInfoPessoaSegurada().get(i).getDataEmissaoFormatada().toUpperCase(), fontTableNegrito)); PdfPCell cellSegurado62 = new PdfPCell(pa); pa = new Paragraph(new Phrase("Outras Informaes: ".toUpperCase(), fontTableSimple)); pa.add(new Phrase( ((vb.getInfoPessoaSegurada().get(i).getOutrasInformacoes() == null) ? " " : vb.getInfoPessoaSegurada().get(i).getOutrasInformacoes().toUpperCase()).toUpperCase(), fontTableNegrito)); PdfPCell cellSegurado72 = new PdfPCell(pa); cellSegurado02.setBorder(0); cellSegurado02.setColspan(2); pTablePrincipalSegurado.addCell(cellSegurado02); cellSegurado12.setColspan(2); cellSegurado12.setBorder(0); pTablePrincipalSegurado.addCell(cellSegurado12); cellSegurado21.setBorder(0); pTablePrincipalSegurado.addCell(cellSegurado21); cellSegurado22.setBorder(0); pTablePrincipalSegurado.addCell(cellSegurado22); cellSegurado31.setBorder(0); pTablePrincipalSegurado.addCell(cellSegurado31); cellSegurado32.setBorder(0); pTablePrincipalSegurado.addCell(cellSegurado32); cellSegurado41.setBorder(0); pTablePrincipalSegurado.addCell(cellSegurado41); cellSegurado42.setBorder(0); pTablePrincipalSegurado.addCell(cellSegurado42); cellSegurado51.setBorder(0); pTablePrincipalSegurado.addCell(cellSegurado51); cellSegurado52.setBorder(0); pTablePrincipalSegurado.addCell(cellSegurado52); cellSegurado61.setBorder(0); pTablePrincipalSegurado.addCell(cellSegurado61); cellSegurado62.setBorder(0); pTablePrincipalSegurado.addCell(cellSegurado62); cellSegurado72.setBorder(0); cellSegurado72.setColspan(2); pTablePrincipalSegurado.addCell(cellSegurado72); PdfPTable pTableOtros = new PdfPTable(1); pTableOtros.setWidthPercentage(92f); // PdfPCell paragraphOutros = new PdfPCell(new Phrase("Outros Informaes:",fontTableSimple)); PdfPCell paragraphNotaDebito = new PdfPCell(new Phrase(" ", fontTableNegrito)); PdfPCell paragraphAmbitoC = new PdfPCell( new Phrase("mbito de Cobertura/Condies Particulares:", fontTableSimple)); // paragraphOutros.setBorder(0); // pTableOtros.addCell(paragraphOutros); paragraphNotaDebito.setBorder(0); pTableOtros.addCell(paragraphNotaDebito); paragraphAmbitoC.setBorder(0); paragraphAmbitoC.setPaddingBottom(5f); pTableOtros.addCell(paragraphAmbitoC); PdfPTable pTableCobertura = new PdfPTable(new float[] { 70, 30 }); pTableCobertura.setWidthPercentage(92); PdfPCell cellTable11 = new PdfPCell(new Phrase("COBERTURA", fontTableNegrito)); PdfPCell cellTable12 = new PdfPCell(new Phrase("Limites de Indemnizao", fontTableNegrito)); PdfPCell cellTable21 = new PdfPCell( new Phrase("Depesas mdicas, Cirgias, Farmacutica e de Hospitalizao no Estrangeiro", fontTableSimpleMenor)); PdfPCell cellTable22 = new PdfPCell(new Phrase("Euros 30.000 Franquia: 80 Euros", fontTableSimpleMenor)); PdfPCell cellTable31 = new PdfPCell( new Phrase("Acompanhamento da pessoa segura hospitalizada", fontTableSimpleMenor)); PdfPCell cellTable32 = new PdfPCell(new Phrase("Dia: Euros 70/ Mximo:Euros 700", fontTableSimpleMenor)); PdfPCell cellTable41 = new PdfPCell( new Phrase("Transporte de ida e volta de familiar e estadia", fontTableSimpleMenor)); PdfPCell cellTable42 = new PdfPCell(new Phrase("Dia: Euros 70/ Mximo: Euros 700", fontTableSimpleMenor)); PdfPCell cellTable51 = new PdfPCell(new Phrase("Prolongamento de estadia no Hotel", fontTableSimpleMenor)); PdfPCell cellTable52 = new PdfPCell(new Phrase("Dia: Euros 40/ Mximo: Euros 400", fontTableSimpleMenor)); PdfPCell cellTable61 = new PdfPCell( new Phrase("Repatriamento / Transporte sanitrio de feridos e doentes", fontTableSimpleMenor)); PdfPCell cellTable62 = new PdfPCell(new Phrase("Ilimitado", fontTableSimpleMenor)); PdfPCell cellTable71 = new PdfPCell( new Phrase("Repatriamento / Transporte aps a morte", fontTableSimpleMenor)); PdfPCell cellTable72 = new PdfPCell(new Phrase("Ilimitado", fontTableSimpleMenor)); PdfPCell cellTable81 = new PdfPCell( new Phrase("Transporte ou Repatriamento das restantes pessoas seguras", fontTableSimpleMenor)); PdfPCell cellTable82 = new PdfPCell(new Phrase("Ilimitado", fontTableSimpleMenor)); PdfPCell cellTable91 = new PdfPCell( new Phrase("Superviso de crianas no estrangeiro", fontTableSimpleMenor)); PdfPCell cellTable92 = new PdfPCell(new Phrase("Ilimitado", fontTableSimpleMenor)); PdfPCell cellTable101 = new PdfPCell( new Phrase("Regresso antecipado por falecimento de familiar", fontTableSimpleMenor)); PdfPCell cellTable102 = new PdfPCell(new Phrase("Ilimitado", fontTableSimpleMenor)); PdfPCell cellTable111 = new PdfPCell( new Phrase("Localizao e envio de medicamentos de urgncia", fontTableSimpleMenor)); PdfPCell cellTable112 = new PdfPCell(new Phrase("Ilimitado", fontTableSimpleMenor)); PdfPCell cellTable121 = new PdfPCell( new Phrase("Transporte ou repatriamento de bagagens", fontTableSimpleMenor)); PdfPCell cellTable122 = new PdfPCell( new Phrase("Limite imposto pela Empresa Transportadora", fontTableSimpleMenor)); PdfPCell cellTable131 = new PdfPCell( new Phrase("Adiantamento de fundos no estrangeiro", fontTableSimpleMenor)); PdfPCell cellTable132 = new PdfPCell(new Phrase("Mximo: Euros 700", fontTableSimpleMenor)); PdfPCell cellTable141 = new PdfPCell(new Phrase("Aconselhamento mdico", fontTableSimpleMenor)); PdfPCell cellTable142 = new PdfPCell(new Phrase("Ilimitado", fontTableSimpleMenor)); PdfPCell cellTable151 = new PdfPCell( new Phrase("Pagamento de despesas de comunicao", fontTableSimpleMenor)); PdfPCell cellTable152 = new PdfPCell(new Phrase("Ilimitado", fontTableSimpleMenor)); PdfPCell cellTable161 = new PdfPCell(new Phrase("Servios informativos", fontTableSimpleMenor)); PdfPCell cellTable162 = new PdfPCell(new Phrase("Ilimitado", fontTableSimpleMenor)); cellTable11.setHorizontalAlignment(Element.ALIGN_CENTER); pTableCobertura.addCell(cellTable11); cellTable12.setHorizontalAlignment(Element.ALIGN_CENTER); pTableCobertura.addCell(cellTable12); pTableCobertura.addCell(cellTable21); cellTable22.setHorizontalAlignment(Element.ALIGN_CENTER); pTableCobertura.addCell(cellTable22); pTableCobertura.addCell(cellTable31); cellTable32.setHorizontalAlignment(Element.ALIGN_CENTER); pTableCobertura.addCell(cellTable32); pTableCobertura.addCell(cellTable41); cellTable42.setHorizontalAlignment(Element.ALIGN_CENTER); pTableCobertura.addCell(cellTable42); pTableCobertura.addCell(cellTable51); cellTable52.setHorizontalAlignment(Element.ALIGN_CENTER); pTableCobertura.addCell(cellTable52); pTableCobertura.addCell(cellTable61); cellTable62.setHorizontalAlignment(Element.ALIGN_CENTER); pTableCobertura.addCell(cellTable62); pTableCobertura.addCell(cellTable71); cellTable72.setHorizontalAlignment(Element.ALIGN_CENTER); pTableCobertura.addCell(cellTable72); pTableCobertura.addCell(cellTable81); cellTable82.setHorizontalAlignment(Element.ALIGN_CENTER); pTableCobertura.addCell(cellTable82); pTableCobertura.addCell(cellTable91); cellTable92.setHorizontalAlignment(Element.ALIGN_CENTER); pTableCobertura.addCell(cellTable92); pTableCobertura.addCell(cellTable101); cellTable102.setHorizontalAlignment(Element.ALIGN_CENTER); pTableCobertura.addCell(cellTable102); pTableCobertura.addCell(cellTable111); cellTable112.setHorizontalAlignment(Element.ALIGN_CENTER); pTableCobertura.addCell(cellTable112); pTableCobertura.addCell(cellTable121); cellTable122.setHorizontalAlignment(Element.ALIGN_CENTER); pTableCobertura.addCell(cellTable122); pTableCobertura.addCell(cellTable131); cellTable132.setHorizontalAlignment(Element.ALIGN_CENTER); pTableCobertura.addCell(cellTable132); pTableCobertura.addCell(cellTable141); cellTable142.setHorizontalAlignment(Element.ALIGN_CENTER); pTableCobertura.addCell(cellTable142); pTableCobertura.addCell(cellTable151); cellTable152.setHorizontalAlignment(Element.ALIGN_CENTER); pTableCobertura.addCell(cellTable152); pTableCobertura.addCell(cellTable161); cellTable162.setHorizontalAlignment(Element.ALIGN_CENTER); pTableCobertura.addCell(cellTable162); PdfPTable pTableCausuala = new PdfPTable(1); pTableCausuala.setWidthPercentage(92); PdfPCell paragraphParaFamilha = new PdfPCell(new Phrase( "1. Para Famlia e/ou Grupo, fornecer uma lista anexada com outros detalhes necessrios.", fontTableSimpleCausulas)); paragraphParaFamilha.setHorizontalAlignment(Element.ALIGN_JUSTIFIED); paragraphParaFamilha.setPaddingBottom(7f); PdfPCell paragraphOPresente = new PdfPCell(new Phrase( "2. O presente Contrato baseia-se na proposta do Segurador e regido pelos termos referidos nas " + "Condies Gerais e Especiais e de Excluses anexadas ao presente documento.", fontTableSimpleCausulas)); paragraphOPresente.setHorizontalAlignment(Element.ALIGN_JUSTIFIED); paragraphOPresente.setPaddingBottom(7f); PdfPCell paragraphOPremio = new PdfPCell(new Phrase( "3. O Prmio pago no reembolsvel excepto a rejeio da aplice pela Embaixada.", fontTableSimpleCausulas)); paragraphOPremio.setHorizontalAlignment(Element.ALIGN_JUSTIFIED); paragraphOPremio.setPaddingBottom(7f); PdfPCell paragraphOSeguro = new PdfPCell(new Phrase( "4. O Segurado declara que as informaes prestadas so verdadeiras e completas e declara ter " + "lido as condies Gerais e Especiais e as Excluses e concordado com as disposies nelas contidas.", fontTableSimpleCausulas)); paragraphOSeguro.setHorizontalAlignment(Element.ALIGN_JUSTIFIED); paragraphOSeguro.setPaddingBottom(7f); PdfPCell paragraphSolitacao = new PdfPCell(new Phrase( "5. Solicitao de reembolso deve ser feita por carta dirigida a Directora Geral da NICON Seguros STP, " + "3 dias antes da data de inicio do seguro, e deve ser acompanhada da aplice original e da fotocpia da carta de rejeio da Embaixada.", fontTableSimpleCausulas)); paragraphSolitacao.setHorizontalAlignment(Element.ALIGN_JUSTIFIED); // paragraphSolitacao.setPaddingBottom(7f); paragraphParaFamilha.setBorder(0); pTableCausuala.addCell(paragraphParaFamilha); paragraphOPresente.setBorder(0); pTableCausuala.addCell(paragraphOPresente); paragraphOPremio.setBorder(0); pTableCausuala.addCell(paragraphOPremio); paragraphOSeguro.setBorder(0); pTableCausuala.addCell(paragraphOSeguro); paragraphSolitacao.setBorder(0); pTableCausuala.addCell(paragraphSolitacao); PdfPTable pTableNota = new PdfPTable(1); pTableNota.setWidthPercentage(92); PdfPCell paragraphNota = new PdfPCell(new Phrase( " condio indispensvel para usufruir das garantias deste contrato que o Subscritor ou Pessoas Seguradas contactem de imediato:", fontTableItalico)); paragraphNota.setBorder(0); pTableNota.addCell(paragraphNota); PdfPTable pTableRotape = new PdfPTable(1); pTableRotape.setWidthPercentage(92); Paragraph p = new Paragraph(); Image imageRotape = Image.getInstance(ConfigDoc.Fontes.getDiretorio() + "/europ-assistance2.jpg"); imageRotape.scaleToFit(90, 40); p.add(new Chunk(imageRotape, 1, 1, true)); Phrase phraseRodape = new Phrase( ", COMPAINHA PORTUGUESA DE SEGUROS DE ASSISTNCIA, Tel. 351 21 384 80 97 Fax: 351 21 386 03 08 www.europ-assitance.pt", fontTableNormal); p.add(phraseRodape); PdfPCell cellRodape = new PdfPCell(p); cellRodape.setPaddingTop(10f); cellRodape.setBorder(0); pTableRotape.addCell(cellRodape); PdfPTable pTableAsinatura = new PdfPTable(2); pTableAsinatura.setWidthPercentage(92); PdfPCell cellSeguradora = new PdfPCell(new Phrase("A Seguradora", fontTableSimpleCausulas)); cellSeguradora.setBorder(0); cellSeguradora.setPaddingTop(25); cellSeguradora.setHorizontalAlignment(Element.ALIGN_CENTER); PdfPCell cellSegurado = new PdfPCell(new Phrase("O Segurado", fontTableSimpleCausulas)); cellSegurado.setPaddingTop(25); cellSegurado.setBorder(0); cellSegurado.setHorizontalAlignment(Element.ALIGN_CENTER); PdfPCell cellSeguradoValor = new PdfPCell( new Phrase("____________________________", fontTableSimpleCausulas)); cellSeguradoValor.setBorder(0); cellSeguradoValor.setHorizontalAlignment(Element.ALIGN_CENTER); pTableAsinatura.addCell(cellSeguradora); pTableAsinatura.addCell(cellSegurado); pTableAsinatura.addCell(cellSeguradoValor); pTableAsinatura.addCell(cellSeguradoValor); // documento.open(); documento.add(pTableEmpresaPricipal); documento.add(pTableTitulo); documento.add(pTableNull); documento.add(pTablePrincipalSegurado); documento.add(pTableOtros); // documento.add(pTableNull); documento.add(pTableCobertura); documento.add(pTableNull); documento.add(pTableCausuala); documento.add(pTableNull); documento.add(pTableNota); documento.add(pTableRotape); documento.add(pTableNull); documento.add(pTableAsinatura); if ((i + 1) != vb.getInfoPessoaSegurada().size()) documento.newPage(); //PrintPdf printPdf = new PrintPdf("Cobertura Viagem.pdf", "Cobertura Viagem.pdf", 0, 595f,842f,"Enviar Para o OneNote 2013",1); // PrintPdf printPdf = new PrintPdf("Cobertura Viagem.pdf", "Cobertura Viagem.pdf", 0, 595f,842f,"Hewlett-Packard HP LaserJet P2035",1); // printPdf.print(); }
From source file:Export.SeguroViatura.java
public String criarDoc(String numApolice, String numCliente, Contrato c, VeiculoBean vb, String user, String arquivo) {// ww w.j av a 2s . 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 {//from ww w. ja va 2s. c o 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 Vitals Table - The vitals of the encounter * * @param encounter the encounter item/*from ww w . j a va 2 s. c o m*/ * @param vitalMap the map of the vital values * @return PdfPTable the itext table to add to the document */ private PdfPTable createVitalsTable(PatientEncounterItem encounter, VitalMultiMap vitalMap) { PdfPTable table = getDefaultTable(3); table.addCell(getDefaultHeaderCell("Patient Vitals", 3)); table.addCell(getVitalMapCell("Blood Pressure: ", "bloodPressure", vitalMap)); table.addCell(getVitalMapCell("Temperature:", "temperature", vitalMap)); table.addCell(getVitalMapCell("Glucose:", "glucose", vitalMap)); table.addCell(getVitalMapCell("Heart Rate: ", "bloodPressure", vitalMap)); table.addCell(getVitalMapCell("Respiration Rate:", "respiratoryRate", vitalMap)); table.addCell(getVitalMapCell("Oxygen Saturation:", "oxygenSaturation", vitalMap)); //Sam Zanni PdfPCell cell = new PdfPCell(table.getDefaultCell()); cell.setPaddingTop(2); table.addCell(getVitalMapCell("Weeks Pregnant:", "weeksPregnant", vitalMap)); table.completeRow(); return table; }
From source file:fll.web.playoff.ScoresheetGenerator.java
License:Open Source License
public void writeFile(final OutputStream out, final boolean orientationIsPortrait) throws DocumentException { // This creates our new PDF document and declares its orientation Document pdfDoc;/*from w w w .jav a2 s . co m*/ if (orientationIsPortrait) { pdfDoc = new Document(PageSize.LETTER); // portrait } else { pdfDoc = new Document(PageSize.LETTER.rotate()); // landscape } PdfWriter.getInstance(pdfDoc, out); // Measurements are always in points (72 per inch) // This sets up 1/2 inch margins side margins and 0.35in top and bottom // margins pdfDoc.setMargins(0.5f * POINTS_PER_INCH, 0.5f * POINTS_PER_INCH, 0.35f * POINTS_PER_INCH, 0.35f * POINTS_PER_INCH); pdfDoc.open(); // Header cell with challenge title to add to both scoresheets final Paragraph titleParagraph = new Paragraph(); final Chunk titleChunk = new Chunk(m_pageTitle, FontFactory.getFont(FontFactory.HELVETICA_BOLD, 14, Font.NORMAL, BaseColor.WHITE)); titleParagraph.setAlignment(Element.ALIGN_CENTER); titleParagraph.add(titleChunk); titleParagraph.add(Chunk.NEWLINE); final Chunk swVersionChunk = new Chunk("SW version: " + Version.getVersion(), FontFactory.getFont(FontFactory.HELVETICA, 8, Font.NORMAL, BaseColor.WHITE)); titleParagraph.add(swVersionChunk); if (null != m_revision) { final Chunk revisionChunk = new Chunk(" Descriptor revision: " + m_revision, FontFactory.getFont(FontFactory.HELVETICA, 8, Font.NORMAL, BaseColor.WHITE)); titleParagraph.add(revisionChunk); } final PdfPCell head = new PdfPCell(); head.setColspan(2); head.setBorder(1); head.setPaddingTop(0); head.setPaddingBottom(3); head.setBackgroundColor(new BaseColor(64, 64, 64)); head.setVerticalAlignment(Element.ALIGN_TOP); head.addElement(titleParagraph); // Cells for score field, and 2nd check initials final Phrase des = new Phrase("Data Entry Score _______", ARIAL_8PT_NORMAL); final PdfPCell desC = new PdfPCell(des); desC.setBorder(0); desC.setPaddingTop(9); desC.setPaddingRight(36); desC.setHorizontalAlignment(Element.ALIGN_RIGHT); final Phrase sci = new Phrase("2nd Check Initials _______", ARIAL_8PT_NORMAL); final PdfPCell sciC = new PdfPCell(sci); sciC.setBorder(0); sciC.setPaddingTop(9); sciC.setPaddingRight(36); sciC.setHorizontalAlignment(Element.ALIGN_RIGHT); // Create a table with a grid cell for each scoresheet on the page PdfPTable wholePage = getTableForPage(orientationIsPortrait); wholePage.setWidthPercentage(100); for (int i = 0; i < m_numSheets; i++) { if (i > 0 && (orientationIsPortrait || (i % 2) == 0)) { pdfDoc.newPage(); wholePage = getTableForPage(orientationIsPortrait); wholePage.setWidthPercentage(100); } // This table is a single score sheet final PdfPTable scoreSheet = new PdfPTable(2); // scoreSheet.getDefaultCell().setBorder(Rectangle.LEFT | Rectangle.BOTTOM // | Rectangle.RIGHT | Rectangle.TOP); //FIXME DEBUG should be NO_BORDER scoreSheet.getDefaultCell().setBorder(Rectangle.NO_BORDER); scoreSheet.getDefaultCell().setPaddingRight(1); scoreSheet.getDefaultCell().setPaddingLeft(0); scoreSheet.addCell(head); final PdfPTable teamInfo = new PdfPTable(7); teamInfo.setWidthPercentage(100); teamInfo.setWidths(new float[] { 1f, 1f, 1f, 1f, 1f, 1f, .9f }); // Time label cell final Paragraph timeP = new Paragraph("Time:", ARIAL_10PT_NORMAL); timeP.setAlignment(Element.ALIGN_RIGHT); final PdfPCell timeLc = new PdfPCell(scoreSheet.getDefaultCell()); timeLc.addElement(timeP); teamInfo.addCell(timeLc); // Time value cell final Paragraph timeV = new Paragraph(null == m_time[i] ? SHORT_BLANK : m_time[i], COURIER_10PT_NORMAL); final PdfPCell timeVc = new PdfPCell(scoreSheet.getDefaultCell()); timeVc.addElement(timeV); teamInfo.addCell(timeVc); // Table label cell final Paragraph tblP = new Paragraph("Table:", ARIAL_10PT_NORMAL); tblP.setAlignment(Element.ALIGN_RIGHT); final PdfPCell tblLc = new PdfPCell(scoreSheet.getDefaultCell()); tblLc.addElement(tblP); teamInfo.addCell(tblLc); // Table value cell final Paragraph tblV = new Paragraph(m_table[i], COURIER_10PT_NORMAL); final PdfPCell tblVc = new PdfPCell(scoreSheet.getDefaultCell()); tblVc.addElement(tblV); teamInfo.addCell(tblVc); // Round number label cell final Paragraph rndP = new Paragraph("Round:", ARIAL_10PT_NORMAL); rndP.setAlignment(Element.ALIGN_RIGHT); final PdfPCell rndlc = new PdfPCell(scoreSheet.getDefaultCell()); rndlc.addElement(rndP); teamInfo.addCell(rndlc); // Round number value cell final Paragraph rndV = new Paragraph(m_round[i], COURIER_10PT_NORMAL); final PdfPCell rndVc = new PdfPCell(scoreSheet.getDefaultCell()); // rndVc.setColspan(2); rndVc.addElement(rndV); teamInfo.addCell(rndVc); final PdfPCell temp1 = new PdfPCell(scoreSheet.getDefaultCell()); // temp1.setColspan(2); temp1.addElement(new Paragraph("Judge ____", ARIAL_8PT_NORMAL)); teamInfo.addCell(temp1); // Team number label cell final Paragraph nbrP = new Paragraph("Team #:", ARIAL_10PT_NORMAL); nbrP.setAlignment(Element.ALIGN_RIGHT); final PdfPCell nbrlc = new PdfPCell(scoreSheet.getDefaultCell()); nbrlc.addElement(nbrP); teamInfo.addCell(nbrlc); // Team number value cell final Paragraph nbrV = new Paragraph(null == m_number[i] ? SHORT_BLANK : String.valueOf(m_number[i]), COURIER_10PT_NORMAL); final PdfPCell nbrVc = new PdfPCell(scoreSheet.getDefaultCell()); nbrVc.addElement(nbrV); teamInfo.addCell(nbrVc); // Team division label cell final Paragraph divP = new Paragraph(m_divisionLabel[i], ARIAL_10PT_NORMAL); divP.setAlignment(Element.ALIGN_RIGHT); final PdfPCell divlc = new PdfPCell(scoreSheet.getDefaultCell()); divlc.addElement(divP); divlc.setColspan(2); teamInfo.addCell(divlc); // Team division value cell final Paragraph divV = new Paragraph(m_division[i], COURIER_10PT_NORMAL); final PdfPCell divVc = new PdfPCell(scoreSheet.getDefaultCell()); divVc.setColspan(2); divVc.addElement(divV); teamInfo.addCell(divVc); final PdfPCell temp2 = new PdfPCell(scoreSheet.getDefaultCell()); // temp2.setColspan(2); temp2.addElement(new Paragraph("Team ____", ARIAL_8PT_NORMAL)); teamInfo.addCell(temp2); // Team name label cell final Paragraph nameP = new Paragraph("Team Name:", ARIAL_10PT_NORMAL); nameP.setAlignment(Element.ALIGN_RIGHT); final PdfPCell namelc = new PdfPCell(scoreSheet.getDefaultCell()); namelc.setColspan(2); namelc.addElement(nameP); teamInfo.addCell(namelc); // Team name value cell final Paragraph nameV = new Paragraph(m_name[i], COURIER_10PT_NORMAL); final PdfPCell nameVc = new PdfPCell(scoreSheet.getDefaultCell()); nameVc.setColspan(5); nameVc.addElement(nameV); teamInfo.addCell(nameVc); // add team info cell to the team table final PdfPCell teamInfoCell = new PdfPCell(scoreSheet.getDefaultCell()); teamInfoCell.addElement(teamInfo); teamInfoCell.setColspan(2); scoreSheet.addCell(teamInfoCell); if (null != m_goalsTable) { final PdfPCell goalCell = new PdfPCell(m_goalsTable); goalCell.setBorder(0); goalCell.setPadding(0); goalCell.setColspan(2); scoreSheet.addCell(goalCell); } scoreSheet.addCell(desC); scoreSheet.addCell(sciC); if (null != m_copyright) { final Phrase copyright = new Phrase("\u00A9" + m_copyright, f6i); final PdfPCell copyrightC = new PdfPCell(scoreSheet.getDefaultCell()); copyrightC.addElement(copyright); copyrightC.setBorder(0); copyrightC.setHorizontalAlignment(Element.ALIGN_CENTER); copyrightC.setColspan(2); scoreSheet.addCell(copyrightC); } // the cell in the whole page table that will contain the single score // sheet final PdfPCell scoresheetCell = new PdfPCell(scoreSheet); scoresheetCell.setBorder(0); scoresheetCell.setPadding(0); // Interior borders between scoresheets on a page if (!orientationIsPortrait) { if (i % 2 == 0) { scoresheetCell.setPaddingRight(0.1f * POINTS_PER_INCH); } else { scoresheetCell.setPaddingLeft(0.1f * POINTS_PER_INCH); } } // Add the current scoresheet to the page wholePage.addCell(scoresheetCell); // Add the current table of scoresheets to the document if (orientationIsPortrait || (i % 2 != 0)) { pdfDoc.add(wholePage); } } // Add a blank cells to complete the table of the last page if (!orientationIsPortrait && m_numSheets % 2 != 0) { final PdfPCell blank = new PdfPCell(); blank.setBorder(0); wholePage.addCell(blank); pdfDoc.add(wholePage); } pdfDoc.close(); }
From source file:fll.web.playoff.ScoresheetGenerator.java
License:Open Source License
/** * Stores the goal cells that are inserted into the output after the team name * headers and before the scoring/initials blanks at the bottom of the * scoresheet./*w w w . ja va 2 s . c o m*/ */ private void setChallengeInfo(final ChallengeDescription description) { setPageTitle(description.getTitle()); if (null != description.getRevision()) { setRevisionInfo(description.getRevision()); } if (null != description.getCopyright()) { m_copyright = description.getCopyright(); } else { m_copyright = null; } final PerformanceScoreCategory performanceElement = description.getPerformance(); // use ArrayList as we will be doing indexed access in the loop final List<AbstractGoal> goals = new ArrayList<>(performanceElement.getGoals()); final float[] relativeWidths = new float[3]; relativeWidths[0] = 4; relativeWidths[1] = 48; relativeWidths[2] = 48; m_goalsTable = new PdfPTable(relativeWidths); String prevCategory = null; for (int goalIndex = 0; goalIndex < goals.size(); ++goalIndex) { final AbstractGoal goal = goals.get(goalIndex); if (!goal.isComputed()) { final String category = goal.getCategory(); // add category cell if needed boolean firstRowInCategory = false; if (!StringUtils.equals(prevCategory, category)) { if (!StringUtils.isEmpty(category)) { // find out how many future goals have the same category int categoryRowSpan = 1; for (int otherIndex = goalIndex + 1; otherIndex < goals.size(); ++otherIndex) { final AbstractGoal otherGoal = goals.get(otherIndex); if (!otherGoal.isComputed()) { if (StringUtils.equals(category, otherGoal.getCategory())) { ++categoryRowSpan; } else { break; } } } final Paragraph catPara = new Paragraph(category, ARIAL_10PT_NORMAL); final PdfPCell categoryCell = new PdfPCell(catPara); categoryCell.setBorderWidthTop(1); categoryCell.setBorderWidthBottom(0); categoryCell.setBorderWidthLeft(0); categoryCell.setBorderWidthRight(0); categoryCell.setVerticalAlignment(Element.ALIGN_CENTER); categoryCell.setHorizontalAlignment(Element.ALIGN_CENTER); categoryCell.setRotation(90); categoryCell.setRowspan(categoryRowSpan); m_goalsTable.addCell(categoryCell); } // first row in a new category, which may be empty firstRowInCategory = true; } // This is the text for the left hand "label" cell final String title = goal.getTitle(); final Paragraph p = new Paragraph(title, ARIAL_10PT_NORMAL); final PdfPCell goalLabel = new PdfPCell(p); goalLabel.setHorizontalAlignment(Element.ALIGN_RIGHT); goalLabel.setVerticalAlignment(Element.ALIGN_CENTER); if (firstRowInCategory) { goalLabel.setBorderWidthTop(1); goalLabel.setBorderWidthBottom(0); goalLabel.setBorderWidthLeft(0); goalLabel.setBorderWidthRight(0); } else { goalLabel.setBorder(0); } goalLabel.setPaddingRight(9); goalLabel.setVerticalAlignment(Element.ALIGN_TOP); if (StringUtils.isEmpty(category)) { // category column and goal label column goalLabel.setColspan(2); } m_goalsTable.addCell(goalLabel); // define the value cell final double min = goal.getMin(); final String minStr = FP.equals(min, Math.round(min), 1E-6) ? String.valueOf((int) min) : String.valueOf(min); final double max = goal.getMax(); final String maxStr = FP.equals(max, Math.round(max), 1E-6) ? String.valueOf((int) max) : String.valueOf(max); // If element has child nodes, then we have an enumerated list // of choices. Otherwise it is either yes/no or a numeric field. final PdfPCell goalValue = new PdfPCell(); final Chunk choices = new Chunk("", COURIER_10PT_NORMAL); if (goal.isEnumerated()) { // replace spaces with "no-break" spaces boolean first = true; final List<EnumeratedValue> values = goal.getSortedValues(); for (final EnumeratedValue value : values) { if (!first) { choices.append(" /" + Utilities.NON_BREAKING_SPACE); } else { first = false; } choices.append(value.getTitle().toUpperCase().replace(' ', Utilities.NON_BREAKING_SPACE)); } goalValue.addElement(choices); } else { if (goal.isYesNo()) { // order of yes/no needs to match ScoreEntry.generateYesNoButtons final Paragraph q = new Paragraph("NO / YES", COURIER_10PT_NORMAL); goalValue.addElement(q); } else { final String range = "(" + minStr + " - " + maxStr + ")"; final PdfPTable t = new PdfPTable(2); t.setHorizontalAlignment(Element.ALIGN_LEFT); t.setTotalWidth(1 * POINTS_PER_INCH); t.setLockedWidth(true); final Phrase r = new Phrase("", ARIAL_8PT_NORMAL); t.addCell(new PdfPCell(r)); final Phrase q = new Phrase(range, ARIAL_8PT_NORMAL); t.addCell(new PdfPCell(q)); goalValue.setPaddingTop(9); goalValue.addElement(t); } } if (firstRowInCategory) { goalValue.setBorderWidthTop(1); goalValue.setBorderWidthBottom(0); goalValue.setBorderWidthLeft(0); goalValue.setBorderWidthRight(0); } else { goalValue.setBorder(0); } goalValue.setVerticalAlignment(Element.ALIGN_MIDDLE); m_goalsTable.addCell(goalValue); // setup for next loop prevCategory = category; } // if not computed goal } // foreach goal }
From source file:Functions.pdf_Export.java
public void createHeader(Document doc, Integer soHoaDon) { try {/*from w w w . jav a2s. c o m*/ PdfPTable table = new PdfPTable(new float[] { 80, 20 }); table.setWidthPercentage(100); LinkedHashMap<String, Font> lines = new LinkedHashMap<>(); lines.put("Shop Name: " + shopName, titleFont); lines.put("Address: " + address, smallFont); lines.put("Phone Number: " + phoneNumb, smallFont); lines.put("Website: " + web, smallFont); lines.put("Email: " + email, smallFont); // left cell with shop's infor PdfPCell leftCell = new PdfPCell(); leftCell.setPaddingTop(-7); leftCell.setPaddingRight(35); Set<String> singleLine = lines.keySet(); // this below loop to create a line with text, and set it's font for (String line : singleLine) { leftCell.addElement(new Phrase(line, lines.get(line))); } leftCell.setHorizontalAlignment(Element.ALIGN_LEFT); leftCell.setBorder(PdfPCell.NO_BORDER); table.addCell(leftCell); // right cell with bill's time String time = new HoaDonDAO().getHoaDon(soHoaDon).getNgayLapHoaDon().toString(); PdfPCell rightCell = new PdfPCell(); rightCell.setHorizontalAlignment(PdfPCell.ALIGN_RIGHT); rightCell.addElement(new Phrase("Date: " + time + "\nNo.: " + soHoaDon, smallFont)); rightCell.setBorder(PdfPCell.NO_BORDER); table.addCell(rightCell); doc.add(table); } catch (DocumentException ex) { Logger.getLogger(pdf_Export.class.getName()).log(Level.SEVERE, null, ex); } }