Example usage for com.itextpdf.text.pdf PdfPCell setColspan

List of usage examples for com.itextpdf.text.pdf PdfPCell setColspan

Introduction

In this page you can find the example usage for com.itextpdf.text.pdf PdfPCell setColspan.

Prototype

public void setColspan(int colspan) 

Source Link

Document

Setter for property colspan.

Usage

From source file:Export.DocNotaCredito.java

@SuppressWarnings("CallToPrintStackTrace")
private void docSeguros(String nomeSeguro, String interCod, String user, String arquivo, int idResseguro,
        TypeNotaCredito tnc) {/*w  w w.j ava2 s  . c o  m*/
    String reString;
    try {

        Font fontCabecalhoN = FontFactory.getFont(Fontes.FONTB, BaseFont.WINANSI, BaseFont.EMBEDDED, 9.2f);
        Font fontLinha = FontFactory.getFont(Fontes.FONTB, BaseFont.WINANSI, BaseFont.EMBEDDED, 0.000000358f);
        Font fontCabecalhoS = FontFactory.getFont(Fontes.FONT, BaseFont.WINANSI, BaseFont.EMBEDDED, 9.2f);
        Font fontCorpo = FontFactory.getFont(Fontes.FONT, BaseFont.WINANSI, BaseFont.EMBEDDED, 8f);
        Font fontCorpoN = FontFactory.getFont(Fontes.FONTB, BaseFont.WINANSI, BaseFont.EMBEDDED, 8f);
        Font fontNull = FontFactory.getFont(Fontes.FONT, BaseFont.WINANSI, BaseFont.EMBEDDED, 4f);
        Font fontMenor = FontFactory.getFont(Fontes.FONT, BaseFont.WINANSI, BaseFont.EMBEDDED, 3f);

        PdfPTable pTableEmpresaPricipal = new PdfPTable(new float[] { 80, 20 });
        pTableEmpresaPricipal.setWidthPercentage(95);
        PdfPTable pTableEmpresaInforImpres1 = new PdfPTable(1);
        PdfPTable pTableEmpresaInforImpres2 = new PdfPTable(1);
        PdfPTable pTableEmpresaInforImpres3 = new PdfPTable(2);
        PdfPTable pTableEmpresaInforImpres4 = new PdfPTable(2);
        PdfPTable pTableEmpresaInforImpres5 = new PdfPTable(1);

        DataResseguro resS = new DataResseguro();
        HashMap<String, Object> map = new LinkedHashMap<>();
        if (tnc == TypeNotaCredito.RESEGURO) {
            resS = DataReseguro.getDadosReseguro(idResseguro);
        } else {
            map = loadNotaConta();
        }

        PdfPTable pTableFatura = new PdfPTable(new float[] { 80, 20 });

        PdfPCell pCellNomeEmpresa = new PdfPCell(new Phrase(Empresa.NOME, fontCabecalhoN));
        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 pCellCapital = new PdfPCell(new Phrase(Empresa.CAPITALSOCIAL, fontCabecalhoN));
        pCellCapital.setBorder(0);

        PdfPCell pCellPolice = new PdfPCell(new Phrase(
                Empresa.APOLICE + ((TypeNotaCredito.RESEGURO == tnc) ? resS.getAPOLICE() : map.get(APOLICE)),
                fontCabecalhoN));
        pCellPolice.setBorder(0);

        PdfPCell pCellDebNF = new PdfPCell(new Phrase("Cre. N", fontCabecalhoS));
        pCellDebNF.setHorizontalAlignment(Element.ALIGN_RIGHT);
        pCellDebNF.setBorder(0);

        PdfPCell pCellDebN = new PdfPCell(new Phrase(
                ((TypeNotaCredito.RESEGURO == tnc) ? resS.getIDSEGURO() : map.get(ID) + ""), fontCabecalhoS));
        pCellDebN.setHorizontalAlignment(Element.ALIGN_CENTER);
        pCellDebN.setBorder(0);

        PdfPCell pCellInterCoF = new PdfPCell(new Phrase("Inter COD:", fontCabecalhoS));
        pCellInterCoF.setHorizontalAlignment(Element.ALIGN_RIGHT);
        pCellInterCoF.setBorder(0);

        PdfPCell pCellInterCo = new PdfPCell(new Phrase(interCod, fontCabecalhoS));
        pCellInterCo.setHorizontalAlignment(Element.ALIGN_CENTER);
        pCellInterCo.setBorder(0);

        Image imageEmpresa = Image.getInstance("logo.png");
        imageEmpresa.scaleToFit(120f, 100f);

        pTableEmpresaInforImpres1.addCell(pCellNomeEmpresa);
        pTableEmpresaInforImpres1.addCell(pCellNomeEndereco);
        pTableEmpresaInforImpres1.addCell(pCellCaixaPostal);
        pTableEmpresaInforImpres1.addCell(pCellTeleFax);
        pTableEmpresaInforImpres1.addCell(pCellSociedade);

        pTableEmpresaInforImpres2.addCell(pCellCapital);
        pTableEmpresaInforImpres2.addCell(pCellPolice);

        pTableEmpresaInforImpres3.addCell(pCellDebNF);
        pTableEmpresaInforImpres3.addCell(pCellDebN);
        pTableEmpresaInforImpres3.addCell(pCellInterCoF);
        pTableEmpresaInforImpres3.addCell(pCellInterCo);

        PdfPCell cellTabela1 = new PdfPCell(pTableEmpresaInforImpres2);
        cellTabela1.setBorder(0);

        pTableEmpresaInforImpres4.addCell(cellTabela1);

        PdfPCell cellTabela2 = new PdfPCell(pTableEmpresaInforImpres3);
        cellTabela2.setBorder(0);

        pTableEmpresaInforImpres4.addCell(cellTabela2);

        PdfPCell cellTabela3 = new PdfPCell(pTableEmpresaInforImpres1);
        cellTabela3.setBorder(0);

        pTableEmpresaInforImpres5.addCell(cellTabela3);

        PdfPCell cellTabela4 = new PdfPCell(pTableEmpresaInforImpres4);
        cellTabela4.setBorder(0);

        pTableEmpresaInforImpres5.addCell(cellTabela4);

        PdfPCell cellTabela5 = new PdfPCell(pTableEmpresaInforImpres5);
        cellTabela5.setBorder(0);

        pTableEmpresaPricipal.addCell(cellTabela5);

        PdfPCell cellTabela6 = new PdfPCell(imageEmpresa);
        cellTabela6.setBorder(0);
        cellTabela6.setHorizontalAlignment(Element.ALIGN_RIGHT);

        pTableEmpresaPricipal.addCell(cellTabela6);

        //
        PdfPTable pTableLinha = new PdfPTable(1);
        pTableLinha.setWidthPercentage(95);
        PdfPCell linha = new PdfPCell(new Phrase(" ", fontLinha));
        linha.setBorderWidthTop(0.5f);
        linha.setBorderWidthBottom(0);
        linha.setBorderWidthLeft(0);
        linha.setBorderWidthRight(0);
        pTableLinha.addCell(linha);

        PdfPTable pTableCorpoEndTitile = new PdfPTable(new float[] { 100 });
        pTableCorpoEndTitile.setWidthPercentage(95);
        PdfPCell cellCorpoEndTitile = new PdfPCell();
        Paragraph paragraphCorpoEndTitile = new Paragraph();

        Paragraph titile = new Paragraph("NOTA DE CREDITO", fontCabecalhoN);
        titile.setAlignment(Paragraph.ALIGN_CENTER);

        PdfPTable pTableNumNota = new PdfPTable(new float[] { 100f });

        Paragraph titileSub = new Paragraph(nomeSeguro, fontCabecalhoN);
        titileSub.setAlignment(Paragraph.ALIGN_CENTER);
        paragraphCorpoEndTitile.add(titile);

        if (tnc == TypeNotaCredito.ANULACAO) {
            PdfPCell titileNum = new PdfPCell(new Paragraph("Deb. N " + map.get(NOTADEBITO), fontCabecalhoN));
            titileNum.setBorder(PdfPCell.NO_BORDER);
            titileNum.setHorizontalAlignment(PdfPCell.ALIGN_RIGHT);

            pTableNumNota.addCell(titileNum);
            paragraphCorpoEndTitile.add(pTableNumNota);
        }

        paragraphCorpoEndTitile.add(titileSub);

        paragraphCorpoEndTitile.add(new Paragraph(" ", fontCorpo));
        paragraphCorpoEndTitile.add(new Paragraph(" ", fontCorpo));

        ArrayList<DataReseguro.DataEmpresa> listaDataEmpresas = new ArrayList<>();

        ClienteI ci = null;
        if (tnc == TypeNotaCredito.RESEGURO) {
            listaDataEmpresas = DataReseguro.getDadosEmpresa(idResseguro);
        } else {
            ci = new ClienteI(map.get(IDCLIENTE) + "");
        }

        Phrase pCr = new Phrase("BENEFICI?RIO: ", fontCabecalhoN);
        paragraphCorpoEndTitile.add(pCr);
        @SuppressWarnings("null")
        Phrase pCrTex = new Phrase(
                ((tnc == TypeNotaCredito.RESEGURO) ? resS.getCLIENTE() : map.get(BENEFICIARIO) + "\n"),
                fontCabecalhoS);
        paragraphCorpoEndTitile.add(pCrTex);

        Phrase pEndereco = new Phrase("Endereo: ".toUpperCase(), fontCabecalhoN);
        paragraphCorpoEndTitile.add(pEndereco);
        Phrase pEnderecoTex = new Phrase(
                ((tnc == TypeNotaCredito.RESEGURO) ? ConfigDoc.Empresa.ENDERECO : ci.getENDERECO_()) + "\n",
                fontCabecalhoS);
        paragraphCorpoEndTitile.add(pEnderecoTex);

        Phrase pPolice = new Phrase("Apolice: ".toUpperCase(), fontCabecalhoN);
        paragraphCorpoEndTitile.add(pPolice);
        Phrase pPoliceTex = new Phrase(
                ((tnc == TypeNotaCredito.RESEGURO) ? resS.getAPOLICE() : map.get(APOLICE)) + "\n",
                fontCabecalhoS);
        paragraphCorpoEndTitile.add(pPoliceTex);

        //                Phrase pInterCod = new Phrase("intermediry Code".toUpperCase(), fontCabecalhoN);
        //                paragraphCorpoEndTitile.add(pInterCod);
        //                Phrase pInterCodTex = new Phrase(/*SessionUtil.getUserlogado().getResidencia()*/"In ----\n", fontCabecalhoS);
        //                paragraphCorpoEndTitile.add(pInterCodTex);

        Phrase pDate = new Phrase("DATA: ".toUpperCase(), fontCabecalhoN);
        paragraphCorpoEndTitile.add(pDate);
        Phrase pDateTex = new Phrase(((TypeNotaCredito.ANULACAO != tnc) ? resS.getINICIO() + " " + resS.getFIM()
                : map.get(DATAINICIO) + " " + map.get(DATAFIM)) + "\n", fontCabecalhoS);
        paragraphCorpoEndTitile.add(pDateTex);

        Phrase pSegurado = new Phrase("Segurado: ".toUpperCase(), fontCabecalhoN);
        paragraphCorpoEndTitile.add(pSegurado);
        Phrase pSeguradoTex = new Phrase(
                ((tnc == TypeNotaCredito.RESEGURO) ? ConfigDoc.Empresa.NOME + "(" + resS.getCLIENTE() + ")"
                        : ci.getNOME_()),
                fontCabecalhoS);
        paragraphCorpoEndTitile.add(pSeguradoTex);

        paragraphCorpoEndTitile.add(new Paragraph(" ", fontCorpo));
        paragraphCorpoEndTitile.add(new Paragraph(" ", fontCorpo));

        //Tabela Principal
        PdfPTable pTableNotaCredito = new PdfPTable(new float[] { 21.5f, 21.5f, 22f, 27f, 7f });
        //            PdfPTable pTableNotaCreditos = new PdfPTable(new float[]{70f, 30f});
        pTableNotaCredito.setWidthPercentage(100f);
        //            pTableNotaCreditos.setWidthPercentage(100f);

        PdfPCell cellParticular = new PdfPCell(new Phrase("Particular".toUpperCase(), fontCorpoN));
        cellParticular.setBorderWidth(1);
        pTableNotaCredito.addCell(cellParticular);

        PdfPCell cellPremioGrosso = new PdfPCell(new Phrase("Prmio Grosso".toUpperCase(), fontCorpoN));
        cellPremioGrosso.setBorderWidth(1);
        pTableNotaCredito.addCell(cellPremioGrosso);

        PdfPCell cellComissaoDedutivel = new PdfPCell(
                new Phrase("Comisso Dedutvel".toUpperCase(), fontCorpoN));
        cellComissaoDedutivel.setBorderWidth(1);
        pTableNotaCredito.addCell(cellComissaoDedutivel);

        PdfPCell cellValorLiquidoD = new PdfPCell(new Phrase("Valor Liqudo Devido", fontCorpoN));
        cellValorLiquidoD.setBorderWidth(1);
        cellValorLiquidoD.setBorderWidthRight(0);
        pTableNotaCredito.addCell(cellValorLiquidoD);

        PdfPCell cellNull = new PdfPCell(new Phrase(" ", fontCorpoN));
        PdfPCell cellNull1 = new PdfPCell(new Phrase("(NET)", fontCorpoN));
        cellNull.setBorder(0);

        cellNull1.setBorderWidthTop(1);
        cellNull1.setBorderWidthRight(1);
        cellNull1.setBorderWidthLeft(0);
        cellNull1.setBorderWidthBottom(1);
        cellNull1.setHorizontalAlignment(PdfPCell.ALIGN_RIGHT);

        pTableNotaCredito.addCell(cellNull1);

        cellParticular = new PdfPCell(
                new Phrase(((TypeNotaCredito.RESEGURO == tnc) ? resS.getDESCRICAO().toUpperCase()
                        : map.get(DESCRICAO) + ""), fontCorpo));
        cellParticular.setBorderWidth(1);
        pTableNotaCredito.addCell(cellParticular);

        cellPremioGrosso = new PdfPCell(new Phrase(
                ((TypeNotaCredito.RESEGURO == tnc) ? Moeda.format(Double.valueOf(resS.getPREMIOGROSSO()))
                        : Moeda.format(Double.valueOf(map.get(PREMIOGROSSO) + ""))),
                fontCorpo));
        cellPremioGrosso.setBorderWidth(1);
        cellPremioGrosso.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
        cellPremioGrosso.setPaddingTop(30f);
        pTableNotaCredito.addCell(cellPremioGrosso);

        cellComissaoDedutivel = new PdfPCell(new Phrase(
                ((TypeNotaCredito.RESEGURO == tnc) ? resS.getDEDUCAO() + "%" : map.get(DECUCAO) + "%"),
                fontCorpo));
        cellComissaoDedutivel.setBorderWidth(1);
        cellComissaoDedutivel.setPaddingTop(30f);
        cellComissaoDedutivel.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
        pTableNotaCredito.addCell(cellComissaoDedutivel);

        cellValorLiquidoD = new PdfPCell(new Phrase(
                Moeda.format(Double
                        .valueOf(((TypeNotaCredito.RESEGURO == tnc) ? resS.getTOTAL() : map.get(TOTAL) + ""))),
                fontCorpo));
        cellValorLiquidoD.setBorderWidth(1);
        cellValorLiquidoD.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
        cellValorLiquidoD.setPaddingTop(30f);
        cellValorLiquidoD.setPaddingBottom(75f);
        pTableNotaCredito.addCell(cellValorLiquidoD);

        pTableNotaCredito.addCell(cellNull);

        PdfPCell cellTotalDebito = new PdfPCell(new Phrase("TOTAL ", fontCorpoN));
        cellTotalDebito.setBorder(PdfPCell.NO_BORDER);
        cellTotalDebito.setColspan(3);
        pTableNotaCredito.addCell(cellTotalDebito);

        PdfPCell cellTotalDebitoV = new PdfPCell(new Phrase(
                Moeda.format(Double
                        .valueOf(((TypeNotaCredito.RESEGURO == tnc) ? resS.getTOTAL() : map.get(TOTAL) + ""))),
                fontCorpo));
        cellTotalDebitoV.setBorderWidth(1);
        cellTotalDebitoV.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
        pTableNotaCredito.addCell(cellTotalDebitoV);

        pTableNotaCredito.addCell(cellNull);

        double cambio;
        double totalSTD = 0;
        if (!((TypeNotaCredito.RESEGURO == tnc) ? resS.getMOEDA() : map.get(SIGLADAMOEDA)).equals("STD")) {
            PdfPCell cellCambio = new PdfPCell(new Phrase(
                    "CAMBIO " + ((TypeNotaCredito.RESEGURO == tnc) ? resS.getMOEDA() : map.get(SIGLADAMOEDA)),
                    fontCorpoN));
            cellCambio.setBorder(PdfPCell.NO_BORDER);
            cellCambio.setColspan(3);
            pTableNotaCredito.addCell(cellCambio);

            cambio = valorCompra(
                    ((TypeNotaCredito.RESEGURO == tnc) ? resS.getMOEDA() : map.get(SIGLADAMOEDA) + ""),
                    ((TypeNotaCredito.RESEGURO == tnc) ? new Date() : map.get(CTT_DTREG)));

            PdfPCell cellCambioV = new PdfPCell(new Phrase(Moeda.format(cambio), fontCorpo));
            cellCambioV.setBorderWidth(1);
            cellCambioV.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
            pTableNotaCredito.addCell(cellCambioV);

            pTableNotaCredito.addCell(cellNull);

            PdfPCell cellValorDobras = new PdfPCell(new Phrase("VALOR EM DOBRAS", fontCorpoN));
            cellValorDobras.setBorder(PdfPCell.NO_BORDER);
            cellValorDobras.setColspan(3);
            pTableNotaCredito.addCell(cellValorDobras);

            totalSTD = cambio
                    * Double.valueOf((TypeNotaCredito.RESEGURO == tnc) ? resS.getTOTAL() : map.get(TOTAL) + "");
            PdfPCell cellValorDobrasV = new PdfPCell(new Phrase(Moeda.format(totalSTD), fontCorpo));
            cellValorDobrasV.setBorderWidth(1);
            cellValorDobrasV.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
            pTableNotaCredito.addCell(cellValorDobrasV);

            pTableNotaCredito.addCell(cellNull);
        }

        paragraphCorpoEndTitile.add(pTableNotaCredito);
        JTextPane jtp = new JTextPane();
        Moeda.EscreverEstenso(totalSTD, jtp, "Dobras");
        paragraphCorpoEndTitile.add(new Phrase("POR EXTENSO: ", fontCorpoN));
        paragraphCorpoEndTitile.add(new Phrase(jtp.getText().toUpperCase().trim() + "\n", fontCorpo));

        paragraphCorpoEndTitile.add(new Paragraph(" ", fontCorpoN));
        paragraphCorpoEndTitile.add(new Paragraph(" ", fontCorpoN));

        paragraphCorpoEndTitile.add(new Phrase("NOTA: ZERO PRMIO, ZERO COBERTURA", fontCorpoN));

        paragraphCorpoEndTitile.add(new Paragraph(" ", fontCorpoN));
        paragraphCorpoEndTitile.add(new Paragraph(" ", fontCorpoN));

        PdfPTable pTableRodape = new PdfPTable(new float[] { 33.333333333f, 33.333333333f, 33.333333333f });
        pTableRodape.setWidthPercentage(100.0f);

        PdfPCell cellRodapeData = new PdfPCell(
                new Phrase(".......................................................", fontCorpo));
        cellRodapeData.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
        cellRodapeData.setBorder(PdfPCell.NO_BORDER);
        pTableRodape.addCell(cellRodapeData);

        PdfPCell cellRodapeVerificado = new PdfPCell(
                new Phrase(".......................................................", fontCorpoN));
        cellRodapeVerificado.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
        cellRodapeVerificado.setBorder(PdfPCell.NO_BORDER);
        pTableRodape.addCell(cellRodapeVerificado);

        PdfPCell cellAssinatura = new PdfPCell(
                new Phrase(".......................................................", fontCorpo));
        cellAssinatura.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
        cellAssinatura.setBorder(PdfPCell.NO_BORDER);
        pTableRodape.addCell(cellAssinatura);

        cellRodapeData = new PdfPCell(new Phrase(" ", fontCorpo));
        cellRodapeData.setBorder(PdfPCell.NO_BORDER);
        pTableRodape.addCell(cellRodapeData);

        cellRodapeVerificado = new PdfPCell(new Phrase("VERIFICADO POR", fontCorpoN));
        cellRodapeVerificado.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
        cellRodapeVerificado.setBorder(PdfPCell.NO_BORDER);
        pTableRodape.addCell(cellRodapeVerificado);

        cellAssinatura = new PdfPCell(new Phrase("ASSINATURA", fontCorpo));
        cellAssinatura.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
        cellAssinatura.setBorder(PdfPCell.NO_BORDER);
        pTableRodape.addCell(cellAssinatura);

        paragraphCorpoEndTitile.add(pTableRodape);

        cellCorpoEndTitile.addElement(paragraphCorpoEndTitile);

        cellCorpoEndTitile.setBorder(PdfPCell.NO_BORDER);

        pTableCorpoEndTitile.addCell(cellCorpoEndTitile);

        SimpleDateFormat sdf1 = new SimpleDateFormat("dd-MM-yyyy hh'.'mm'.'ss");

        Document documento = new Document();
        documento.setPageSize(PageSize.A4);
        documento.setMargins(20f, 20f, 70f, 5f);

        String f1 = (arquivo + "/" + interCod + "/Seguro " + nomeSeguro + "/");
        File f = new File(f1);
        String Ddata = sdf1.format(new Date());
        f.mkdirs();
        f = new File(f.getAbsoluteFile() + "/" + "Nota de Credito " + Ddata + ".pdf");

        reString = "../Documentos/" + interCod + "/Seguro " + nomeSeguro + "/" + "Nota de Credito " + Ddata
                + ".pdf";
        OutputStream outputStraem = new FileOutputStream(f);
        PdfWriter writer = PdfWriter.getInstance(documento, outputStraem);

        documento.open();
        documento.add(pTableEmpresaPricipal);
        documento.add(pTableLinha);
        documento.add(pTableLinha);
        documento.add(pTableCorpoEndTitile);
        documento.close();

        RequestContext.getCurrentInstance().execute("openAllDocument('" + reString + "')");
    } catch (FileNotFoundException | DocumentException e) {
        e.printStackTrace();
    } catch (IOException ex) {
        Logger.getLogger(DocNotaCredito.class.getName()).log(Level.SEVERE, null, ex);
    }

}

From source file:Export.DocOfReCoSeguro.java

public static void docSeguros(String nomeSeguro, String user, String arquivo, String numDebito, String tileDoc,
        int idReseguro, boolean isReseguroOfNICON) {
    String reString;//from w w  w . j a va 2 s.co m
    try {

        Font fontCabecalhoN = FontFactory.getFont(ConfigDoc.Fontes.FONTB, BaseFont.WINANSI, BaseFont.EMBEDDED,
                9.2f);
        Font fontLinha = FontFactory.getFont(ConfigDoc.Fontes.FONTB, BaseFont.WINANSI, BaseFont.EMBEDDED,
                0.000000358f);
        Font fontCabecalhoS = FontFactory.getFont(ConfigDoc.Fontes.FONT, BaseFont.WINANSI, BaseFont.EMBEDDED,
                9.2f);
        Font fontCorpo = FontFactory.getFont(ConfigDoc.Fontes.FONT, BaseFont.WINANSI, BaseFont.EMBEDDED, 8f);
        Font fontCorpoS = FontFactory.getFont(ConfigDoc.Fontes.FONT, BaseFont.WINANSI, BaseFont.EMBEDDED, 8f,
                Font.UNDERLINE);
        Font fontCorpoN = FontFactory.getFont(ConfigDoc.Fontes.FONTB, BaseFont.WINANSI, BaseFont.EMBEDDED, 8f);
        Font fontNull = FontFactory.getFont(ConfigDoc.Fontes.FONT, BaseFont.WINANSI, BaseFont.EMBEDDED, 4f);
        Font fontMenor = FontFactory.getFont(ConfigDoc.Fontes.FONT, BaseFont.WINANSI, BaseFont.EMBEDDED, 3f);

        DataResseguro reS = DataReseguro.getDadosReseguro(idReseguro);

        PdfPTable pTableEmpresaPricipal = new PdfPTable(new float[] { 80, 20 });
        pTableEmpresaPricipal.setWidthPercentage(90);
        PdfPTable pTableEmpresaInforImpres1 = new PdfPTable(1);
        PdfPTable pTableEmpresaInforImpres2 = new PdfPTable(1);
        PdfPTable pTableEmpresaInforImpres4 = new PdfPTable(1);
        PdfPTable pTableEmpresaInforImpres5 = new PdfPTable(1);

        PdfPTable pTableFatura = new PdfPTable(new float[] { 80, 20 });

        PdfPCell pCellNomeEmpresa = new PdfPCell(new Phrase(ConfigDoc.Empresa.NOME, fontCabecalhoN));
        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);

        PdfPCell pCellCapital = new PdfPCell(new Phrase(ConfigDoc.Empresa.CAPITALSOCIAL, fontCabecalhoN));
        pCellCapital.setBorder(0);

        PdfPCell pCellPolice = new PdfPCell(
                new Phrase(ConfigDoc.Empresa.APOLICE + reS.getAPOLICE(), fontCabecalhoN));
        pCellPolice.setBorder(0);

        Image imageEmpresa = Image.getInstance("logo.png");
        imageEmpresa.scaleToFit(120f, 100f);

        pTableEmpresaInforImpres1.addCell(pCellNomeEmpresa);
        pTableEmpresaInforImpres1.addCell(pCellNomeEndereco);
        pTableEmpresaInforImpres1.addCell(pCellCaixaPostal);
        pTableEmpresaInforImpres1.addCell(pCellTeleFax);
        pTableEmpresaInforImpres1.addCell(pCellSociedade);

        pTableEmpresaInforImpres2.addCell(pCellCapital);
        pTableEmpresaInforImpres2.addCell(pCellPolice);

        PdfPCell cellTabela1 = new PdfPCell(pTableEmpresaInforImpres2);
        cellTabela1.setBorder(0);

        pTableEmpresaInforImpres4.addCell(cellTabela1);

        PdfPCell cellTabela3 = new PdfPCell(pTableEmpresaInforImpres1);
        cellTabela3.setBorder(0);

        pTableEmpresaInforImpres5.addCell(cellTabela3);

        PdfPCell cellTabela4 = new PdfPCell(pTableEmpresaInforImpres4);
        cellTabela4.setBorder(0);

        pTableEmpresaInforImpres5.addCell(cellTabela4);

        PdfPCell cellTabela5 = new PdfPCell(pTableEmpresaInforImpres5);
        cellTabela5.setBorder(0);

        pTableEmpresaPricipal.addCell(cellTabela5);

        PdfPCell cellTabela6 = new PdfPCell(imageEmpresa);
        cellTabela6.setBorder(0);
        cellTabela6.setHorizontalAlignment(Element.ALIGN_RIGHT);

        pTableEmpresaPricipal.addCell(cellTabela6);

        PdfPTable pTableLinha = new PdfPTable(1);
        pTableLinha.setWidthPercentage(90);
        PdfPCell linha = new PdfPCell(new Phrase(" ", fontLinha));
        linha.setBorderWidthTop(0.5f);
        linha.setBorderWidthBottom(0);
        linha.setBorderWidthLeft(0);
        linha.setBorderWidthRight(0);
        pTableLinha.addCell(linha);

        /**
         * Tile Doc start
         */
        /*
        PdfPTable pTableTileDoc = new PdfPTable(new float[]{50, 50});
                
        PdfPCell cellTileDoc = new PdfPCell(new Phrase(tileDoc, fontCabecalhoS));
        cellTileDoc.setColspan(2);
        cellTileDoc.setPaddingTop(10f);
        cellTileDoc.setPaddingBottom(20f);
        cellTileDoc.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
        cellTileDoc.setBorder(PdfPCell.NO_BORDER);
        pTableTileDoc.addCell(cellTileDoc);
                
        Paragraph pTile = new Paragraph();
        pTile.add(new Phrase("DEBIT:  ", fontCorpoN));
        pTile.add(new Phrase("NiCON Seguros STP", fontCorpoN));
        PdfPCell cellDebit = new PdfPCell(pTile);
        cellDebit.setBorder(PdfPCell.NO_BORDER);
        pTableTileDoc.addCell(cellDebit);
                
        Paragraph pNotaNum = new Paragraph();
        pNotaNum.add(new Phrase("DEBIT NOTE NO: ", fontCorpoN));
        pNotaNum.add(new Phrase("05525", fontCorpo));
        cellDebit = new PdfPCell(pNotaNum);
        cellDebit.setPaddingLeft(20f);
        cellDebit.setBorder(PdfPCell.NO_BORDER);
        pTableTileDoc.addCell(cellDebit);
                
        cellDebit = new PdfPCell(new Phrase("             Avenida Marginal 12 de Junlho, 977", fontCorpo));
        cellDebit.setBorder(PdfPCell.NO_BORDER);
        pTableTileDoc.addCell(cellDebit);
                
        Paragraph pDate = new Paragraph();
        pDate.add(new Phrase("Date: ", fontCorpoN));
        SimpleDateFormat format = new SimpleDateFormat("dd MMMM',' yyyy",new Locale("pt", "BR"));
        pDate.add(new Phrase(format.format(new Date()), fontCorpo));
        cellDebit = new PdfPCell(pDate);
        cellDebit.setBorder(PdfPCell.NO_BORDER);
        cellDebit.setPaddingLeft(20f);
        pTableTileDoc.addCell(cellDebit);
                
        cellDebit = new PdfPCell(new Phrase("             Cx Postal 556-So Tom", fontCorpo));
        cellDebit.setBorder(PdfPCell.NO_BORDER);
        pTableTileDoc.addCell(cellDebit);
        cellDebit = new PdfPCell(new Phrase(" "));
        cellDebit.setBorder(PdfPCell.NO_BORDER);
        pTableTileDoc.addCell(cellDebit);
        */
        /**
         * Tile Doc end
         */

        ArrayList<DataEmpresa> listaDataEmpresas = DataReseguro.getDadosEmpresa(idReseguro);

        /**
         * Data Parte 1 Start
         */
        PdfPTable pTableDataPart1 = new PdfPTable(new float[] { 18f, 82f });
        pTableDataPart1.setWidthPercentage(90);

        PdfPCell cellDataPart1 = new PdfPCell(new Phrase("EMPRESA LIDER:", fontCorpoN));
        cellDataPart1.setBorder(PdfPCell.NO_BORDER);
        cellDataPart1.setPaddingTop(10f);
        cellDataPart1.setPaddingBottom(5f);
        pTableDataPart1.addCell(cellDataPart1);
        cellDataPart1 = new PdfPCell(
                new Phrase(((!isReseguroOfNICON) ? listaDataEmpresas.get(0).getEMPRESA().toUpperCase()
                        : ConfigDoc.Empresa.NOME), fontCorpo));
        cellDataPart1.setPaddingTop(10f);
        cellDataPart1.setPaddingBottom(5f);
        cellDataPart1.setBorder(PdfPCell.NO_BORDER);
        pTableDataPart1.addCell(cellDataPart1);

        cellDataPart1 = new PdfPCell(new Phrase("CONTRATO N:", fontCorpoN));
        cellDataPart1.setBorder(PdfPCell.NO_BORDER);
        cellDataPart1.setPaddingTop(5f);
        cellDataPart1.setPaddingBottom(5f);
        pTableDataPart1.addCell(cellDataPart1);
        cellDataPart1 = new PdfPCell(new Phrase(reS.getAPOLICE(), fontCorpo));
        cellDataPart1.setPaddingTop(5f);
        cellDataPart1.setPaddingBottom(5f);
        cellDataPart1.setBorder(PdfPCell.NO_BORDER);
        pTableDataPart1.addCell(cellDataPart1);

        cellDataPart1 = new PdfPCell(new Phrase("DESCRIO:", fontCorpoN));
        cellDataPart1.setPaddingTop(5f);
        cellDataPart1.setPaddingBottom(5f);
        cellDataPart1.setBorder(PdfPCell.NO_BORDER);
        pTableDataPart1.addCell(cellDataPart1);
        cellDataPart1 = new PdfPCell(new Phrase(reS.getDESCRICAO(), fontCorpo));
        cellDataPart1.setPaddingTop(5f);
        cellDataPart1.setPaddingBottom(5f);
        cellDataPart1.setBorder(PdfPCell.NO_BORDER);
        pTableDataPart1.addCell(cellDataPart1);

        cellDataPart1 = new PdfPCell(new Phrase("PERIODO:", fontCorpoN));
        cellDataPart1.setBorder(PdfPCell.NO_BORDER);
        cellDataPart1.setPaddingTop(5f);
        cellDataPart1.setPaddingBottom(5f);
        pTableDataPart1.addCell(cellDataPart1);
        cellDataPart1 = new PdfPCell(new Phrase(reS.getINICIO() + " - " + reS.getFIM(), fontCorpo));
        cellDataPart1.setBorder(PdfPCell.NO_BORDER);
        cellDataPart1.setPaddingTop(5f);
        cellDataPart1.setPaddingBottom(5f);
        pTableDataPart1.addCell(cellDataPart1);

        cellDataPart1 = new PdfPCell(new Phrase("LIMITE:", fontCorpoN));
        cellDataPart1.setBorder(PdfPCell.NO_BORDER);
        cellDataPart1.setPaddingTop(5f);
        cellDataPart1.setPaddingBottom(5f);
        pTableDataPart1.addCell(cellDataPart1);
        cellDataPart1 = new PdfPCell(new Phrase((covertDouble(reS.getLIMITE()) == null) ? reS.getLIMITE()
                : Moeda.format(covertDouble(reS.getLIMITE())), fontCorpo));
        cellDataPart1.setBorder(PdfPCell.NO_BORDER);
        cellDataPart1.setPaddingTop(5f);
        cellDataPart1.setPaddingBottom(5f);
        pTableDataPart1.addCell(cellDataPart1);

        cellDataPart1 = new PdfPCell(new Phrase("MOEDA:", fontCorpoN));
        cellDataPart1.setPaddingTop(5f);
        cellDataPart1.setPaddingBottom(10f);
        cellDataPart1.setBorder(PdfPCell.NO_BORDER);
        pTableDataPart1.addCell(cellDataPart1);

        cellDataPart1 = new PdfPCell(new Phrase(reS.getMOEDA(), fontCorpo));
        cellDataPart1.setPaddingTop(5f);
        cellDataPart1.setPaddingBottom(10f);
        cellDataPart1.setBorder(PdfPCell.NO_BORDER);
        pTableDataPart1.addCell(cellDataPart1);
        /**
         * Data Part 1 end
         */

        /**
         * Data Part 2 start
         */
        PdfPTable pTableDataPart2 = new PdfPTable(new float[] { 33.333333333f, 33.333333333f, 33.333333333f });
        pTableDataPart2.setWidthPercentage(90);

        PdfPCell cellDataPart2 = new PdfPCell(new Phrase("PREMIO GROSSO:", fontCorpoN));
        cellDataPart2.setColspan(2);
        cellDataPart2.setBorder(PdfPCell.NO_BORDER);
        cellDataPart2.setPaddingTop(10f);
        cellDataPart2.setPaddingBottom(5f);
        pTableDataPart2.addCell(cellDataPart2);
        cellDataPart2 = new PdfPCell(new Phrase(
                Moeda.format(Double.valueOf(reS.getPREMIOGROSSO().replace(',', '.'))) + " " + reS.getMOEDA(),
                fontCorpo));
        cellDataPart2.setPaddingTop(10f);
        cellDataPart2.setPaddingBottom(5f);
        cellDataPart2.setBorder(PdfPCell.NO_BORDER);
        pTableDataPart2.addCell(cellDataPart2);

        cellDataPart2 = new PdfPCell(new Phrase("DEDUO:", fontCorpoN));
        cellDataPart2.setBorder(PdfPCell.NO_BORDER);
        cellDataPart2.setColspan(2);
        cellDataPart2.setPaddingTop(5f);
        cellDataPart2.setPaddingBottom(5f);
        pTableDataPart2.addCell(cellDataPart2);
        cellDataPart2 = new PdfPCell(new Phrase(reS.getDEDUCAO() + "%", fontCorpo));
        cellDataPart2.setPaddingTop(5f);
        cellDataPart2.setPaddingBottom(5f);
        cellDataPart2.setBorder(PdfPCell.NO_BORDER);
        pTableDataPart2.addCell(cellDataPart2);

        cellDataPart2 = new PdfPCell(new Phrase("LIQUIDO:", fontCorpoN));
        cellDataPart2.setBorder(PdfPCell.NO_BORDER);
        cellDataPart2.setColspan(2);
        cellDataPart2.setPaddingTop(5f);
        cellDataPart2.setPaddingBottom(5f);
        pTableDataPart2.addCell(cellDataPart2);
        cellDataPart2 = new PdfPCell(new Phrase(
                Moeda.format(Double.valueOf(reS.getPREMIOGROSSO().replace(',', '.'))) + " " + reS.getMOEDA(),
                fontCorpo));
        cellDataPart2.setPaddingTop(5f);
        cellDataPart2.setPaddingBottom(5f);
        cellDataPart2.setBorder(PdfPCell.NO_BORDER);
        pTableDataPart2.addCell(cellDataPart2);

        cellDataPart2 = new PdfPCell(new Phrase("TOTAL:", fontCorpoN));
        cellDataPart2.setBorder(PdfPCell.NO_BORDER);
        cellDataPart2.setPaddingTop(5f);
        cellDataPart2.setPaddingBottom(10f);
        pTableDataPart2.addCell(cellDataPart2);
        cellDataPart2 = new PdfPCell(new Phrase("100%", fontCorpo));
        cellDataPart2.setPaddingTop(5f);
        cellDataPart2.setPaddingBottom(10f);
        cellDataPart2.setBorder(PdfPCell.NO_BORDER);
        pTableDataPart2.addCell(cellDataPart2);
        cellDataPart2 = new PdfPCell(new Phrase(
                Moeda.format(Double.valueOf(reS.getTOTAL().replace(',', '.'))) + " " + reS.getMOEDA(),
                fontCorpo));
        cellDataPart2.setPaddingTop(5f);
        cellDataPart2.setPaddingBottom(10f);
        cellDataPart2.setBorder(PdfPCell.NO_BORDER);
        pTableDataPart2.addCell(cellDataPart2);

        //            cellDataPart2 = new PdfPCell(new Phrase("Your faithfully", fontCorpo));
        //            cellDataPart2.setColspan(3);
        //            cellDataPart2.setPaddingTop(5f);
        //            cellDataPart2.setPaddingBottom(0.7f);
        //            cellDataPart2.setBorder(PdfPCell.NO_BORDER);
        //            pTableDataPart2.addCell(cellDataPart2);
        //            cellDataPart2 = new PdfPCell(new Phrase("THE UNITED AFRICAN INSURANCE BROKERS LTD", fontCorpo));
        //            cellDataPart2.setColspan(3);
        //            cellDataPart2.setPaddingTop(0.7f);
        //            cellDataPart2.setPaddingBottom(10F);
        //            cellDataPart2.setBorder(PdfPCell.NO_BORDER);
        //            pTableDataPart2.addCell(cellDataPart2);
        /**
         * Data Part 2 end
         */
        PdfPTable pTableSecureter = new PdfPTable(new float[] { 30f, 30f, 40f });

        PdfPCell cellSecureterNull = new PdfPCell(new Phrase(" ", fontCorpoN));
        cellSecureterNull.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
        cellSecureterNull.setPaddingTop(2f);
        cellSecureterNull.setPaddingBottom(2f);
        cellSecureterNull.setColspan(3);
        cellSecureterNull.setBorder(PdfPCell.NO_BORDER);
        pTableSecureter.addCell(cellSecureterNull);

        cellSecureterNull.setColspan(0);

        if (isReseguroOfNICON) {
            PdfPCell cellSecureter = new PdfPCell(new Phrase("RESSEGURADORA USADA", fontCorpoN));
            cellSecureter.setColspan(2);
            cellSecureter.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
            cellSecureter.setPaddingTop(8f);
            cellSecureter.setPaddingBottom(8f);
            cellSecureter.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
            pTableSecureter.addCell(cellSecureter);
            pTableSecureter.addCell(cellSecureterNull);

            cellSecureter = new PdfPCell(new Phrase("RESSEGURA", fontCorpoN));
            cellSecureter.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
            cellSecureter.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
            cellSecureter.setPaddingTop(5f);
            cellSecureter.setPaddingBottom(5);
            pTableSecureter.addCell(cellSecureter);
            cellSecureter = new PdfPCell(new Phrase("%PERCENTAGEM", fontCorpoN));
            cellSecureter.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
            cellSecureter.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
            cellSecureter.setPaddingTop(5f);
            cellSecureter.setPaddingBottom(5);
            pTableSecureter.addCell(cellSecureter);
            pTableSecureter.addCell(cellSecureterNull);

            int total = listaDataEmpresas.size();
            for (int i = 0; (i < total); i++) {
                cellSecureter = new PdfPCell(new Phrase(listaDataEmpresas.get(i).getEMPRESA(), fontCorpo));
                cellSecureter.setPaddingTop(5f);
                cellSecureter.setPaddingBottom(5);
                cellSecureter.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
                pTableSecureter.addCell(cellSecureter);
                cellSecureter = new PdfPCell(new Phrase(
                        listaDataEmpresas.get(i).getPERCENTAGEM() + "% -- "
                                + Moeda.format(((covertDouble(listaDataEmpresas.get(i).getPERCENTAGEM()) / 100)
                                        * covertDouble(reS.getPREMIOGROSSO())))
                                + " " + reS.getMOEDA(),
                        fontCorpo));
                cellSecureter.setPaddingTop(5f);
                cellSecureter.setPaddingBottom(5);
                cellSecureter.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
                cellSecureter.setHorizontalAlignment(PdfPCell.ALIGN_RIGHT);
                pTableSecureter.addCell(cellSecureter);
                pTableSecureter.addCell(cellSecureterNull);
            }
        }
        PdfPTable pTablePocessed = new PdfPTable(new float[] { 100 });
        PdfPCell cellPocessed = new PdfPCell(new Phrase("_____________________________", fontCorpoN));
        cellPocessed.setBorder(PdfPCell.NO_BORDER);
        cellPocessed.setVerticalAlignment(PdfPCell.ALIGN_BOTTOM);
        cellPocessed.setPaddingTop(50f);
        cellPocessed.setPaddingBottom(1f);
        pTablePocessed.addCell(cellPocessed);
        cellPocessed = new PdfPCell(new Phrase("PROCESSED BY", fontCorpoN));
        cellPocessed.setPaddingTop(1f);
        cellPocessed.setVerticalAlignment(PdfPCell.ALIGN_TOP);
        cellPocessed.setBorder(PdfPCell.NO_BORDER);
        pTablePocessed.addCell(cellPocessed);

        SimpleDateFormat sdf1 = new SimpleDateFormat("dd-MM-yyyy hh'.'mm'.'ss");

        Document documento = new Document();
        documento.setPageSize(PageSize.A4);
        documento.setMargins(20f, 20f, 70f, 5f);

        String f1 = (arquivo + "/" + user + "/Seguro " + nomeSeguro + "/");
        File f = new File(f1);
        String Ddata = sdf1.format(new Date());
        f.mkdirs();
        f = new File(f.getAbsoluteFile() + "/" + "Doc Nota CO-ReSSEGURO " + Ddata + ".pdf");

        reString = "../Documentos/" + user + "/Seguro " + nomeSeguro + "/" + "Doc Nota CO-ReSSEGURO " + Ddata
                + ".pdf";
        OutputStream outputStraem = new FileOutputStream(f);
        PdfWriter writer = PdfWriter.getInstance(documento, outputStraem);

        documento.open();
        documento.add(pTableEmpresaPricipal);
        documento.add(pTableLinha);
        documento.add(pTableLinha);
        /*
        documento.add(pTableTileDoc);
        documento.add(pTableLinha);
         */
        documento.add(pTableDataPart1);
        documento.add(pTableLinha);
        documento.add(pTableDataPart2);
        documento.add(pTableLinha);
        documento.add(pTableLinha);
        documento.add(pTableSecureter);
        //            documento.add(pTablePocessed);
        pTablePocessed.setTotalWidth(200);
        pTablePocessed.writeSelectedRows(-1, 100, 100f, 175f, writer.getDirectContent());
        documento.close();

        RequestContext.getCurrentInstance().execute("openAllDocument('" + reString + "')");

    } catch (FileNotFoundException | DocumentException e) {
    } catch (IOException ex) {
        Logger.getLogger(DocNotaCredito.class.getName()).log(Level.SEVERE, null, ex);
    }

}

From source file:Export.ExporOnlyViagemPdf.java

private void radapeTable(PdfPTable pTableDate, Document documento) throws DocumentException {
    PdfPCell cellRodape = new PdfPCell(cellRodape(" ", false, false, -1));
    cellRodape.setBorder(PdfPCell.NO_BORDER);
    cellRodape.setColspan(2);
    setStyleRodape(cellRodape);//w  w  w. j a  v a2s.c o m
    pTableDate.addCell(cellRodape);

    cellRodape = new PdfPCell(cellRodape(" ", false, false, -1));
    cellRodape.setBorder(PdfPCell.NO_BORDER);
    setStyleRodape(cellRodape);
    pTableDate.addCell(cellRodape);

    cellRodape = new PdfPCell(cellRodape(" ", false, false, -1));
    cellRodape.setBorder(PdfPCell.NO_BORDER);
    setStyleRodape(cellRodape);
    pTableDate.addCell(cellRodape);

    cellRodape = new PdfPCell(cellRodape(" ", false, false, -1));
    cellRodape.setBorder(PdfPCell.NO_BORDER);
    setStyleRodape(cellRodape);
    pTableDate.addCell(cellRodape);

    cellRodape = new PdfPCell(cellRodape(" ", false, false, -1));
    cellRodape.setBorder(PdfPCell.NO_BORDER);
    setStyleRodape(cellRodape);
    pTableDate.addCell(cellRodape);

    cellRodape = new PdfPCell(cellRodape(" ", false, false, -1));
    cellRodape.setBorder(PdfPCell.NO_BORDER);
    setStyleRodape(cellRodape);
    pTableDate.addCell(cellRodape);

    cellRodape = new PdfPCell(cellRodape(" ", false, false, -1));
    cellRodape.setBorder(PdfPCell.NO_BORDER);
    setStyleRodape(cellRodape);
    pTableDate.addCell(cellRodape);

    cellRodape = new PdfPCell(
            cellRodape(ConfigDoc.toMoeda(totalPremio, ""), false, false, Element.ALIGN_RIGHT));
    cellRodape.setBorder(PdfPCell.NO_BORDER);
    setStyleRodape(cellRodape);
    pTableDate.addCell(cellRodape);

    cellRodape = new PdfPCell(
            cellRodape(ConfigDoc.toMoeda(totalComissao, ""), false, false, Element.ALIGN_RIGHT));
    cellRodape.setBorder(PdfPCell.NO_BORDER);
    setStyleRodape(cellRodape);
    pTableDate.addCell(cellRodape);

    cellRodape = new PdfPCell(
            cellRodape(ConfigDoc.toMoeda(totalConsumo, ""), false, false, Element.ALIGN_RIGHT));
    cellRodape.setBorder(PdfPCell.NO_BORDER);
    setStyleRodape(cellRodape);
    pTableDate.addCell(cellRodape);
    cellRodape = new PdfPCell(cellRodape(ConfigDoc.toMoeda(totalSelo, ""), false, false, Element.ALIGN_RIGHT));
    cellRodape.setBorder(PdfPCell.NO_BORDER);
    setStyleRodape(cellRodape);
    pTableDate.addCell(cellRodape);

    //        cellRodape = new PdfPCell(cellRodape(" ", false, false,-1));
    //        cellRodape.setBorder(PdfPCell.NO_BORDER);
    //        setStyleRodape(cellRodape);
    //        pTableDate.addCell(cellRodape);

    cellRodape = new PdfPCell(cellRodape(ConfigDoc.toMoeda(totalTotal, ""), false, false, Element.ALIGN_RIGHT));
    cellRodape.setBorder(PdfPCell.NO_BORDER);
    setStyleRodape(cellRodape);
    //        cellRodape.setBorderWidthBottom(0.5f);
    //        cellRodape.setBorderWidthRight(0.5f);
    //        cellRodape.setPadding(2f);
    //        cellRodape.setPaddingLeft(0.8f);
    pTableDate.addCell(cellRodape);

    documento.add(pTableDate);
}

From source file:Export.ExportViagemSemanaPdf.java

public static void criarDoc(Date dataInicio, Date dateFim, String user, String nomeFuncinario) {
    Font fontTableCorpo = FontFactory.getFont(ConfigDoc.Fontes.FONT, BaseFont.WINANSI, BaseFont.EMBEDDED, 6f);
    Font fontTableTitile = FontFactory.getFont(ConfigDoc.Fontes.FONTB, BaseFont.WINANSI, BaseFont.EMBEDDED, 6f);

    Font fontRoadape = FontFactory.getFont(ConfigDoc.Fontes.FONTB, BaseFont.WINANSI, BaseFont.EMBEDDED, 8f);
    Font fontRoadapeP = FontFactory.getFont(ConfigDoc.Fontes.FONTB, BaseFont.WINANSI, BaseFont.EMBEDDED, 6f);
    Font fontRoadapeB = FontFactory.getFont(ConfigDoc.Fontes.FONTB, BaseFont.WINANSI, BaseFont.EMBEDDED, 8f);
    Font fontRoadapeBU = FontFactory.getFont(ConfigDoc.Fontes.FONTB, BaseFont.WINANSI, BaseFont.EMBEDDED, 8f,
            Font.UNDEFINED);//  w  w w.j av  a2s  .co  m

    Font fontCabecalhoN = FontFactory.getFont(ConfigDoc.Fontes.FONTB, BaseFont.WINANSI, BaseFont.EMBEDDED,
            9.5f);
    Font fontCorpoNG = FontFactory.getFont(ConfigDoc.Fontes.FONTB, BaseFont.WINANSI, BaseFont.EMBEDDED, 9.5f);
    Font fontCabecalhoNG = FontFactory.getFont(ConfigDoc.Fontes.FONTB, BaseFont.WINANSI, BaseFont.EMBEDDED, 16f,
            Font.UNDERLINE);

    OutputStream outputStraem;
    try {
        SimpleDateFormat sdf = new SimpleDateFormat("dd-MM-yyyy hh.mm.ss");
        SimpleDateFormat sdfTitile = new SimpleDateFormat("dd-MM-yyyy");
        Document documento = new Document();
        documento.setPageSize(PageSize.A4.rotate());
        documento.setMargins(10f, 10f, 35f, 20f);

        File ff = new File(ConfigDoc.Fontes.getDiretorio() + "/" + user + "/Seguro Viagem/");
        ff.mkdirs();

        String Ddata = sdf.format(new Date());

        ff = new File(ff.getAbsoluteFile() + "/" + "Export Mapa Viagem Semanal " + Ddata + ".pdf");
        String reString = "../Documentos/" + user + "/Seguro Viagem/" + "Export Mapa Viagem Semanal " + Ddata
                + ".pdf";
        outputStraem = new FileOutputStream(ff);

        PdfWriter writer = PdfWriter.getInstance(documento, outputStraem);

        PdfPTable tableDados = new PdfPTable(
                new float[] { 5f, 10.6f, 5f, 5f, 4.6f, 19f, 5.6f, 6f, 10.6f, 9.6f, 7f, 5.5f, 5.5f });
        tableDados.setWidthPercentage(100f);

        BaseColor colorCinza = new BaseColor(129, 138, 145);

        for (int j = 0; j < 13; j++) {
            PdfPCell cellTitileTable = new PdfPCell(new Phrase(titileTable(j), fontTableTitile));
            cellTitileTable.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
            cellTitileTable.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);

            cellTitileTable.setBackgroundColor(colorCinza);
            tableDados.addCell(cellTitileTable);
        }

        dataViagem(dataInicio, dateFim);

        float premiototal = 0;

        for (HashMap<String, Object> data : hasList) {
            tableDados.addCell(new Phrase(toString(data.get(DATA)), fontTableCorpo));
            tableDados.addCell(ExportViagemSemanaPdf
                    .cellEspecial(new PdfPCell(new Phrase(toString(data.get(NUMEROAPOLICE)), fontTableCorpo))));
            tableDados.addCell(
                    new Phrase(ConfigDoc.toFormat(toString(data.get(INICIO)), "dd-MM-yyyy", "yyyy-MM-dd"),
                            fontTableCorpo));
            tableDados.addCell(new Phrase(
                    ConfigDoc.toFormat(toString(data.get(FIM)), "dd-MM-yyyy", "yyyy-MM-dd"), fontTableCorpo));

            premiototal += toFloat(data.get(PREMIO));

            PdfPCell cellRigh = new PdfPCell(
                    new Phrase(ConfigDoc.toMoeda(toFloat(data.get(PREMIO)), ""), fontTableCorpo));
            cellRigh.setHorizontalAlignment(PdfPCell.ALIGN_RIGHT);
            tableDados.addCell(cellRigh);

            tableDados.addCell(new Phrase(toString(data.get(CLIENTE)), fontTableCorpo));
            tableDados.addCell(new Phrase(toString(data.get(DATANASCIMENTO)), fontTableCorpo));
            tableDados.addCell(new Phrase(toString(data.get(TELEFONE)), fontTableCorpo));
            tableDados.addCell(new Phrase(toString(data.get(ENDERECO)), fontTableCorpo));
            tableDados.addCell(new Phrase(toString(data.get(LOCALNASCIMENTO)), fontTableCorpo));
            tableDados.addCell(new Phrase(toString(data.get(PAISDESTINO)), fontTableCorpo));
            tableDados.addCell(new Phrase(toString(data.get(CIDADEDESTINO)), fontTableCorpo));
            tableDados.addCell(new Phrase(toString(data.get(ZONADESTINO)), fontTableCorpo));
        }

        PdfPCell cellTotal = new PdfPCell(ExportViagemSemanaPdf.cellEspecial(new PdfPCell(
                new Phrase("AL AMOUNT..........................................", fontTableTitile))));
        cellTotal.setColspan(4);
        cellTotal.setPadding(1.5f);
        cellTotal.setBackgroundColor(colorCinza);
        tableDados.addCell(cellTotal);

        cellTotal = new PdfPCell(ExportViagemSemanaPdf
                .cellEspecial(new PdfPCell(new Phrase(ConfigDoc.toMoeda(premiototal, ""), fontTableTitile))));
        cellTotal.setPadding(1.5f);
        cellTotal.setBackgroundColor(colorCinza);
        tableDados.addCell(cellTotal);

        cellTotal = new PdfPCell(
                ExportViagemSemanaPdf.cellEspecial(new PdfPCell(new Phrase(" ", fontTableTitile))));
        cellTotal.setColspan(8);
        cellTotal.setPadding(1.5f);
        cellTotal.setBackgroundColor(colorCinza);
        tableDados.addCell(cellTotal);

        PdfPTable pTableEmpresaPricipal = new PdfPTable(new float[] { 15f, 85f });
        PdfPTable pTableEmpresaInforImpres1 = new PdfPTable(1);
        PdfPTable pTableEmpresaInforImpres5 = new PdfPTable(1);

        PdfPCell pCellNomeEmpresa = new PdfPCell(new Phrase(ConfigDoc.Empresa.NOME, fontCabecalhoNG));
        pCellNomeEmpresa.setBorder(0);
        PdfPCell pCellNomeEndereco = new PdfPCell(new Phrase(ConfigDoc.Empresa.ENDERECO, fontCabecalhoN));
        pCellNomeEndereco.setBorder(0);
        PdfPCell pCellCaixaPostal = new PdfPCell(new Phrase(ConfigDoc.Empresa.CAIXAPOSTAL, fontCabecalhoN));
        pCellCaixaPostal.setBorder(0);
        PdfPCell pCellTeleFax = new PdfPCell(
                new Phrase(ConfigDoc.Empresa.TELEFAX + " " + ConfigDoc.Empresa.EMAIL, fontCabecalhoN));
        pCellTeleFax.setBorder(0);
        PdfPCell pCellSociedade = new PdfPCell(new Phrase(ConfigDoc.Empresa.SOCIEDADE, fontCabecalhoN));
        pCellSociedade.setBorder(0);
        Image imageEmpresa = Image.getInstance("logo.png");
        imageEmpresa.scaleToFit(120f, 85f);
        pTableEmpresaInforImpres1.addCell(pCellNomeEmpresa);
        pTableEmpresaInforImpres1.addCell(pCellNomeEndereco);
        pTableEmpresaInforImpres1.addCell(pCellCaixaPostal);
        pTableEmpresaInforImpres1.addCell(pCellTeleFax);
        pTableEmpresaInforImpres1.addCell(pCellSociedade);
        PdfPCell cellTabela3 = new PdfPCell(pTableEmpresaInforImpres1);
        cellTabela3.setBorder(0);
        pTableEmpresaInforImpres5.addCell(cellTabela3);
        PdfPCell cellTabela5 = new PdfPCell(pTableEmpresaInforImpres5);
        cellTabela5.setBorder(0);
        PdfPCell cellTabela6 = new PdfPCell(imageEmpresa);
        cellTabela6.setBorder(0);
        pTableEmpresaPricipal.setWidthPercentage(95);
        pTableEmpresaPricipal.addCell(cellTabela6);
        pTableEmpresaPricipal.addCell(cellTabela5);

        PdfPTable pTableTitulo = new PdfPTable(1);
        pTableTitulo.setHorizontalAlignment(Element.ALIGN_CENTER);
        pTableTitulo.setWidthPercentage(100);

        PdfPCell cellTitulo = new PdfPCell(new Phrase("RLELATORIO SEMANAL NO. " + "" + "\n"
                + ((dataInicio != null) ? sdfTitile.format(dataInicio) + " - " : "")
                + ((dateFim != null) ? sdfTitile.format(dateFim) : ""), fontCorpoNG));
        cellTitulo.setBorder(0);
        cellTitulo.setPaddingBottom(20f);
        cellTitulo.setPaddingTop(10f);
        cellTitulo.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
        pTableTitulo.addCell(cellTitulo);

        pTableEmpresaPricipal.setHorizontalAlignment(Element.ALIGN_CENTER);

        PdfPTable pTableRodape = new PdfPTable(new float[] { 50f, 50f });
        pTableRodape.setWidthPercentage(90f);

        PdfPCell cellRodape = new PdfPCell(new Phrase("DEPARTAMENTO FINANCEIRO", fontRoadapeBU));
        cellRodape.setBorder(0);
        cellRodape.setColspan(2);
        cellRodape.setPaddingTop(20f);
        pTableRodape.addCell(cellRodape);

        cellRodape = new PdfPCell(new Phrase("QUEIRA POR FAVOR CONFERIR OS PAGAMENTOS", fontRoadape));
        cellRodape.setColspan(2);
        cellRodape.setBorder(0);
        pTableRodape.addCell(cellRodape);

        cellRodape = new PdfPCell(new Phrase("ELABORADO POR", fontRoadapeB));
        cellRodape.setBorder(0);
        pTableRodape.addCell(cellRodape);
        cellRodape = new PdfPCell(new Phrase("VENFICADO POR", fontRoadapeB));
        cellRodape.setBorder(0);
        cellRodape.setHorizontalAlignment(PdfPCell.ALIGN_RIGHT);
        pTableRodape.addCell(cellRodape);

        cellRodape = new PdfPCell(new Phrase("................................................", fontRoadape));
        cellRodape.setBorder(0);
        cellRodape.setPaddingTop(30f);
        pTableRodape.addCell(cellRodape);
        cellRodape = new PdfPCell(new Phrase("................................................", fontRoadape));
        cellRodape.setHorizontalAlignment(PdfPCell.ALIGN_RIGHT);
        cellRodape.setBorder(0);
        cellRodape.setPaddingTop(30f);
        pTableRodape.addCell(cellRodape);

        cellRodape = new PdfPCell(new Phrase(nomeFuncinario, fontRoadapeP));
        cellRodape.setColspan(2);
        cellRodape.setBorder(0);
        pTableRodape.addCell(cellRodape);

        documento.open();
        documento.add(pTableEmpresaPricipal);
        documento.add(pTableTitulo);
        documento.add(tableDados);
        documento.add(pTableRodape);
        documento.close();

        RequestContext.getCurrentInstance().execute("openAllDocument('" + reString + "')");

    } catch (FileNotFoundException | DocumentException ex) {
        Logger.getLogger(ExportViagemSemanaPdf.class.getName()).log(Level.SEVERE, null, ex);
    } catch (IOException ex) {
        Logger.getLogger(ExportViagemSemanaPdf.class.getName()).log(Level.SEVERE, null, ex);
    }
}

From source file:Export.FaturaCoReSeguro__.java

public String docSeguros(String nomeSeguro, String numApolice, String fundoContrato, String user, String moeda,
        String arquivo, String numeroRegistro) {
    String reString;/* w  w w  . j  a v a 2s  .c  o m*/
    try {

        Font fontCabecalhoN = FontFactory.getFont(ConfigDoc.Fontes.FONTB, BaseFont.WINANSI, BaseFont.EMBEDDED,
                9.2f);
        Font fontLinha = FontFactory.getFont(ConfigDoc.Fontes.FONTB, BaseFont.WINANSI, BaseFont.EMBEDDED,
                0.000000358f);
        Font fontCabecalhoS = FontFactory.getFont(ConfigDoc.Fontes.FONT, BaseFont.WINANSI, BaseFont.EMBEDDED,
                9.2f);
        Font fontCorpo = FontFactory.getFont(ConfigDoc.Fontes.FONT, BaseFont.WINANSI, BaseFont.EMBEDDED, 8f);
        Font fontCorpoN = FontFactory.getFont(ConfigDoc.Fontes.FONTB, BaseFont.WINANSI, BaseFont.EMBEDDED, 8f);
        Font fontNull = FontFactory.getFont(ConfigDoc.Fontes.FONT, BaseFont.WINANSI, BaseFont.EMBEDDED, 4f);
        Font fontMenor = FontFactory.getFont(ConfigDoc.Fontes.FONT, BaseFont.WINANSI, BaseFont.EMBEDDED, 6f);
        Font fontMenorN = FontFactory.getFont(ConfigDoc.Fontes.FONT, BaseFont.WINANSI, BaseFont.EMBEDDED, 6f);

        PdfPTable pTableEmpresaPricipal = new PdfPTable(new float[] { 80, 20 });
        PdfPTable pTableEmpresaInforImpres1 = new PdfPTable(1);
        PdfPTable pTableEmpresaInforImpres2 = new PdfPTable(1);
        PdfPTable pTableEmpresaInforImpres4 = new PdfPTable(1);
        PdfPTable pTableEmpresaInforImpres5 = new PdfPTable(1);

        PdfPCell pCellNomeEmpresa = new PdfPCell(new Phrase(ConfigDoc.Empresa.NOME, fontCabecalhoN));
        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);

        PdfPCell pCellCapital = new PdfPCell(new Phrase(ConfigDoc.Empresa.CAPITALSOCIAL, fontCabecalhoN));
        pCellCapital.setBorder(0);

        PdfPCell pCellPolice = new PdfPCell(new Phrase(ConfigDoc.Empresa.APOLICE + numApolice, fontCabecalhoN));
        pCellPolice.setBorder(0);

        Image imageEmpresa = Image.getInstance("logo.png");
        imageEmpresa.scaleToFit(120f, 100f);

        pTableEmpresaInforImpres1.addCell(pCellNomeEmpresa);
        pTableEmpresaInforImpres1.addCell(pCellNomeEndereco);
        pTableEmpresaInforImpres1.addCell(pCellCaixaPostal);
        pTableEmpresaInforImpres1.addCell(pCellTeleFax);
        pTableEmpresaInforImpres1.addCell(pCellSociedade);

        pTableEmpresaInforImpres2.addCell(pCellCapital);
        pTableEmpresaInforImpres2.addCell(pCellPolice);

        PdfPCell cellTabela1 = new PdfPCell(pTableEmpresaInforImpres2);
        cellTabela1.setBorder(0);

        pTableEmpresaInforImpres4.addCell(cellTabela1);

        PdfPCell cellTabela3 = new PdfPCell(pTableEmpresaInforImpres1);
        cellTabela3.setBorder(0);

        pTableEmpresaInforImpres5.addCell(cellTabela3);

        PdfPCell cellTabela4 = new PdfPCell(pTableEmpresaInforImpres4);
        cellTabela4.setBorder(0);

        pTableEmpresaInforImpres5.addCell(cellTabela4);

        PdfPCell cellTabela5 = new PdfPCell(pTableEmpresaInforImpres5);
        cellTabela5.setBorder(0);

        pTableEmpresaPricipal.addCell(cellTabela5);

        PdfPCell cellTabela6 = new PdfPCell(imageEmpresa);
        cellTabela6.setBorder(0);
        cellTabela6.setHorizontalAlignment(Element.ALIGN_RIGHT);

        pTableEmpresaPricipal.addCell(cellTabela6);

        PdfPTable pTableLinha = new PdfPTable(1);
        PdfPCell linha = new PdfPCell(new Phrase(" ", fontLinha));
        linha.setBorderWidthTop(0.5f);
        linha.setBorderWidthBottom(0);
        linha.setBorderWidthLeft(0);
        linha.setBorderWidthRight(0);
        pTableLinha.addCell(linha);

        /**
         * Tile Doc
         */
        PdfPTable pTableTileDoc = new PdfPTable(new float[] { 65f, 35f });

        PdfPCell cellTileDoc = new PdfPCell(new Phrase("FACTURA", fontCabecalhoS));
        cellTileDoc.setColspan(2);
        cellTileDoc.setHorizontalAlignment(PdfPCell.ALIGN_RIGHT);
        cellTileDoc.setBorder(PdfPCell.NO_BORDER);

        pTableTileDoc.addCell(cellTileDoc);

        Paragraph pNumFatura = new Paragraph();
        pNumFatura.add(new Phrase("Factura N ", fontMenorN));
        pNumFatura.add(new Phrase("0019528/16 ", fontMenor));
        cellTileDoc = new PdfPCell(pNumFatura);
        cellTileDoc.setColspan(2);
        cellTileDoc.setHorizontalAlignment(PdfPCell.ALIGN_RIGHT);
        cellTileDoc.setBorder(PdfPCell.NO_BORDER);
        cellTileDoc.setPaddingBottom(10f);

        pTableTileDoc.addCell(cellTileDoc);

        PdfPTable pTableCliente = new PdfPTable(new float[] { 100 });

        Paragraph pCliente = new Paragraph();
        pCliente.add(new Phrase("Nome: ", fontCorpo));
        pCliente.add(new Phrase(" ", fontCorpoN));
        PdfPCell cellCliente = new PdfPCell(pCliente);
        cellCliente.setBorder(PdfPCell.NO_BORDER);
        pTableCliente.addCell(cellCliente);

        pCliente = new Paragraph();
        pCliente.add(new Phrase("Morada: ", fontCorpo));
        pCliente.add(new Phrase(" ", fontCorpoN));
        cellCliente = new PdfPCell(pCliente);
        cellCliente.setBorder(PdfPCell.NO_BORDER);
        pTableCliente.addCell(cellCliente);

        pCliente = new Paragraph();
        pCliente.add(new Phrase("Localidade: ", fontCorpo));
        pCliente.add(new Phrase(" ", fontCorpoN));
        pCliente.add(new Phrase("  ?rea: ", fontCorpo));
        pCliente.add(new Phrase(" ", fontCorpoN));
        pCliente.add(new Phrase("  CP: ", fontCorpo));
        pCliente.add(new Phrase(" ", fontCorpoN));
        cellCliente = new PdfPCell(pCliente);
        cellCliente.setBorder(PdfPCell.NO_BORDER);
        pTableCliente.addCell(cellCliente);

        pCliente = new Paragraph();
        pCliente.add(new Phrase("Telefone: ", fontCorpo));
        pCliente.add(new Phrase(" ", fontCorpoN));
        cellCliente = new PdfPCell(pCliente);
        cellCliente.setBorder(PdfPCell.NO_BORDER);
        pTableCliente.addCell(cellCliente);

        cellCliente = new PdfPCell(pTableCliente);
        cellCliente.setBorder(PdfPCell.NO_BORDER);
        pTableTileDoc.addCell(cellCliente);

        PdfPTable pTableContrato = new PdfPTable(new float[] { 40, 60 });

        PdfPCell cellContrato = new PdfPCell(new Phrase("Data", fontCorpo));
        cellContrato.setBorder(PdfPCell.NO_BORDER);
        pTableContrato.addCell(cellContrato);

        cellContrato = new PdfPCell(new Phrase("09-12-2016", fontCorpo));
        cellContrato.setBorder(PdfPCell.NO_BORDER);
        pTableContrato.addCell(cellContrato);

        cellContrato = new PdfPCell(new Phrase("Vendedor", fontCorpo));
        cellContrato.setBorder(PdfPCell.NO_BORDER);
        pTableContrato.addCell(cellContrato);

        cellContrato = new PdfPCell(new Phrase("SAT ISURANCE", fontCorpoN));
        cellContrato.setBorder(PdfPCell.NO_BORDER);
        pTableContrato.addCell(cellContrato);

        cellContrato = new PdfPCell(new Phrase(" ", fontCorpoN));
        cellContrato.setBorder(PdfPCell.NO_BORDER);
        pTableContrato.addCell(cellContrato);

        Paragraph pNIF = new Paragraph();
        pNIF.add(new Phrase("NIF: ", fontCorpoN));
        pNIF.add(new Phrase(" 517255068", fontCorpoN));
        cellContrato = new PdfPCell(pNIF);
        cellContrato.setBorder(PdfPCell.NO_BORDER);
        pTableContrato.addCell(cellContrato);

        cellContrato = new PdfPCell(pTableContrato);
        cellContrato.setBorder(PdfPCell.BOX);
        cellContrato.setPadding(5f);
        pTableTileDoc.addCell(cellContrato);

        PdfPTable pTableDados = new PdfPTable(new float[] { 10, 50, 18, 22 });

        PdfPCell cellDados = new PdfPCell(new Phrase("Qtde.", fontCorpoN));
        pTableDados.addCell(cellDados);

        cellDados = new PdfPCell(new Phrase("Descrio.", fontCorpoN));
        pTableDados.addCell(cellDados);

        cellDados = new PdfPCell(new Phrase("Preo unitrio", fontCorpoN));
        pTableDados.addCell(cellDados);

        cellDados = new PdfPCell(new Phrase("Total", fontCorpoN));
        pTableDados.addCell(cellDados);

        cellDados = new PdfPCell(new Phrase("Qtde.", fontCorpo));
        cellDados.setRowspan(13);
        pTableDados.addCell(cellDados);

        cellDados = new PdfPCell(new Phrase("Descrio.", fontCorpo));
        cellDados.setRowspan(13);
        pTableDados.addCell(cellDados);

        cellDados = new PdfPCell(new Phrase("Preo unitrio", fontCorpo));
        cellDados.setRowspan(13);
        pTableDados.addCell(cellDados);

        cellDados = new PdfPCell(new Phrase("Total", fontCorpo));
        cellDados.setBorderWidthTop(0);
        cellDados.setBorderWidthBottom(0);
        cellDados.setBorderWidthLeft(0);
        cellDados.setBorderWidthRight(0.5f);
        pTableDados.addCell(cellDados);

        for (int i = 0; i < 12; i++) {
            cellDados = new PdfPCell(new Phrase(" ", fontCorpo));
            cellDados.setBorderWidthTop(0f);
            if ((i != (12 - 1))) {
                cellDados.setBorderWidthBottom(0f);
            }
            cellDados.setBorderWidthLeft(0f);
            cellDados.setBorderWidthRight(0.5f);
            pTableDados.addCell(cellDados);
        }

        cellDados = new PdfPCell(new Phrase("Total", fontCorpo));
        cellDados.setColspan(2);
        cellDados.setRowspan(8);
        pTableDados.addCell(cellDados);

        cellDados = new PdfPCell(new Phrase("SubTotal", fontCorpo));
        cellDados.setBorder(PdfPCell.NO_BORDER);
        cellDados.setHorizontalAlignment(PdfPCell.ALIGN_RIGHT);
        pTableDados.addCell(cellDados);

        cellDados = new PdfPCell(new Phrase("46.666.790,01 STD", fontCorpo));
        cellDados.setHorizontalAlignment(PdfPCell.ALIGN_RIGHT);
        pTableDados.addCell(cellDados);

        cellDados = new PdfPCell(new Phrase("Acessrios", fontCorpo));
        cellDados.setBorder(PdfPCell.NO_BORDER);
        cellDados.setHorizontalAlignment(PdfPCell.ALIGN_RIGHT);
        pTableDados.addCell(cellDados);

        cellDados = new PdfPCell(new Phrase("1.000.000,00 STD", fontCorpo));
        cellDados.setHorizontalAlignment(PdfPCell.ALIGN_RIGHT);
        pTableDados.addCell(cellDados);

        cellDados = new PdfPCell(new Phrase("Imposto", fontCorpo));
        cellDados.setBorder(PdfPCell.NO_BORDER);
        cellDados.setHorizontalAlignment(PdfPCell.ALIGN_RIGHT);
        pTableDados.addCell(cellDados);

        cellDados = new PdfPCell(new Phrase("2.680.669,75 STD", fontCorpo));
        cellDados.setHorizontalAlignment(PdfPCell.ALIGN_RIGHT);
        pTableDados.addCell(cellDados);

        cellDados = new PdfPCell(new Phrase("FGA", fontCorpo));
        cellDados.setBorder(PdfPCell.NO_BORDER);
        cellDados.setHorizontalAlignment(PdfPCell.ALIGN_RIGHT);
        pTableDados.addCell(cellDados);

        cellDados = new PdfPCell(new Phrase("1.196.669,75 STD", fontCorpo));
        cellDados.setHorizontalAlignment(PdfPCell.ALIGN_RIGHT);
        pTableDados.addCell(cellDados);

        cellDados = new PdfPCell(new Phrase("TOTAL", fontCorpoN));
        cellDados.setBorder(PdfPCell.NO_BORDER);
        pTableDados.addCell(cellDados);

        cellDados = new PdfPCell(new Phrase("51.744.000,00 STD", fontCorpoN));
        cellDados.setHorizontalAlignment(PdfPCell.ALIGN_RIGHT);
        pTableDados.addCell(cellDados);

        cellDados = new PdfPCell(new Phrase("Cambio", fontCorpo));
        cellDados.setBorder(PdfPCell.NO_BORDER);
        pTableDados.addCell(cellDados);

        cellDados = new PdfPCell(new Phrase("24.500,00 STD", fontCorpo));
        cellDados.setHorizontalAlignment(PdfPCell.ALIGN_RIGHT);
        cellDados.setBorder(PdfPCell.NO_BORDER);
        pTableDados.addCell(cellDados);

        cellDados = new PdfPCell(new Phrase("Total a pagar Euros", fontCorpo));
        cellDados.setBorderWidthRight(0);
        pTableDados.addCell(cellDados);

        cellDados = new PdfPCell(new Phrase("2.112,00 EUR", fontCorpo));
        cellDados.setHorizontalAlignment(PdfPCell.ALIGN_RIGHT);
        cellDados.setBorderWidthLeft(0);
        pTableDados.addCell(cellDados);

        cellDados = new PdfPCell(new Phrase("Total a Pagar USD", fontCorpo));
        cellDados.setBorderWidthRight(0);
        pTableDados.addCell(cellDados);

        cellDados = new PdfPCell(new Phrase("2.282.78 USD", fontCorpo));
        cellDados.setHorizontalAlignment(PdfPCell.ALIGN_RIGHT);
        cellDados.setBorderWidthLeft(0);
        pTableDados.addCell(cellDados);

        SimpleDateFormat sdf1 = new SimpleDateFormat("dd-MM-yyyy hh'.'mm'.'ss");

        Document documento = new Document();
        documento.setPageSize(PageSize.A4);
        documento.setMargins(20f, 20f, 70f, 5f);

        String f1 = (arquivo + "/" + user + "/Seguro " + nomeSeguro + "/");
        File f = new File(f1);
        String Ddata = sdf1.format(new Date());
        f.mkdirs();
        f = new File(f.getAbsoluteFile() + "/" + "Fatura CO-Re SEGURO " + Ddata + ".pdf");

        reString = "../Documentos/" + user + "/Seguro " + nomeSeguro + "/" + "Fatura CO-Re SEGURO " + Ddata
                + ".pdf";
        OutputStream outputStraem = new FileOutputStream(f);
        PdfWriter writer = PdfWriter.getInstance(documento, outputStraem);

        documento.open();
        documento.add(pTableEmpresaPricipal);
        documento.add(pTableLinha);
        documento.add(pTableLinha);
        documento.add(pTableTileDoc);
        documento.add(pTableDados);
        documento.close();

        return reString;
    } catch (FileNotFoundException | DocumentException e) {
    } catch (IOException ex) {
        Logger.getLogger(DocNotaCredito.class.getName()).log(Level.SEVERE, null, ex);
    }

    return "";
}

From source file:Export.GrossSarary.java

public static void criaDoc(String user) {
    OutputStream outputStraem;/*from   ww w. j ava  2s .c o m*/
    try {
        Font fontCabecalhoN = FontFactory.getFont(ConfigDoc.Fontes.FONTB, BaseFont.WINANSI, BaseFont.EMBEDDED,
                10f);
        Font fontCorpo = FontFactory.getFont(ConfigDoc.Fontes.FONT, BaseFont.WINANSI, BaseFont.EMBEDDED, 9f);
        Font fontCorpoBP = FontFactory.getFont(ConfigDoc.Fontes.FONTB, BaseFont.WINANSI, BaseFont.EMBEDDED, 9f);
        Font fontCorpoN = FontFactory.getFont(ConfigDoc.Fontes.FONTB, BaseFont.WINANSI, BaseFont.EMBEDDED,
                9.5f);
        Font fontCorpoNG = FontFactory.getFont(ConfigDoc.Fontes.FONTB, BaseFont.WINANSI, BaseFont.EMBEDDED,
                13f);
        Font fontCorpoTitile = FontFactory.getFont(ConfigDoc.Fontes.FONTB, BaseFont.WINANSI, BaseFont.EMBEDDED,
                11f);
        Font fontCabecalhoNG = FontFactory.getFont(ConfigDoc.Fontes.FONTB, BaseFont.WINANSI, BaseFont.EMBEDDED,
                16f, Font.UNDERLINE);

        SimpleDateFormat sdf1 = new SimpleDateFormat("dd-MM-yyyy hh'.'mm'.'ss");
        File ff = new File(ConfigDoc.Fontes.getDiretorio() + "/" + user + "/Relatorio");
        ff.mkdirs();
        String Ddata = sdf1.format(new Date());
        ff = new File(ff.getAbsoluteFile() + "/" + "Gross Salary " + Ddata + ".pdf");
        outputStraem = new FileOutputStream(ff);

        String reString = "../Documentos/" + user + "/Relatorio/Gross Salary " + Ddata + ".pdf";

        PdfPTable pTableEmpresaPricipal = new PdfPTable(new float[] { 15f, 85f });
        PdfPTable pTableEmpresaInforImpres1 = new PdfPTable(1);
        PdfPTable pTableEmpresaInforImpres5 = new PdfPTable(1);

        PdfPTable pTableNull = new PdfPTable(1);
        PdfPCell cellNull = new PdfPCell(new Phrase(" ", fontCorpo));
        cellNull.setBorder(0);
        pTableNull.addCell(cellNull);

        PdfPCell pCellNomeEmpresa = new PdfPCell(new Phrase(ConfigDoc.Empresa.NOME, fontCabecalhoNG));
        pCellNomeEmpresa.setBorder(0);

        PdfPCell pCellNomeEndereco = new PdfPCell(new Phrase(ConfigDoc.Empresa.ENDERECO, fontCabecalhoN));
        pCellNomeEndereco.setBorder(0);

        PdfPCell pCellCaixaPostal = new PdfPCell(new Phrase(ConfigDoc.Empresa.CAIXAPOSTAL, fontCabecalhoN));
        pCellCaixaPostal.setBorder(0);

        PdfPCell pCellTeleFax = new PdfPCell(
                new Phrase(ConfigDoc.Empresa.TELEFAX + " " + ConfigDoc.Empresa.EMAIL, fontCabecalhoN));
        pCellTeleFax.setBorder(0);

        PdfPCell pCellSociedade = new PdfPCell(new Phrase(ConfigDoc.Empresa.SOCIEDADE, fontCabecalhoN));
        pCellSociedade.setBorder(0);

        Image imageEmpresa = Image.getInstance("logo.png");
        imageEmpresa.scaleToFit(120f, 85f);

        pTableEmpresaInforImpres1.addCell(pCellNomeEmpresa);
        pTableEmpresaInforImpres1.addCell(pCellNomeEndereco);
        pTableEmpresaInforImpres1.addCell(pCellCaixaPostal);
        pTableEmpresaInforImpres1.addCell(pCellTeleFax);
        pTableEmpresaInforImpres1.addCell(pCellSociedade);

        PdfPCell cellTabela3 = new PdfPCell(pTableEmpresaInforImpres1);
        cellTabela3.setBorder(0);

        pTableEmpresaInforImpres5.addCell(cellTabela3);

        PdfPCell cellTabela5 = new PdfPCell(pTableEmpresaInforImpres5);
        cellTabela5.setBorder(0);

        PdfPCell cellTabela6 = new PdfPCell(imageEmpresa);
        cellTabela6.setBorder(0);
        pTableEmpresaPricipal.setWidthPercentage(97);
        pTableEmpresaPricipal.addCell(cellTabela6);
        pTableEmpresaPricipal.addCell(cellTabela5);

        Document documento = new Document(PageSize.A4.rotate());
        PdfWriter writer = PdfWriter.getInstance(documento, outputStraem);

        //Table Principal
        PdfPTable pTableTitile = new PdfPTable(new float[] { 100 });
        PdfPTable pTableTablePrincipal = new PdfPTable(
                new float[] { 16.875f, 11.875f, 11.875f, 11.875f, 11.875f, 11.875f, 11.875f, 11.875f });
        pTableTablePrincipal.setWidthPercentage(100f);

        PdfPCell pCellTable = new PdfPCell(new Phrase("Categoria".toUpperCase(), fontCorpoTitile));
        pCellTable.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
        pCellTable.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
        pTableTablePrincipal.addCell(pCellTable);

        //Table principal
        PdfPTable tableCell;
        for (int i = 1; i <= 7; i++) {
            tableCell = new PdfPTable(new float[] { 100 });

            pCellTable = new PdfPCell(new Phrase("NIVEL", fontCorpoTitile));
            pCellTable.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
            tableCell.addCell(pCellTable);

            pCellTable = new PdfPCell(new Phrase(i + "", fontCorpoTitile));
            pCellTable.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
            tableCell.addCell(pCellTable);

            pTableTablePrincipal.addCell(tableCell);
        }

        de = getList();

        for (DadosEstrutura de1 : de) {
            pCellTable = new PdfPCell(new Phrase(de1.categoria, fontCorpoN));
            pCellTable.setHorizontalAlignment(PdfPCell.ALIGN_LEFT);
            pTableTablePrincipal.addCell(pCellTable);

            pCellTable = new PdfPCell(new Phrase(de1.set1, fontCorpo));
            pCellTable.setHorizontalAlignment(PdfPCell.ALIGN_RIGHT);
            pTableTablePrincipal.addCell(pCellTable);

            pCellTable = new PdfPCell(new Phrase(de1.set2, fontCorpo));
            pCellTable.setHorizontalAlignment(PdfPCell.ALIGN_RIGHT);
            pTableTablePrincipal.addCell(pCellTable);

            pCellTable = new PdfPCell(new Phrase(de1.set3, fontCorpo));
            pCellTable.setHorizontalAlignment(PdfPCell.ALIGN_RIGHT);
            pTableTablePrincipal.addCell(pCellTable);

            pCellTable = new PdfPCell(new Phrase(de1.set4, fontCorpo));
            pCellTable.setHorizontalAlignment(PdfPCell.ALIGN_RIGHT);
            pTableTablePrincipal.addCell(pCellTable);

            pCellTable = new PdfPCell(new Phrase(de1.set5, fontCorpo));
            pCellTable.setHorizontalAlignment(PdfPCell.ALIGN_RIGHT);
            pTableTablePrincipal.addCell(pCellTable);

            pCellTable = new PdfPCell(new Phrase(de1.set6, fontCorpo));
            pCellTable.setHorizontalAlignment(PdfPCell.ALIGN_RIGHT);
            pTableTablePrincipal.addCell(pCellTable);

            pCellTable = new PdfPCell(new Phrase(de1.set7, fontCorpo));
            pCellTable.setHorizontalAlignment(PdfPCell.ALIGN_RIGHT);
            pTableTablePrincipal.addCell(pCellTable);
        }

        //Titulo de Table
        pCellTable = new PdfPCell(new Phrase("Estrutura de salrio Grosso".toUpperCase(), fontCorpoNG));
        pCellTable.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
        pCellTable.setBorder(PdfPCell.NO_BORDER);
        pCellTable.setPadding(15f);
        pTableTitile.addCell(pCellTable);

        pCellTable = new PdfPCell(new Phrase("Mensal".toUpperCase(), fontCorpoNG));
        pCellTable.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
        pCellTable.setBorder(PdfPCell.NO_BORDER);
        pTableTitile.addCell(pCellTable);

        @SuppressWarnings("UnusedAssignment")
        PdfPTable pTableInf = null;
        PdfPTable pTableInfTile = new PdfPTable(new float[] { 6, 18.5f, 18.5f, 18.5f, 18f, 20f });
        PdfPTable pTableInfReal = new PdfPTable(new float[] { 100f });
        pTableInfTile.setWidthPercentage(95f);
        pTableInfReal.setWidthPercentage(95f);

        pTableInfTile.setHorizontalAlignment(PdfPTable.ALIGN_CENTER);
        pTableInfReal.setHorizontalAlignment(PdfPTable.ALIGN_CENTER);

        pCellTable = new PdfPCell(new Phrase("NIVEL", fontCorpoN));
        pCellTable.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
        pCellTable.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
        pTableInfTile.addCell(pCellTable);

        pCellTable = new PdfPCell(new Phrase("SAL?RIO BASE", fontCorpoN));
        pCellTable.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
        pCellTable.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
        pTableInfTile.addCell(pCellTable);

        pCellTable = new PdfPCell(new Phrase("SUBSIDIO ALMOO", fontCorpoN));
        pCellTable.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
        pCellTable.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
        pTableInfTile.addCell(pCellTable);

        pCellTable = new PdfPCell(new Phrase("SUBSIDIO ALOGAMENTO", fontCorpoN));
        pCellTable.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
        pCellTable.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
        pTableInfTile.addCell(pCellTable);

        pCellTable = new PdfPCell(new Phrase("SUBSIDIO TRANSPORTE", fontCorpoN));
        pCellTable.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
        pCellTable.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
        pTableInfTile.addCell(pCellTable);

        pCellTable = new PdfPCell(new Phrase("TOTAL", fontCorpoN));
        pCellTable.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
        pCellTable.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
        pTableInfTile.addCell(pCellTable);

        HashMap<String, ArrayList<Categoria>> outherAr = GrossSarary.getCatList();
        int si = outherAr.size(), i = 0;
        for (Map.Entry<String, ArrayList<Categoria>> eSet : outherAr.entrySet()) {

            pTableInf = new PdfPTable(new float[] { 6, 18.5f, 18.5f, 18.5f, 18f, 20f });
            pTableInf.setWidthPercentage(95f);
            pTableInf.setHorizontalAlignment(PdfPTable.ALIGN_CENTER);

            pCellTable = new PdfPCell(new Phrase(eSet.getKey(), fontCorpoNG));
            pCellTable.setHorizontalAlignment(PdfPCell.ALIGN_LEFT);
            pCellTable.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
            pCellTable.setBorder(PdfPCell.NO_BORDER);
            pCellTable.setColspan(6);
            pTableInf.addCell(pCellTable);

            pCellTable = new PdfPCell(new Phrase(" ", fontCorpoN));
            pCellTable.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
            pCellTable.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
            pCellTable.setColspan(6);
            pCellTable.setBorder(PdfPCell.NO_BORDER);
            pTableInf.addCell(pCellTable);

            pCellTable = new PdfPCell(pTableInfTile);
            pCellTable.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
            pCellTable.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
            pCellTable.setColspan(6);
            pCellTable.setBorder(PdfPCell.NO_BORDER);
            pTableInf.addCell(pCellTable);

            for (Categoria ca : eSet.getValue()) {
                pCellTable = new PdfPCell(new Phrase(ca.nivel, fontCorpo));
                pCellTable.setHorizontalAlignment(PdfPCell.ALIGN_LEFT);
                pCellTable.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
                pTableInf.addCell(pCellTable);

                pCellTable = new PdfPCell(new Phrase(toConverterToMoeda(ca.salarioBase), fontCorpo));
                pCellTable.setHorizontalAlignment(PdfPCell.ALIGN_RIGHT);
                pCellTable.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
                pCellTable.setPaddingRight(10f);
                pTableInf.addCell(pCellTable);

                pCellTable = new PdfPCell(new Phrase(toConverterToMoeda(ca.subsidioAlmoco), fontCorpo));
                pCellTable.setHorizontalAlignment(PdfPCell.ALIGN_RIGHT);
                pCellTable.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
                pCellTable.setPaddingRight(10f);
                pTableInf.addCell(pCellTable);

                pCellTable = new PdfPCell(new Phrase(toConverterToMoeda(ca.subsidioAlogamento), fontCorpo));
                pCellTable.setHorizontalAlignment(PdfPCell.ALIGN_RIGHT);
                pCellTable.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
                pCellTable.setPaddingRight(10f);
                pTableInf.addCell(pCellTable);

                pCellTable = new PdfPCell(new Phrase(toConverterToMoeda(ca.subsidioTransporte), fontCorpo));
                pCellTable.setHorizontalAlignment(PdfPCell.ALIGN_RIGHT);
                pCellTable.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
                pCellTable.setPaddingRight(10f);
                pTableInf.addCell(pCellTable);

                pCellTable = new PdfPCell(new Phrase(toConverterToMoeda(ca.total), fontCorpo));
                pCellTable.setHorizontalAlignment(PdfPCell.ALIGN_RIGHT);
                pCellTable.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
                pCellTable.setPaddingRight(10f);
                pTableInf.addCell(pCellTable);
            }

            pCellTable = new PdfPCell(new Phrase(" ", fontCorpoN));
            pCellTable.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
            pCellTable.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
            pCellTable.setBorder(PdfPCell.NO_BORDER);
            pCellTable.setColspan(6);

            i++;
            if (si == i) {
                pTableInf.addCell(pCellTable);
                pTableInf.addCell(pCellTable);
                pTableInf.addCell(pCellTable);
            }

            pCellTable = new PdfPCell(pTableInf);
            pCellTable.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
            pCellTable.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
            pCellTable.setBorder(PdfPCell.NO_BORDER);
            pTableInfReal.addCell(pCellTable);

        }

        documento.open();
        documento.add(pTableEmpresaPricipal);
        documento.add(pTableNull);
        documento.add(pTableTitile);
        documento.add(pTableNull);
        documento.add(pTableTablePrincipal);
        //                documento.add(pTableNull);
        documento.newPage();
        documento.add(pTableInfReal);
        documento.close();

        RequestContext.getCurrentInstance().execute("openAllDocument('" + reString + "')");

    } catch (FileNotFoundException ex) {
        Logger.getLogger(GrossSarary.class.getName()).log(Level.SEVERE, null, ex);
    } catch (BadElementException | IOException ex) {
        Logger.getLogger(GrossSarary.class.getName()).log(Level.SEVERE, null, ex);
    } catch (DocumentException ex) {
        Logger.getLogger(GrossSarary.class.getName()).log(Level.SEVERE, null, ex);
    }
}

From source file: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 {//from   www .j a va2 s .com
        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.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 . j a  v  a  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.SeguroViagem.java

public String criarDoc(ViagemBean vb, String numCriente, String user, String arquivo, Contrato c) {
    try {/*from w  ww . ja v a  2  s  .  com*/
        PdfPTable pTablePrincaipal;
        //            PdfPTable pTableSegu1;
        PdfPTable pTableSegu2;
        SimpleDateFormat sdf = new SimpleDateFormat("dd-MM-yyyy hh'.'mm'.'ss");
        SimpleDateFormat sdfPot = new SimpleDateFormat("dd/MM/yyyy");

        Font fontCorpoN = FontFactory.getFont(Fontes.FONTB, BaseFont.WINANSI, BaseFont.EMBEDDED, 7.9f);
        Font fontCorpo = FontFactory.getFont(Fontes.FONT, BaseFont.WINANSI, BaseFont.EMBEDDED, 7.9f);

        //            PdfPTable pTableLinha = new PdfPTable(1);
        //            pTableLinha.setWidthPercentage(95);
        //            PdfPCell linha= new PdfPCell(new Phrase(" "));
        //            
        //            linha.setBorderWidthTop(0.5f);
        //            linha.setBorderWidthBottom(0);
        //            linha.setBorderWidthLeft(0);
        //            linha.setBorderWidthRight(0);
        //            pTableLinha.addCell(linha);
        Document documento = new Document();
        documento.setPageSize(PageSize.A4);
        documento.setMargins(20f, 20f, 138f, 5f);
        File ff = new File(arquivo + "/" + user + "/Seguro Viagem/");
        ff.mkdirs();
        String Ddata = sdf.format(new Date());
        ff = new File(ff.getAbsoluteFile() + "/" + "Doc Seguro Viagem " + Ddata + ".pdf");
        reString = "../Documentos/" + user + "/Seguro Viagem/" + "Doc Seguro Viagem " + Ddata + ".pdf";
        outputStraem = new FileOutputStream(ff);
        PdfWriter writer = PdfWriter.getInstance(documento, outputStraem);

        if (MarcaDAgua.isSimulation) {
            MarcaDAgua.SimulacaoVertical v = new MarcaDAgua.SimulacaoVertical();
            writer.setPageEvent(v);
        }

        if (MarcaDAgua.isCanceled) {
            MarcaDAgua.AnulacaoVertical v = new MarcaDAgua.AnulacaoVertical();
            writer.setPageEvent(v);
        }

        documento.open();

        int total = vb.getInfoPessoaSegurada().size();
        for (int i = 0; i < total; i++) {

            pTablePrincaipal = new PdfPTable(1);
            pTablePrincaipal.setWidthPercentage(98f);
            //                pTableSegu1 = new PdfPTable(1);
            //                pTableSegu1.setWidthPercentage(95);
            pTableSegu2 = new PdfPTable(new float[] { 55f, 45f });
            pTableSegu2.setWidthPercentage(100f);

            //                PdfPCell cellTitulo= new PdfPCell(new Phrase("Lista Pessoas Seguradas",fontCabecalhoN));
            //                cellTitulo.setBorder(0);
            PdfPCell cellNull = new PdfPCell(new Phrase(" ", fontCorpo));
            cellNull.setBorder(0);

            //                if(((i)%6)==0)
            //                {
            //                    pTableSegu1.addCell(cellTitulo);
            //                    pTableSegu1.addCell(cellNull);
            //                }
            //                
            Paragraph pCl = new Paragraph();
            pCl.add(new Phrase("Nome do Segurado: ".toUpperCase(), fontCorpo));
            pCl.add(new Phrase(vb.getInfoPessoaSegurada().get(i).getNomePessoaSegurada().toUpperCase(),
                    fontCorpoN));
            PdfPCell cellNome = new PdfPCell(pCl);
            cellNome.setColspan(2);
            cellNome.setBorder(0);
            pTableSegu2.addCell(cellNome);

            //                PdfPCell cellNum= new PdfPCell(new Phrase(""+(i+1),fontCorpo));
            //                cellNum.setBorder(0);
            //                cellNum.setHorizontalAlignment(Element.ALIGN_RIGHT);
            //                pTableSegu2.addCell(cellNum);
            pCl = new Paragraph();
            pCl.add(new Phrase("Endereo: ".toUpperCase(), fontCorpo));
            pCl.add(new Phrase(vb.getInfoPessoaSegurada().get(i).getEndereco().toUpperCase(), fontCorpoN));
            PdfPCell cellEndereco = new PdfPCell(pCl);
            cellEndereco.setBorder(0);
            pTableSegu2.addCell(cellEndereco);
            pTableSegu2.addCell(cellNull);

            pCl = new Paragraph();
            pCl.add(new Phrase("Data e Local Nascimento: ".toUpperCase(), fontCorpo));
            pCl.add(new Phrase(vb.getInfoPessoaSegurada().get(i).getDataNascFormatada(), fontCorpoN));
            pCl.add(new Phrase(" em ", fontCorpo));
            pCl.add(new Phrase(vb.getInfoPessoaSegurada().get(i).getLocalNascimento(), fontCorpoN));
            PdfPCell cellNascDaNascloc = new PdfPCell(pCl);
            cellNascDaNascloc.setBorder(0);

            pCl = new Paragraph();
            pCl.add(new Phrase("Sexo: ".toUpperCase(), fontCorpo));
            pCl.add(new Phrase(vb.getInfoPessoaSegurada().get(i).getSexo(), fontCorpoN));
            pCl.add(new Phrase("   Tel.N ", fontCorpo));
            pCl.add(new Phrase(vb.getInfoPessoaSegurada().get(i).getTelefone(), fontCorpoN));
            PdfPCell cellSexo = new PdfPCell(pCl);
            cellSexo.setBorder(0);
            pTableSegu2.addCell(cellNascDaNascloc);
            pTableSegu2.addCell(cellSexo);

            pCl = new Paragraph();
            pCl.add(new Phrase("Apolice: ".toUpperCase(), fontCorpo));
            pCl.add(new Phrase(vb.getInfoPessoaSegurada().get(i).getNumApolice(), fontCorpoN));
            PdfPCell cellApolice = new PdfPCell(pCl);
            cellApolice.setBorder(0);

            pCl = new Paragraph();
            pCl.add(new Phrase("Cliente: ".toUpperCase(), fontCorpo));

            String[] codCliente = vb.getInfoPessoaSegurada().get(i).getNumApolice().split("/");

            pCl.add(new Phrase(((codCliente.length == 2) ? "TIN " + codCliente[1] : "TIN "), fontCorpoN));
            PdfPCell cellCliente = new PdfPCell(pCl);
            cellCliente.setBorder(0);
            pTableSegu2.addCell(cellApolice);
            pTableSegu2.addCell(cellCliente);

            pCl = new Paragraph();
            pCl.add(new Phrase("Durao: ".toUpperCase(), fontCorpo));
            pCl.add(new Phrase(vb.getInfoPessoaSegurada().get(i).getNumDias() + " DIAS", fontCorpoN));
            PdfPCell cellDuracao = new PdfPCell(pCl);
            cellDuracao.setBorder(0);

            pCl = new Paragraph();
            pCl.add(new Phrase("Perodo: de ".toUpperCase(), fontCorpo));
            pCl.add(new Phrase(sdfPot.format(vb.getInfoPessoaSegurada().get(i).getDataInicio()), fontCorpoN));
            pCl.add(new Phrase("  ", fontCorpo));
            pCl.add(new Phrase(((vb.getInfoPessoaSegurada().get(i).getDataFim() != null)
                    ? sdfPot.format(vb.getInfoPessoaSegurada().get(i).getDataFim())
                    : " "), fontCorpoN));
            PdfPCell cellPeriodo = new PdfPCell(pCl);
            cellPeriodo.setBorder(0);
            pTableSegu2.addCell(cellDuracao);
            pTableSegu2.addCell(cellPeriodo);

            pCl = new Paragraph();
            pCl.add(new Phrase("Data de Emisso: ".toUpperCase(), fontCorpo));
            pCl.add(new Phrase(sdfPot.format(c.getDataContrato()), fontCorpoN));
            PdfPCell cellDataEmissao = new PdfPCell(pCl);
            cellDataEmissao.setBorder(0);

            pCl = new Paragraph();
            pCl.add(new Phrase("Destino: ".toUpperCase(), fontCorpo));
            pCl.add(new Phrase(
                    ClienteDao.paisesSelected(vb.getInfoPessoaSegurada().get(i).getPaisDestino().toUpperCase())
                            + "    ",
                    fontCorpoN));
            pCl.add(new Phrase("N de Pessoas: ", fontCorpo));
            pCl.add(new Phrase((i + 1) + "", fontCorpoN));
            PdfPCell cellDestino = new PdfPCell(pCl);
            cellDestino.setBorder(0);
            pTableSegu2.addCell(cellDataEmissao);
            pTableSegu2.addCell(cellDestino);

            pCl = new Paragraph();
            pCl.add(new Phrase("Meio de Identificao: ".toUpperCase(), fontCorpo));
            pCl.add(new Phrase(
                    ((vb.getInfoPessoaSegurada().get(i).getTipoDoc().toUpperCase().equals("PASSAPORTE"))
                            ? "PASS"
                            : (vb.getInfoPessoaSegurada().get(i).getTipoDoc().toUpperCase()
                                    .equals("BILHETE IDENTIDADE") ? "BI"
                                            : vb.getInfoPessoaSegurada().get(i).getTipoDoc().toUpperCase())),
                    fontCorpoN));
            pCl.add(new Phrase("   N ", fontCorpo));
            pCl.add(new Phrase(vb.getInfoPessoaSegurada().get(i).getNumDoc(), fontCorpoN));
            PdfPCell cellEmiDocNum = new PdfPCell(pCl);
            cellEmiDocNum.setBorder(0);

            pCl = new Paragraph();
            pCl.add(new Phrase("Emitido em: ".toUpperCase(), fontCorpo));
            pCl.add(new Phrase(vb.getInfoPessoaSegurada().get(i).getLocalEmissao().toUpperCase() + " ",
                    fontCorpoN));
            pCl.add(new Phrase("em ", fontCorpo));
            pCl.add(new Phrase(vb.getInfoPessoaSegurada().get(i).getDataEmissaoFormatada(), fontCorpoN));
            PdfPCell cellEmiDoc = new PdfPCell(pCl);
            cellEmiDoc.setBorder(0);
            pTableSegu2.addCell(cellEmiDocNum);
            pTableSegu2.addCell(cellEmiDoc);

            pCl = new Paragraph();
            pCl.add(new Phrase("Outras Informaes: ".toUpperCase(), fontCorpo));
            pCl.add(new Phrase(
                    ((vb.getInfoPessoaSegurada().get(i).getOutrasInformacoes() == null) ? " "
                            : vb.getInfoPessoaSegurada().get(i).getOutrasInformacoes().toUpperCase()),
                    fontCorpoN));
            PdfPCell cellOutraInf = new PdfPCell(pCl);
            cellOutraInf.setColspan(2);
            cellOutraInf.setBorder(0);
            pTableSegu2.addCell(cellOutraInf);

            //                PdfPCell cellSegui1 = new PdfPCell();
            //                cellSegui1.addElement(pTableSegu1);
            //                cellSegui1.setBorder(0);
            PdfPCell cellSegui2 = new PdfPCell();
            cellSegui2.addElement(pTableSegu2);
            cellSegui2.setBorder(0);

            //                PdfPCell cellSeguiT = new PdfPCell();
            //                cellSeguiT.addElement(pTableLinha);
            //                cellSeguiT.setBorder(0);
            //                pTablePrincaipal.addCell(cellSegui1);
            pTablePrincaipal.addCell(cellSegui2);

            //                if((i+1)<total&&((i+1)%6)!=0)
            //                    pTablePrincaipal.addCell(cellSeguiT);
            //                
            documento.add(pTablePrincaipal);
            //                
            //                System.err.println((((i+1)%6)==0)+" "+(i+1));
            if ((i + 1) != total) {
                documento.newPage();
            }

        }

        documento.close();
        return reString;

    } catch (DocumentException | IOException ex) {
        Logger.getLogger(SeguroViagem.class.getName()).log(Level.SEVERE, null, ex);
        return reString;
    }
}

From source file:Export.TableOfSalary.java

public static void ciarDoc(String user, String idProcesso, String data) {
    FileOutputStream outputStraem;
    try {//from   w w  w . j a v a 2  s  .  com
        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);
    }
}