Example usage for com.itextpdf.text.pdf PdfPTable setWidthPercentage

List of usage examples for com.itextpdf.text.pdf PdfPTable setWidthPercentage

Introduction

In this page you can find the example usage for com.itextpdf.text.pdf PdfPTable setWidthPercentage.

Prototype

public void setWidthPercentage(final float widthPercentage) 

Source Link

Document

Sets the width percentage that the table will occupy in the page.

Usage

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 a 2s.  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.FuncPagamento.java

private String folhaPagamento(String numPagamento, String user, String nomeUser, int j)
        throws NumberFormatException {
    try {/* w  w  w.j  a  va2  s  .  c  o  m*/

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

        Font fontCabecalhoN = FontFactory.getFont(ConfigDoc.Fontes.FONTB, BaseFont.WINANSI, BaseFont.EMBEDDED,
                9.5f);
        Font fontCorpo = FontFactory.getFont(ConfigDoc.Fontes.FONT, BaseFont.WINANSI, BaseFont.EMBEDDED, 9f);
        Font fontCorpoP = FontFactory.getFont(ConfigDoc.Fontes.FONT, BaseFont.WINANSI, BaseFont.EMBEDDED, 8f);
        Font fontCorpoN = FontFactory.getFont(ConfigDoc.Fontes.FONTB, BaseFont.WINANSI, BaseFont.EMBEDDED, 9f);
        Font fontCorpoNU = FontFactory.getFont(ConfigDoc.Fontes.FONTB, BaseFont.WINANSI, BaseFont.EMBEDDED, 9f,
                Font.UNDERLINE);
        Font fontCorpoNG = FontFactory.getFont(ConfigDoc.Fontes.FONTB, BaseFont.WINANSI, BaseFont.EMBEDDED,
                11.5f);
        Font fontCorpoNGT = FontFactory.getFont(ConfigDoc.Fontes.FONTB, BaseFont.WINANSI, BaseFont.EMBEDDED,
                13f, Font.UNDERLINE);
        Font fontCabecalhoNG = FontFactory.getFont(ConfigDoc.Fontes.FONTB, BaseFont.WINANSI, BaseFont.EMBEDDED,
                16f, Font.UNDERLINE);

        ArrayList<HashMap<String, Object>> mapList = getObj(numPagamento);

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

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

        int size = mapList.size(), i = 0;

        File ff = new File(ConfigDoc.Fontes.getDiretorio() + "/" + user + "/Pagamentos/");

        ff.mkdirs();
        ff = new File(ff.getAbsoluteFile() + "/" + "Pagamentos Func " + Ddata + ".pdf");

        OutputStream outputStraem = new FileOutputStream(ff);
        PdfWriter writer = PdfWriter.getInstance(documento, outputStraem);

        MyFooter event = new MyFooter();
        writer.setPageEvent(event);

        documento.open();

        for (HashMap<String, Object> hashMap : mapList) {
            i++;

            PdfPTable pTableEmpresaPricipal = new PdfPTable(new float[] { 25f, 75f });
            pTableEmpresaPricipal.setWidthPercentage(90);
            PdfPTable pTableEmpresaInforImpres1 = new PdfPTable(1);
            PdfPTable pTableEmpresaInforImpres5 = new PdfPTable(1);

            PdfPTable pTableNull = new PdfPTable(1);
            PdfPCell cellNull = new PdfPCell(new Phrase(" ", fontCorpoP));
            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.addCell(cellTabela6);
            pTableEmpresaPricipal.addCell(cellTabela5);

            documento.add(pTableEmpresaPricipal);

            documento.add(pTableNull);
            documento.add(pTableNull);

            PdfPTable pTableTitulo = new PdfPTable(new float[] { 50, 50 });
            pTableTitulo.setWidthPercentage(90f);
            PdfPCell cellTitulo = new PdfPCell(new Phrase("Comprovativo de Pagamento", fontCorpoNGT));
            cellTitulo.setBorder(0);
            cellTitulo.setHorizontalAlignment(Element.ALIGN_RIGHT);
            cellTitulo.setPaddingRight(-80f);
            cellTitulo.setPaddingTop(-26f);
            pTableTitulo.addCell(cellTitulo);
            cellTitulo = new PdfPCell(new Phrase("N: " + hashMap.get(PAGAMENTO), fontCorpoNGT));
            cellTitulo.setHorizontalAlignment(Element.ALIGN_RIGHT);
            cellTitulo.setBorder(0);
            cellTitulo.setPaddingBottom(5f);
            pTableTitulo.addCell(cellTitulo);

            documento.add(pTableTitulo);

            PdfPTable pTableAno = new PdfPTable(new float[] { 100 });
            pTableAno.setWidthPercentage(90f);
            PdfPCell cellAno = new PdfPCell(new Phrase(toData(hashMap.get(REGISTRO), j), fontCorpoNGT));
            cellAno.setBorder(0);
            cellAno.setPaddingBottom(20f);
            pTableAno.addCell(cellAno);

            documento.add(pTableAno);

            PdfPTable pTableDetalhesPagamento = new PdfPTable(new float[] { 100 });
            pTableDetalhesPagamento.setWidthPercentage(90f);
            PdfPCell cellDetalhesPagamento = new PdfPCell();

            Paragraph pDetalhesPagamento = new Paragraph();
            pDetalhesPagamento.add(new Paragraph("\nDetalhes de Pagamento ", fontCorpoNG));

            pDetalhesPagamento.add(new Phrase("Beneficirio: ", fontCorpoN));
            pDetalhesPagamento.add(new Phrase(toString(hashMap.get(BENEFICIARIO)) + "\n", fontCorpo));
            pDetalhesPagamento.add(new Phrase("Descrio do pagamento: ", fontCorpoN));
            pDetalhesPagamento.add(new Phrase(toString(hashMap.get(DESCRICAOPAGAMENTO)), fontCorpo));
            pDetalhesPagamento.add(new Paragraph("CONFORME APROVADO\n\n", fontCorpoN));

            pDetalhesPagamento.add(new Paragraph("Valor Pagamento", fontCorpoNG));
            pDetalhesPagamento.add(new Phrase("Valor Numerico: ", fontCorpoN));
            pDetalhesPagamento.add(new Phrase(
                    toMoeda(hashMap.get(VALORPAGAMENTO), toString(hashMap.get(SIGLA))) + "\n", fontCorpo));
            System.err.println(toString(hashMap.get(RETENCAOFONTE)) + " hfhfh retensao");
            if (toString(hashMap.get(RETENCAOFONTE)).trim().equals("1")) {
                double ret = getValorImportRetensao();
                pDetalhesPagamento.add(new Phrase("Valor Retensao Fonte: ", fontCorpoN));
                pDetalhesPagamento.add(new Phrase(toMoeda(ret, "%") + "\n", fontCorpo));
                pDetalhesPagamento.add(new Phrase("Valor Retido: ", fontCorpoN));
                double valret = toDouble(hashMap.get(VALORPAGAMENTO)) * ret;
                pDetalhesPagamento
                        .add(new Phrase(toMoeda(valret, toString(hashMap.get(SIGLA))) + "\n", fontCorpo));
            }

            JTextPane jtp = new JTextPane();
            Double valor = Double.valueOf((hashMap.get(VALORPAGAMENTO) + ""));
            Moeda.EscreverEstenso(valor, jtp, toString(hashMap.get(MOEDA)));

            pDetalhesPagamento.add(new Phrase("Valor por Extenso: ", fontCorpoN));
            pDetalhesPagamento.add(new Phrase(jtp.getText().trim() + " \n\n", fontCorpo));

            pDetalhesPagamento.add(new Paragraph("Descrio da Conta", fontCorpoNG));
            pDetalhesPagamento.add(new Phrase("Cod Conta: ", fontCorpoN));
            pDetalhesPagamento.add(new Phrase(hashMap.get(CODIGOCONTAPAGAMENTO) + "\n", fontCorpo));
            pDetalhesPagamento.add(new Phrase("Titulo da Conta: ", fontCorpoN));
            pDetalhesPagamento.add(new Phrase(hashMap.get(TITULOCONTAPAGAMENTO) + "\n", fontCorpo));

            /**
             * For alter
             */
            pDetalhesPagamento.add(new Phrase("Forma de Pagamento: ", fontCorpoN));
            pDetalhesPagamento.add(new Phrase(hashMap.get(FORMAPAGAMENTO) + " \n", fontCorpo));
            pDetalhesPagamento.add(new Phrase("Documento de Pagamento: ", fontCorpoN));
            pDetalhesPagamento.add(new Phrase(toString(hashMap.get(DESCRICAOCONTABANCO)) + " - "
                    + toString(hashMap.get(DOCFORMAPAGAMENTO)) + "\n\n", fontCorpo));
            pDetalhesPagamento.add(new Paragraph(" ", fontCorpoN));

            cellDetalhesPagamento.addElement(pDetalhesPagamento);
            pTableDetalhesPagamento.addCell(cellDetalhesPagamento);

            cellDetalhesPagamento = new PdfPCell();
            pDetalhesPagamento = new Paragraph();

            pDetalhesPagamento.add(new Paragraph(" ", fontCorpo));
            pDetalhesPagamento.add(new Phrase("Preparado por: ", fontCorpoN));
            pDetalhesPagamento.add(new Phrase(nomeUser + " ", fontCorpoP));
            pDetalhesPagamento.add(new Phrase("            Examinado por", fontCorpoN));
            pDetalhesPagamento.add(new Phrase("____________________\n", fontCorpo));

            pDetalhesPagamento.add(new Paragraph(" ", fontCorpoN));
            pDetalhesPagamento.add(new Paragraph("Pagamento Autorizado por:", fontCorpoNG));

            pDetalhesPagamento.add(new Paragraph(" ", fontCorpoN));
            pDetalhesPagamento.add(new Phrase("Assinatura: ", fontCorpoN));
            pDetalhesPagamento.add(new Phrase(" ____________________________________________", fontCorpo));
            pDetalhesPagamento.add(new Phrase("    Data ", fontCorpoN));
            pDetalhesPagamento.add(new Phrase(" ______________________\n\n", fontCorpo));

            pDetalhesPagamento.add(new Phrase("Assinatura: ", fontCorpoN));
            pDetalhesPagamento.add(new Phrase(" ____________________________________________", fontCorpo));
            pDetalhesPagamento.add(new Phrase("    Data ", fontCorpoN));
            pDetalhesPagamento.add(new Phrase(" ______________________\n", fontCorpo));

            pDetalhesPagamento.add(new Paragraph(" ", fontCorpo));
            pDetalhesPagamento.add(new Paragraph(
                    "............................................................................."
                            + "...........................................................................",
                    fontCorpoN));

            pDetalhesPagamento.add(new Paragraph(" ", fontCorpo));
            Paragraph pReceip = new Paragraph("RECIBO", fontCorpoN);
            pReceip.setAlignment(Element.ALIGN_CENTER);
            pDetalhesPagamento.add(pReceip);

            pDetalhesPagamento.add(new Paragraph(" ", fontCorpo));
            pDetalhesPagamento.add(new Phrase("Recebi o valor de: ", fontCorpo));
            pDetalhesPagamento.add(new Phrase(jtp.getText() + " \n", fontCorpoNU));

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

            PdfPTable pTableNumCheque = new PdfPTable(
                    new float[] { 33.3333333333f, 33.3333333333f, 33.3333333333f });
            pTableNumCheque.setWidthPercentage(90f);
            pTableNumCheque.setWidthPercentage(100f);

            PdfPCell cellNumCheque = new PdfPCell(new Phrase("_______________________", fontCorpo));
            cellNumCheque.setBorder(0);
            cellNumCheque.setHorizontalAlignment(Element.ALIGN_CENTER);
            pTableNumCheque.addCell(cellNumCheque);
            cellNumCheque = new PdfPCell(new Phrase("_______________________", fontCorpo));
            cellNumCheque.setBorder(0);
            cellNumCheque.setHorizontalAlignment(Element.ALIGN_CENTER);
            pTableNumCheque.addCell(cellNumCheque);
            cellNumCheque = new PdfPCell(new Phrase("_______________________", fontCorpo));
            cellNumCheque.setBorder(0);
            cellNumCheque.setHorizontalAlignment(Element.ALIGN_CENTER);
            pTableNumCheque.addCell(cellNumCheque);

            cellNumCheque = new PdfPCell(new Phrase("Cheque No.", fontCorpoN));
            cellNumCheque.setBorder(0);
            cellNumCheque.setHorizontalAlignment(Element.ALIGN_CENTER);
            pTableNumCheque.addCell(cellNumCheque);
            cellNumCheque = new PdfPCell(new Phrase("Data", fontCorpoN));
            cellNumCheque.setBorder(0);
            cellNumCheque.setHorizontalAlignment(Element.ALIGN_CENTER);
            pTableNumCheque.addCell(cellNumCheque);
            cellNumCheque = new PdfPCell(new Phrase("Receiver Name & Signature", fontCorpoN));
            cellNumCheque.setBorder(0);
            cellNumCheque.setHorizontalAlignment(Element.ALIGN_CENTER);
            pTableNumCheque.addCell(cellNumCheque);

            pDetalhesPagamento.add(pTableNumCheque);

            pDetalhesPagamento.add(new Phrase(
                    "\nNOTA: Um recibo oficial pode ser obtido por um pagamento e informado na parte inversa deste comprovativo. \n\n",
                    fontCorpo));

            cellDetalhesPagamento.addElement(pDetalhesPagamento);

            pTableDetalhesPagamento.addCell(cellDetalhesPagamento);

            documento.add(pTableDetalhesPagamento);

            if (i != size) {
                documento.newPage();
            }
        }

        documento.close();

        reString = "../Documentos/" + user + "/Pagamentos/" + "Pagamentos Func " + Ddata + ".pdf";
        return reString;
    } catch (BadElementException | IOException ex) {
        Logger.getLogger(FuncPagamento.class.getName()).log(Level.SEVERE, null, ex);
    } catch (DocumentException ex) {
        Logger.getLogger(FuncPagamento.class.getName()).log(Level.SEVERE, null, ex);
    }
    return reString;
}

From source file:Export.FuncPagamento.java

private String pequenoPagamento(String numPagamento, String user, String nomeUser, int i) {
    OutputStream outputStraem;/*  w  w  w .ja v  a 2 s. c  o  m*/
    try {
        SimpleDateFormat sdf = new SimpleDateFormat("MMMM yyyy - dd", new Locale("pt", "BR"));
        SimpleDateFormat sdf3 = new SimpleDateFormat("dd-MM-yyyy");
        SimpleDateFormat sdf2 = new SimpleDateFormat("dd 'de' MMMM 'de' yyyy", new Locale("pt", "BR"));
        SimpleDateFormat sdf1 = new SimpleDateFormat("dd-MM-yyyy hh'.'mm'.'ss");

        Font fontCabecalhoN = FontFactory.getFont(ConfigDoc.Fontes.FONT, BaseFont.WINANSI, BaseFont.EMBEDDED,
                14f);
        Font fontCorpo = FontFactory.getFont(ConfigDoc.Fontes.FONT, BaseFont.WINANSI, BaseFont.EMBEDDED, 8.5f);
        Font fontCorpoU = FontFactory.getFont(ConfigDoc.Fontes.FONT, BaseFont.WINANSI, BaseFont.EMBEDDED, 9f,
                Font.UNDERLINE);
        //            Font fontCorpoP= FontFactory.getFont(ConfigDoc.Fontes.FONT, BaseFont.WINANSI, BaseFont.EMBEDDED ,8f );
        Font fontCorpoN = FontFactory.getFont(ConfigDoc.Fontes.FONTB, BaseFont.WINANSI, BaseFont.EMBEDDED, 9f);
        Font fontCorpoNG = FontFactory.getFont(ConfigDoc.Fontes.FONTB, BaseFont.WINANSI, BaseFont.EMBEDDED,
                8.5f);
        //            Font fontCorpoNGT= FontFactory.getFont(ConfigDoc.Fontes.FONTB, BaseFont.WINANSI, BaseFont.EMBEDDED , 13f ,Font.UNDERLINE);
        Font fontCabecalhoNG = FontFactory.getFont(ConfigDoc.Fontes.FONTB, BaseFont.WINANSI, BaseFont.EMBEDDED,
                16f, Font.UNDERLINE);

        Document documento = new Document();
        documento.setPageSize(PageSize.A4);
        documento.setMargins(20f, 20f, 10f, 5f);
        String Ddata = sdf1.format(new Date());

        ArrayList<HashMap<String, Object>> mapList = getObj(numPagamento);
        int total = mapList.size();

        File ff = new File(ConfigDoc.Fontes.getDiretorio() + "/" + user + "/Pagamentos/");
        ff.mkdirs();
        ff = new File(ff.getAbsoluteFile() + "/" + "Pagamentos Func " + Ddata + ".pdf");

        outputStraem = new FileOutputStream(ff);
        PdfWriter writer = PdfWriter.getInstance(documento, outputStraem);
        MyFooterA5 event = new MyFooterA5();
        writer.setPageEvent(event);

        documento.open();

        PdfPTable pTableTitile = new PdfPTable(new float[] { 100 });
        pTableTitile.setWidthPercentage(95f);
        PdfPCell cellTitile = new PdfPCell();
        cellTitile.setBorder(0);

        Paragraph pTitile = new Paragraph();

        pTitile.add(new Phrase(ConfigDoc.Empresa.NOME.toUpperCase(), fontCabecalhoNG));
        pTitile.setAlignment(Element.ALIGN_CENTER);

        PdfPTable pTableSubTitile = new PdfPTable(new float[] { 80, 20 });
        pTableSubTitile.setWidthPercentage(101f);

        PdfPCell cellSubTitile = new PdfPCell(
                new Phrase("Petty cash voucher no.".toUpperCase(), fontCabecalhoN));
        cellSubTitile.setBorder(0);
        cellSubTitile.setHorizontalAlignment(Element.ALIGN_RIGHT);
        cellSubTitile.setPaddingBottom(20);
        cellSubTitile.setPaddingRight(67);
        cellSubTitile.setPaddingTop(10);
        pTableSubTitile.addCell(cellSubTitile);

        cellSubTitile = new PdfPCell(
                new Phrase(toData((mapList.size() > 0) ? mapList.get(0).get(REGISTRO) : " ", i).toUpperCase(),
                        fontCabecalhoN));
        cellSubTitile.setHorizontalAlignment(Element.ALIGN_LEFT);
        cellSubTitile.setBorder(0);
        cellSubTitile.setPaddingBottom(20);
        cellSubTitile.setPaddingTop(10);
        pTableSubTitile.addCell(cellSubTitile);
        //            pTitile.add(cellSubTitile);

        pTitile.add(pTableSubTitile);

        cellTitile.addElement(pTitile);
        pTableTitile.addCell(cellTitile);

        documento.add(pTableTitile);

        PdfPTable pTableDados = new PdfPTable(new float[] { 5.6f, 6.05f, 53.5f, 17.95f, 19f });
        pTableDados.setWidthPercentage(95f);

        PdfPCell cellDados = new PdfPCell(new Phrase("S/N", fontCorpoNG));
        cellDados.setHorizontalAlignment(Element.ALIGN_CENTER);
        pTableDados.addCell(cellDados);

        cellDados = new PdfPCell(new Phrase("Qty", fontCorpoNG));
        cellDados.setHorizontalAlignment(Element.ALIGN_CENTER);
        pTableDados.addCell(cellDados);

        cellDados = new PdfPCell(new Phrase("Detail Description", fontCorpoNG));
        cellDados.setHorizontalAlignment(Element.ALIGN_CENTER);
        pTableDados.addCell(cellDados);

        cellDados = new PdfPCell(new Phrase("Unit price", fontCorpoNG));
        cellDados.setHorizontalAlignment(Element.ALIGN_CENTER);
        pTableDados.addCell(cellDados);

        cellDados = new PdfPCell(new Phrase("AMT (STD)", fontCorpoNG));
        cellDados.setHorizontalAlignment(Element.ALIGN_CENTER);
        pTableDados.addCell(cellDados);

        Double toPa = 0.0;
        for (int j = 0; j < total; j++) {
            int tLinha = toString(mapList.get(j).get(DESCRICAOPAGAMENTO)).split("\n").length;

            float pad = setPadding(total, tLinha);

            cellDados = new PdfPCell(new Phrase((j + 1) + "", fontCorpo));
            cellDados.setPaddingBottom(pad);
            cellDados.setVerticalAlignment(Element.ALIGN_MIDDLE);
            cellDados.setPaddingTop(pad);
            pTableDados.addCell(cellDados);

            cellDados = new PdfPCell(new Phrase(toInt(mapList.get(j).get(QUANTIDADE)) + "", fontCorpo));
            cellDados.setPaddingBottom(pad);
            cellDados.setVerticalAlignment(Element.ALIGN_MIDDLE);
            cellDados.setPaddingTop(pad);
            pTableDados.addCell(cellDados);

            cellDados = new PdfPCell(new Phrase(toString(mapList.get(j).get(DESCRICAOPAGAMENTO)), fontCorpo));
            cellDados.setPaddingBottom(pad);
            cellDados.setVerticalAlignment(Element.ALIGN_MIDDLE);
            cellDados.setPaddingTop(pad);
            pTableDados.addCell(cellDados);

            cellDados = new PdfPCell(new Phrase(toMoeda(
                    (toDouble(mapList.get(j).get(VALORPAGAMENTO))
                            / (float) toInt(mapList.get(j).get(QUANTIDADE))),
                    toString(mapList.get(j).get(SIGLA))), fontCorpo));
            cellDados.setPaddingBottom(pad);
            cellDados.setVerticalAlignment(Element.ALIGN_MIDDLE);
            cellDados.setPaddingTop(pad);
            pTableDados.addCell(cellDados);

            cellDados = new PdfPCell(new Phrase(
                    toMoeda(toDouble(mapList.get(j).get(VALORPAGAMENTO)), toString(mapList.get(j).get(SIGLA))),
                    fontCorpo));
            cellDados.setPaddingBottom(pad);
            cellDados.setVerticalAlignment(Element.ALIGN_MIDDLE);
            cellDados.setPaddingTop(pad);
            pTableDados.addCell(cellDados);

            toPa += toDouble(mapList.get(j).get(VALORPAGAMENTO));
        }
        //            5.6f,5.6f,53.5f,17.95f,19.45f
        PdfPTable pTableRodape = new PdfPTable(new float[] { 5.6f, 6.05f, 19.795f, 33.705f, 17.95f, 19f });
        pTableRodape.setWidthPercentage(95f);

        cellDados = new PdfPCell(new Phrase(" ", fontCorpoNG));
        pTableRodape.addCell(cellDados);

        cellDados = new PdfPCell(new Phrase("CODE", fontCorpoNG));
        pTableRodape.addCell(cellDados);

        cellDados = new PdfPCell(new Phrase(toString(mapList.get(0).get(DOCFORMAPAGAMENTO)), fontCorpoNG));
        pTableRodape.addCell(cellDados);

        cellDados = new PdfPCell(new Phrase(toString(mapList.get(0).get(DESCRICAOCONTABANCO)), fontCorpoNG));
        pTableRodape.addCell(cellDados);

        cellDados = new PdfPCell(new Phrase("TOTAL", fontCorpoNG));
        pTableRodape.addCell(cellDados);

        cellDados = new PdfPCell(new Phrase(toMoeda(toPa, toString(mapList.get(0).get(SIGLA))), fontCorpoNG));
        pTableRodape.addCell(cellDados);

        documento.add(pTableDados);
        documento.add(pTableRodape);

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

        pTableAssiEstenso.setWidthPercentage(95f);

        PdfPCell cellAssiEstenso = new PdfPCell();
        Paragraph pAssiEstenso = new Paragraph();

        PdfPTable pTableResposavel = new PdfPTable(new float[] { 70, 30 });
        pTableResposavel.setWidthPercentage(100f);

        PdfPCell cellResposavel = new PdfPCell();
        cellResposavel
                .addElement(new Phrase("Requested by:_________________________________________", fontCorpoN));
        cellResposavel.setPaddingTop(10f);
        cellResposavel.setPaddingBottom(20f);
        cellResposavel.setBorder(0);
        pTableResposavel.addCell(cellResposavel);

        cellResposavel = new PdfPCell();
        cellResposavel.addElement(new Phrase(" HOD:___________________", fontCorpoN));
        cellResposavel.setPaddingTop(10f);
        cellResposavel.setPaddingBottom(20f);
        cellResposavel.setBorder(0);
        pTableResposavel.addCell(cellResposavel);

        cellResposavel = new PdfPCell();
        cellResposavel
                .addElement(new Phrase("Approveds by:_________________________________________", fontCorpoN));
        cellResposavel.setPaddingTop(-5f);
        cellResposavel.setPaddingBottom(20f);
        cellResposavel.setBorder(0);
        pTableResposavel.addCell(cellResposavel);

        cellResposavel = new PdfPCell();
        cellResposavel.addElement(new Phrase(" Date:___________________", fontCorpoN));
        cellResposavel.setPaddingTop(-5f);
        cellResposavel.setPaddingBottom(20f);
        cellResposavel.setBorder(0);
        pTableResposavel.addCell(cellResposavel);

        pAssiEstenso.add(pTableResposavel);
        cellAssiEstenso.addElement(pAssiEstenso);

        PdfPTable pTableExteso = new PdfPTable(new float[] { 25f, 75f });
        pTableExteso.setWidthPercentage(100f);

        JTextPane jtp = new JTextPane();
        Moeda.EscreverEstenso(toPa, jtp, ((mapList.size() > 0) ? toString(mapList.get(0).get(MOEDA)) : ""));

        PdfPCell cellExteso = new PdfPCell(new Phrase("Recived the sum of", fontCorpoN));
        cellExteso.setBorder(0);
        pTableExteso.addCell(cellExteso);
        cellExteso = new PdfPCell(new Phrase(jtp.getText().toUpperCase().trim(), fontCorpoU));
        cellExteso.setBorder(0);
        pTableExteso.addCell(cellExteso);

        pAssiEstenso.add(pTableExteso);

        PdfPTable pTableAss = new PdfPTable(new float[] { 45f, 55f });
        pTableAss.setWidthPercentage(100f);

        PdfPCell cellAss = new PdfPCell(new Phrase(" ______________", fontCorpoN));
        cellAss.setPaddingTop(15f);
        cellAss.setHorizontalAlignment(Element.ALIGN_CENTER);
        cellAss.setBorder(0);
        cellAss.setPaddingBottom(0f);
        pTableAss.addCell(cellAss);

        cellAss = new PdfPCell(new Phrase(" ____________________________________________", fontCorpoN));
        cellAss.setPaddingTop(15f);
        cellAss.setPaddingBottom(0f);
        cellAss.setHorizontalAlignment(Element.ALIGN_CENTER);
        cellAss.setBorder(0);
        pTableAss.addCell(cellAss);

        cellAss = new PdfPCell(new Phrase("Date", fontCorpoN));
        cellAss.setHorizontalAlignment(Element.ALIGN_CENTER);
        cellAss.setBorder(0);
        pTableAss.addCell(cellAss);

        cellAss = new PdfPCell(new Phrase("Receiver name & signature", fontCorpoN));
        cellAss.setHorizontalAlignment(Element.ALIGN_CENTER);
        cellAss.setBorder(0);
        pTableAss.addCell(cellAss);
        pTableAss.setHorizontalAlignment(Element.ALIGN_CENTER);

        pAssiEstenso.add(pTableAss);
        pAssiEstenso.setAlignment(Element.ALIGN_CENTER);
        pAssiEstenso.add(new Phrase(
                "NOTA: Um recibo oficial pode ser obtido por um pagamento e informado na parte inversa deste comprovativo.\n\n",
                fontCorpoN));
        cellAssiEstenso = new PdfPCell();
        cellAssiEstenso.addElement(pAssiEstenso);

        pTableAssiEstenso.addCell(cellAssiEstenso);

        documento.add(pTableAssiEstenso);

        documento.close();
        reString = "../Documentos/" + user + "/Pagamentos/" + "Pagamentos Func " + Ddata + ".pdf";
        return reString;
    } catch (FileNotFoundException | DocumentException ex) {
        Logger.getLogger(FuncPagamento.class.getName()).log(Level.SEVERE, null, ex);
    }
    return reString;
}

From source file:Export.FuncPagamento.java

public static String folhaPagamentoOnlyMovCre(String numPagamento, String user, String nomeUser, Object ob)
        throws NumberFormatException {
    try {/*w  ww . ja  va  2 s  .c  o m*/

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

        Font fontCabecalhoN = FontFactory.getFont(ConfigDoc.Fontes.FONTB, BaseFont.WINANSI, BaseFont.EMBEDDED,
                9.5f);
        Font fontCorpo = FontFactory.getFont(ConfigDoc.Fontes.FONT, BaseFont.WINANSI, BaseFont.EMBEDDED, 9f);
        Font fontCorpoP = FontFactory.getFont(ConfigDoc.Fontes.FONT, BaseFont.WINANSI, BaseFont.EMBEDDED, 8f);
        Font fontCorpoN = FontFactory.getFont(ConfigDoc.Fontes.FONTB, BaseFont.WINANSI, BaseFont.EMBEDDED, 9f);
        Font fontCorpoNU = FontFactory.getFont(ConfigDoc.Fontes.FONTB, BaseFont.WINANSI, BaseFont.EMBEDDED, 9f,
                Font.UNDERLINE);
        Font fontCorpoNG = FontFactory.getFont(ConfigDoc.Fontes.FONTB, BaseFont.WINANSI, BaseFont.EMBEDDED,
                11.5f);
        Font fontCorpoNGT = FontFactory.getFont(ConfigDoc.Fontes.FONTB, BaseFont.WINANSI, BaseFont.EMBEDDED,
                13f, Font.UNDERLINE);
        Font fontCabecalhoNG = FontFactory.getFont(ConfigDoc.Fontes.FONTB, BaseFont.WINANSI, BaseFont.EMBEDDED,
                16f, Font.UNDERLINE);

        ArrayList<HashMap<String, Object>> mapList = setObj(numPagamento, ob);

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

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

        int size = mapList.size(), i = 0;

        File ff = new File(ConfigDoc.Fontes.getDiretorio() + "/" + user + "/Pagamentos/");

        ff.mkdirs();
        ff = new File(ff.getAbsoluteFile() + "/" + "Pagamentos Func " + Ddata + ".pdf");

        OutputStream outputStraem = new FileOutputStream(ff);
        PdfWriter writer = PdfWriter.getInstance(documento, outputStraem);

        MyFooter event = new MyFooter();
        writer.setPageEvent(event);

        documento.open();

        for (HashMap<String, Object> hashMap : mapList) {
            i++;

            PdfPTable pTableEmpresaPricipal = new PdfPTable(new float[] { 25f, 75f });
            pTableEmpresaPricipal.setWidthPercentage(90);
            PdfPTable pTableEmpresaInforImpres1 = new PdfPTable(1);
            PdfPTable pTableEmpresaInforImpres5 = new PdfPTable(1);

            PdfPTable pTableNull = new PdfPTable(1);
            PdfPCell cellNull = new PdfPCell(new Phrase(" ", fontCorpoP));
            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.addCell(cellTabela6);
            pTableEmpresaPricipal.addCell(cellTabela5);

            documento.add(pTableEmpresaPricipal);

            documento.add(pTableNull);
            documento.add(pTableNull);

            PdfPTable pTableTitulo = new PdfPTable(new float[] { 50, 50 });
            pTableTitulo.setWidthPercentage(90f);
            PdfPCell cellTitulo = new PdfPCell(new Phrase("Comprovativo de Pagamento", fontCorpoNGT));
            cellTitulo.setBorder(0);
            cellTitulo.setHorizontalAlignment(Element.ALIGN_RIGHT);
            cellTitulo.setPaddingRight(-80f);
            cellTitulo.setPaddingTop(-26f);
            pTableTitulo.addCell(cellTitulo);
            cellTitulo = new PdfPCell(new Phrase("N: " + hashMap.get(PAGAMENTO), fontCorpoNGT));
            cellTitulo.setHorizontalAlignment(Element.ALIGN_RIGHT);
            cellTitulo.setBorder(0);
            cellTitulo.setPaddingBottom(5f);
            pTableTitulo.addCell(cellTitulo);

            documento.add(pTableTitulo);

            PdfPTable pTableAno = new PdfPTable(new float[] { 100 });
            pTableAno.setWidthPercentage(90f);

            SimpleDateFormat sdfVeiw = new SimpleDateFormat("MMMM '('dd/MM/yyyy')'", new Locale("pt", "BR"));
            PdfPCell cellAno = new PdfPCell(new Phrase(sdfVeiw.format(new Date()), fontCorpoNGT));
            cellAno.setBorder(0);
            cellAno.setPaddingBottom(20f);
            pTableAno.addCell(cellAno);

            documento.add(pTableAno);

            PdfPTable pTableDetalhesPagamento = new PdfPTable(new float[] { 100 });
            pTableDetalhesPagamento.setWidthPercentage(90f);
            PdfPCell cellDetalhesPagamento = new PdfPCell();

            Paragraph pDetalhesPagamento = new Paragraph();
            pDetalhesPagamento.add(new Paragraph("\nDetalhes de Pagamento ", fontCorpoNG));

            pDetalhesPagamento.add(new Phrase("Beneficirio: ", fontCorpoN));
            pDetalhesPagamento.add(new Phrase(toString(hashMap.get(BENEFICIARIO)) + "\n", fontCorpo));
            pDetalhesPagamento.add(new Phrase("Descrio do pagamento: ", fontCorpoN));
            pDetalhesPagamento.add(new Phrase(toString(hashMap.get(DESCRICAOPAGAMENTO)), fontCorpo));
            pDetalhesPagamento.add(new Paragraph("CONFORME APROVADO\n\n", fontCorpoN));

            pDetalhesPagamento.add(new Paragraph("Valor Pagamento", fontCorpoNG));
            pDetalhesPagamento.add(new Phrase("Valor Numerico: ", fontCorpoN));
            pDetalhesPagamento.add(new Phrase(
                    toMoeda(hashMap.get(VALORPAGAMENTO), toString(hashMap.get(SIGLA))) + "\n", fontCorpo));
            System.err.println(toString(hashMap.get(RETENCAOFONTE)) + " hfhfh retensao");
            if (toString(hashMap.get(RETENCAOFONTE)).trim().equals("1")) {
                double ret = getValorImportRetensao();
                pDetalhesPagamento.add(new Phrase("Valor Retensao Fonte: ", fontCorpoN));
                pDetalhesPagamento.add(new Phrase(toMoeda(ret, "%") + "\n", fontCorpo));
                pDetalhesPagamento.add(new Phrase("Valor Retido: ", fontCorpoN));
                double valret = toDouble(hashMap.get(VALORPAGAMENTO)) * ret;
                pDetalhesPagamento
                        .add(new Phrase(toMoeda(valret, toString(hashMap.get(SIGLA))) + "\n", fontCorpo));
            }

            JTextPane jtp = new JTextPane();
            Double valor = Double.valueOf((hashMap.get(VALORPAGAMENTO) + ""));
            Moeda.EscreverEstenso(valor, jtp, toString(hashMap.get(MOEDA)));

            pDetalhesPagamento.add(new Phrase("Valor por Extenso: ", fontCorpoN));
            pDetalhesPagamento.add(new Phrase(jtp.getText().trim() + " \n\n", fontCorpo));

            pDetalhesPagamento.add(new Paragraph("Descrio da Conta", fontCorpoNG));
            pDetalhesPagamento.add(new Phrase("Cod Conta: ", fontCorpoN));
            pDetalhesPagamento.add(new Phrase(hashMap.get(CODIGOCONTAPAGAMENTO) + "\n", fontCorpo));
            pDetalhesPagamento.add(new Phrase("Titulo da Conta: ", fontCorpoN));
            pDetalhesPagamento.add(new Phrase(hashMap.get(TITULOCONTAPAGAMENTO) + "\n", fontCorpo));

            /**
             * For alter
             */
            //                pDetalhesPagamento.add(new Phrase("Forma de Pagamento: ", fontCorpoN));
            //                pDetalhesPagamento.add(new Phrase(hashMap.get(FORMAPAGAMENTO) + " \n", fontCorpo));
            pDetalhesPagamento.add(new Phrase("Documento de Pagamento: ", fontCorpoN));
            pDetalhesPagamento.add(new Phrase(toString(hashMap.get(DESCRICAOCONTABANCO)) + " - "
                    + toString(hashMap.get(DOCFORMAPAGAMENTO)) + "\n\n", fontCorpo));
            pDetalhesPagamento.add(new Paragraph(" ", fontCorpoN));

            cellDetalhesPagamento.addElement(pDetalhesPagamento);
            pTableDetalhesPagamento.addCell(cellDetalhesPagamento);

            cellDetalhesPagamento = new PdfPCell();
            pDetalhesPagamento = new Paragraph();

            pDetalhesPagamento.add(new Paragraph(" ", fontCorpo));
            pDetalhesPagamento.add(new Phrase("Preparado por: ", fontCorpoN));
            pDetalhesPagamento.add(new Phrase(nomeUser + " ", fontCorpoP));
            pDetalhesPagamento.add(new Phrase("            Examinado por", fontCorpoN));
            pDetalhesPagamento.add(new Phrase("____________________\n", fontCorpo));

            pDetalhesPagamento.add(new Paragraph(" ", fontCorpoN));
            pDetalhesPagamento.add(new Paragraph("Pagamento Autorizado por:", fontCorpoNG));

            pDetalhesPagamento.add(new Paragraph(" ", fontCorpoN));
            pDetalhesPagamento.add(new Phrase("Assinatura: ", fontCorpoN));
            pDetalhesPagamento.add(new Phrase(" ____________________________________________", fontCorpo));
            pDetalhesPagamento.add(new Phrase("    Data ", fontCorpoN));
            pDetalhesPagamento.add(new Phrase(" ______________________\n\n", fontCorpo));

            pDetalhesPagamento.add(new Phrase("Assinatura: ", fontCorpoN));
            pDetalhesPagamento.add(new Phrase(" ____________________________________________", fontCorpo));
            pDetalhesPagamento.add(new Phrase("    Data ", fontCorpoN));
            pDetalhesPagamento.add(new Phrase(" ______________________\n", fontCorpo));

            pDetalhesPagamento.add(new Paragraph(" ", fontCorpo));
            pDetalhesPagamento.add(new Paragraph(
                    "............................................................................."
                            + "...........................................................................",
                    fontCorpoN));

            pDetalhesPagamento.add(new Paragraph(" ", fontCorpo));
            Paragraph pReceip = new Paragraph("RECIBO", fontCorpoN);
            pReceip.setAlignment(Element.ALIGN_CENTER);
            pDetalhesPagamento.add(pReceip);

            pDetalhesPagamento.add(new Paragraph(" ", fontCorpo));
            pDetalhesPagamento.add(new Phrase("Recebi o valor de: ", fontCorpo));
            pDetalhesPagamento.add(new Phrase(jtp.getText() + " \n", fontCorpoNU));

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

            PdfPTable pTableNumCheque = new PdfPTable(
                    new float[] { 33.3333333333f, 33.3333333333f, 33.3333333333f });
            pTableNumCheque.setWidthPercentage(90f);
            pTableNumCheque.setWidthPercentage(100f);

            PdfPCell cellNumCheque = new PdfPCell(new Phrase("_______________________", fontCorpo));
            cellNumCheque.setBorder(0);
            cellNumCheque.setHorizontalAlignment(Element.ALIGN_CENTER);
            pTableNumCheque.addCell(cellNumCheque);
            cellNumCheque = new PdfPCell(new Phrase("_______________________", fontCorpo));
            cellNumCheque.setBorder(0);
            cellNumCheque.setHorizontalAlignment(Element.ALIGN_CENTER);
            pTableNumCheque.addCell(cellNumCheque);
            cellNumCheque = new PdfPCell(new Phrase("_______________________", fontCorpo));
            cellNumCheque.setBorder(0);
            cellNumCheque.setHorizontalAlignment(Element.ALIGN_CENTER);
            pTableNumCheque.addCell(cellNumCheque);

            cellNumCheque = new PdfPCell(new Phrase("Cheque No.", fontCorpoN));
            cellNumCheque.setBorder(0);
            cellNumCheque.setHorizontalAlignment(Element.ALIGN_CENTER);
            pTableNumCheque.addCell(cellNumCheque);
            cellNumCheque = new PdfPCell(new Phrase("Data", fontCorpoN));
            cellNumCheque.setBorder(0);
            cellNumCheque.setHorizontalAlignment(Element.ALIGN_CENTER);
            pTableNumCheque.addCell(cellNumCheque);
            cellNumCheque = new PdfPCell(new Phrase("Receiver Name & Signature", fontCorpoN));
            cellNumCheque.setBorder(0);
            cellNumCheque.setHorizontalAlignment(Element.ALIGN_CENTER);
            pTableNumCheque.addCell(cellNumCheque);

            pDetalhesPagamento.add(pTableNumCheque);

            pDetalhesPagamento.add(new Phrase(
                    "\nNOTA: Um recibo oficial pode ser obtido por um pagamento e informado na parte inversa deste comprovativo. \n\n",
                    fontCorpo));

            cellDetalhesPagamento.addElement(pDetalhesPagamento);

            pTableDetalhesPagamento.addCell(cellDetalhesPagamento);

            documento.add(pTableDetalhesPagamento);

            if (i != size) {
                documento.newPage();
            }
        }

        documento.close();
        String ret = "../Documentos/" + user + "/Pagamentos/" + "Pagamentos Func " + Ddata + ".pdf";

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

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

From source file:Export.GenericPDFs.java

/**
 *
 * @param user// w  ww  .j a  va 2s . c  o m
 * @param nomeDoc
 * @param titleDoc
 * @param rs
 * @param op
 * @param paramFilter
 * @return
 */
public static String createDoc(String user, String nomeDoc, String titleDoc, DataTableControl rs,
        OrientacaoPagina op, int paramFilter) {
    nomeDocR = nomeDoc;
    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 fontCorpoTable = FontFactory.getFont(ConfigDoc.Fontes.FONT, BaseFont.WINANSI, BaseFont.EMBEDDED,
                7.5f);
        Font fontCorpoTableN = FontFactory.getFont(ConfigDoc.Fontes.FONTB, BaseFont.WINANSI, BaseFont.EMBEDDED,
                7.8f);
        Font fontCorpoNG = FontFactory.getFont(ConfigDoc.Fontes.FONTB, BaseFont.WINANSI, BaseFont.EMBEDDED, 9f);
        Font fontCorpoTitile = FontFactory.getFont(ConfigDoc.Fontes.FONTB, BaseFont.WINANSI, BaseFont.EMBEDDED,
                11.5f);
        Font fontCabecalhoNG = FontFactory.getFont(ConfigDoc.Fontes.FONTB, BaseFont.WINANSI, BaseFont.EMBEDDED,
                16f, Font.UNDERLINE);

        getMap(rs, paramFilter);
        ar = createPerncetage(list, paramFilter);
        PdfPTable tableDados = new PdfPTable(ar);

        Document documento = new Document();

        i = 0;
        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() + "/" + nomeDoc + " " + Ddata + ".pdf");
        OutputStream outputStraem = new FileOutputStream(ff);

        reString = "../Documentos/" + user + "/Relatorio/" + nomeDoc + " " + Ddata + ".pdf";

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

        MyFooter event = new MyFooter();
        writer.setPageEvent(event);

        if (op == OrientacaoPagina.HORIZONTAL) {
            documento.setPageSize(PageSize.A4.rotate());
        } else {
            documento.setPageSize(PageSize.A4);
        }

        documento.setMargins(10f, 10f, 35f, 35f);

        PdfPTable pTableEmpresaPricipal = new PdfPTable(
                (OrientacaoPagina.HORIZONTAL == op) ? new float[] { 14f, 86f } : new float[] { 18.5f, 82.5f });
        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);

        documento.open();
        documento.add(pTableEmpresaPricipal);
        documento.add(pTableNull);

        PdfPTable pTableTitile = new PdfPTable(1);
        SimpleDateFormat format = new SimpleDateFormat("dd 'de' MMMM 'de' yyyy", new Locale("pt", "BR"));
        PdfPCell cellTitile = new PdfPCell(new Phrase(titleDoc.toUpperCase() + ((dF != null && dI != null)
                ? (" de " + format.format(dI) + "  " + format.format(dF)).toUpperCase()
                : ""), fontCorpoTitile));
        cellTitile.setPaddingBottom(20f);
        cellTitile.setBorder(0);
        cellTitile.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
        pTableTitile.addCell(cellTitile);
        documento.add(pTableTitile);

        tableDados.setWidthPercentage(97f);
        PdfPTable tableTitile = new PdfPTable(ar);
        tableTitile.setWidthPercentage(97f);

        if (paramFilter < 0) {
            for (Object[] emap : list) {
                tableDados = new PdfPTable(ar);
                tableDados.setWidthPercentage(97f);
                if (emap[0] == null || !emap[0].equals("TOTAL")) {
                    for (int j = 0; j < emap.length; j++) {
                        if (cabe && i == 0) {
                            lista_titulo_table = emap;
                            PdfPCell cellTitileTable = new PdfPCell(
                                    new Phrase(toString(emap[j]).toUpperCase(), fontCorpoNG));
                            cellTitileTable.setBorderWidth(1f);
                            cellTitileTable.setPaddingTop(8f);
                            cellTitileTable.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
                            cellTitileTable.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
                            BaseColor colorAzul = new BaseColor(255, 255, 255);
                            cellTitileTable.setBackgroundColor(colorAzul);
                            cellTitileTable.setPaddingBottom(8f);
                            tableTitile.addCell(cellTitileTable);
                        } else {
                            PdfPCell dados = new PdfPCell(new Phrase(toString(emap[j]), fontCorpoTable));
                            dados.setHorizontalAlignment(
                                    (alignment.containsKey(j)) ? alignment.get(j).i : PdfPCell.ALIGN_LEFT);
                            dados.setPaddingTop(5f);
                            dados.setPaddingBottom(5f);
                            BaseColor colorCinza = new BaseColor(255, 255, 255);
                            dados.setBackgroundColor(((i % 2 != 0) ? colorCinza : null));
                            tableDados.addCell(dados);
                        }
                    }
                    i++;
                    cabe = false;
                }

                if (i == 1) {
                    documento.add(tableTitile);
                }

                documento.add(tableDados);

            }

            PdfPTable tableTotal = new PdfPTable(ar);
            tableTotal.setWidthPercentage(97f);

            mapTotal.entrySet().stream().forEach((entrySet) -> {
                mapTotal.get(entrySet.getKey()).stream().forEach((get) -> {
                    for (int g = 0; g < get.length; g++) {
                        if (g != paramFilter) {
                            PdfPCell dados = new PdfPCell(
                                    new Phrase(((g == 0) ? "TOTAL" : toString(get[g])), fontCorpoTableN));
                            dados.setHorizontalAlignment(
                                    (alignment.containsKey(g)) ? alignment.get(g).i : PdfPCell.ALIGN_LEFT);
                            dados.setPaddingTop(5f);
                            dados.setPaddingBottom(5f);
                            BaseColor colorCinza = new BaseColor(255, 255, 255);
                            dados.setBackgroundColor(colorCinza);
                            tableTotal.addCell(dados);
                        }
                    }
                });
            });
            documento.add(tableTotal);
        } else {
            int t = 0;
            for (Map.Entry<String, ArrayList<Object[]>> lista : map.entrySet()) {
                i = 0;
                cabe = true;

                PdfPTable pTableSubTitile = new PdfPTable(new float[] { 100 });
                pTableSubTitile.setWidthPercentage(97f);

                PdfPCell cellSubTitile = new PdfPCell(
                        new Paragraph(lista.getKey().toUpperCase(), fontCorpoTitile));
                cellSubTitile.setBorder(PdfPCell.NO_BORDER);
                cellSubTitile.setPaddingTop(0f);
                cellSubTitile.setPaddingBottom(0f);
                pTableSubTitile.addCell(cellSubTitile);
                documento.add(pTableSubTitile);

                documento.add(new Paragraph(" "));

                for (Object[] emap : lista.getValue()) {
                    tableDados = new PdfPTable(ar);
                    tableTitile = new PdfPTable(ar);
                    tableDados.setWidthPercentage(97f);
                    tableTitile.setWidthPercentage(97f);
                    int k = 0;
                    for (int j = 0; j < emap.length; j++) {
                        if (k != paramFilterOculta) {
                            if (cabe && i == 0) {
                                lista_titulo_table = emap;
                                PdfPCell cellTitileTable = new PdfPCell(
                                        new Phrase(toString(emap[j]).toUpperCase(), fontCorpoNG));
                                cellTitileTable.setBorderWidth(1f);
                                cellTitileTable.setPaddingTop(8f);
                                cellTitileTable.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
                                cellTitileTable.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
                                BaseColor colorAzul = new BaseColor(255, 255, 255);
                                cellTitileTable.setBackgroundColor(colorAzul);
                                cellTitileTable.setPaddingBottom(8f);
                                tableTitile.addCell(cellTitileTable);
                            } else {
                                PdfPCell dados = new PdfPCell(new Phrase(toString(emap[j]), fontCorpoTable));
                                dados.setHorizontalAlignment(
                                        (alignment.containsKey(j)) ? alignment.get(j).i : PdfPCell.ALIGN_LEFT);
                                dados.setPaddingTop(5f);
                                dados.setPaddingBottom(5f);
                                BaseColor colorCinza = new BaseColor(255, 255, 255);
                                dados.setBackgroundColor(((i % 2 != 0) ? colorCinza : null));
                                tableDados.addCell(dados);
                            }
                        }
                        k++;
                    }
                    i++;

                    cabe = false;
                    if (i == 1) {
                        documento.add(tableTitile);
                    }

                    documento.add(tableDados);

                }
                PdfPTable tableTotal = new PdfPTable(ar);
                tableTotal.setWidthPercentage(97f);
                if (mapTotal.containsKey(lista.getKey())) {
                    mapTotal.get(lista.getKey()).stream().forEach((get) -> {
                        for (int g = 0; g < get.length; g++) {
                            if (g != paramFilterOculta) {
                                PdfPCell dados = new PdfPCell(
                                        new Phrase(((g == 0) ? "TOTAL" : toString(get[g])), fontCorpoTableN));
                                dados.setHorizontalAlignment(
                                        (alignment.containsKey(g)) ? alignment.get(g).i : PdfPCell.ALIGN_LEFT);
                                dados.setPaddingTop(5f);
                                dados.setPaddingBottom(5f);
                                BaseColor colorCinza = new BaseColor(255, 255, 255);
                                dados.setBackgroundColor(colorCinza);
                                tableTotal.addCell(dados);
                            }
                        }
                    });
                }
                documento.add(tableTotal);
                t++;

                documento.add(new Paragraph(" "));
                documento.add(new Paragraph(" "));
                documento.add(new Paragraph(" "));

                if (t == map.size() && paramFilter > -1) {
                    PdfPTable tableTotal_t = new PdfPTable(ar);
                    tableTotal_t.setWidthPercentage(97f);
                    for (int j = 0; j < lista_titulo_table.length; j++) {
                        if (j != paramFilterOculta) {
                            PdfPCell cellTitileTable = new PdfPCell(
                                    new Phrase(toString(lista_titulo_table[j]).toUpperCase(), fontCorpoNG));
                            cellTitileTable.setBorderWidth(1f);
                            cellTitileTable.setPaddingTop(8f);
                            cellTitileTable.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
                            cellTitileTable.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
                            BaseColor colorAzul = new BaseColor(255, 255, 255);
                            cellTitileTable.setBackgroundColor(colorAzul);
                            cellTitileTable.setPaddingBottom(8f);
                            tableTotal_t.addCell(cellTitileTable);
                        }
                    }

                    Double[] total_total = new Double[lista_titulo_table.length];
                    mapTotal.entrySet().stream().forEach((entrySet) -> {
                        mapTotal.get(entrySet.getKey()).stream().forEach((value) -> {
                            for (int g = 0; g < value.length; g++) {
                                if (!entrySet.getKey().equals("TOTAL")) {
                                    if (g != paramFilterOculta) {
                                        if (Moeda.unFormat(toString(value[g]).replaceAll(" ", "")
                                                .replaceAll(",", ".").replaceAll("STD", "")) != -1) {
                                            double v = ((total_total[g] == null) ? 0.0 : total_total[g]);
                                            total_total[g] = (Moeda
                                                    .unFormat(toString(value[g]).replaceAll(" ", "")
                                                            .replaceAll(",", ".").replaceAll("STD", ""))
                                                    + v);
                                        }
                                        PdfPCell dados = new PdfPCell(new Phrase(
                                                ((g == 0) ? "TOTAL " + entrySet.getKey().toUpperCase()
                                                        : toString(value[g])),
                                                fontCorpoTableN));
                                        dados.setHorizontalAlignment(
                                                (alignment.containsKey(g)) ? alignment.get(g).i
                                                        : PdfPCell.ALIGN_LEFT);
                                        dados.setPaddingTop(5f);
                                        dados.setPaddingBottom(5f);
                                        BaseColor colorCinza = new BaseColor(255, 255, 255);
                                        dados.setBackgroundColor(colorCinza);
                                        tableTotal_t.addCell(dados);
                                    }
                                }
                            }
                        });
                    });
                    for (int j = 0; j < total_total.length; j++) {
                        if (j != paramFilterOculta) {
                            PdfPCell cellTitileTable = new PdfPCell(
                                    new Phrase((total_total[j] != null) ? Moeda.format(total_total[j]) : " ",
                                            fontCorpoNG));
                            cellTitileTable.setPaddingTop(5f);
                            cellTitileTable.setHorizontalAlignment(
                                    (alignment.containsKey(j)) ? alignment.get(j).i : PdfPCell.ALIGN_LEFT);
                            BaseColor colorAzul = new BaseColor(255, 255, 255);
                            cellTitileTable.setBackgroundColor(colorAzul);
                            cellTitileTable.setPaddingBottom(5f);
                            tableTotal_t.addCell(cellTitileTable);
                        }
                    }
                    documento.add(tableTotal_t);
                }
            }
        }
        documento.close();
        no = false;
        nomeNo = "";
        dI = null;
        dF = null;
        paramFilterOculta = -1;
        removeItem = new int[] {};
        renameItem = new HashMap<>();
        alignment = new HashMap<>();
        arrValoresTotal = new int[] {};
        valoresTotal = new String[] {};
        RequestContext.getCurrentInstance().execute("openAllDocument('" + reString + "')");
        return reString;
    } catch (BadElementException | IOException ex) {
        Logger.getLogger(GenericPDFs.class.getName()).log(Level.SEVERE, null, ex);
        return "";
    } catch (DocumentException ex) {
        Logger.getLogger(GenericPDFs.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 av  a  2  s  .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.ListaVeiculo.java

public static void criarDocPdf(List<Veiculo> ls, String user) {
    @SuppressWarnings("UnusedAssignment")
    OutputStream outputStraem = null;
    try {//from  w  w w .j  a  va  2s .  c o m

        Font fontCabecalhoN = FontFactory.getFont(ConfigDoc.Fontes.FONTB, BaseFont.WINANSI, BaseFont.EMBEDDED,
                10f);
        Font fontCorpo = FontFactory.getFont(ConfigDoc.Fontes.FONT, BaseFont.WINANSI, BaseFont.EMBEDDED, 9f);
        Font fontCorpoTable = FontFactory.getFont(ConfigDoc.Fontes.FONT, BaseFont.WINANSI, BaseFont.EMBEDDED,
                8f);
        Font fontCorpoTableN = FontFactory.getFont(ConfigDoc.Fontes.FONTB, BaseFont.WINANSI, BaseFont.EMBEDDED,
                8f);
        Font fontCorpoNG = FontFactory.getFont(ConfigDoc.Fontes.FONTB, BaseFont.WINANSI, BaseFont.EMBEDDED, 9f);
        Font fontCorpoTitile = FontFactory.getFont(ConfigDoc.Fontes.FONTB, BaseFont.WINANSI, BaseFont.EMBEDDED,
                11.5f);
        Font fontCabecalhoNG = FontFactory.getFont(ConfigDoc.Fontes.FONTB, BaseFont.WINANSI, BaseFont.EMBEDDED,
                16f, Font.UNDERLINE);

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

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

        PdfPCell pCellNomeEmpresa = new PdfPCell(new Phrase(ConfigDoc.Empresa.NOME, fontCabecalhoNG));
        pCellNomeEmpresa.setBorder(0);
        PdfPCell pCellNomeEndereco = new PdfPCell(new Phrase(ConfigDoc.Empresa.ENDERECO, fontCabecalhoN));
        pCellNomeEndereco.setBorder(0);
        PdfPCell pCellCaixaPostal = new PdfPCell(new Phrase(ConfigDoc.Empresa.CAIXAPOSTAL, fontCabecalhoN));
        pCellCaixaPostal.setBorder(0);
        PdfPCell pCellTeleFax = new PdfPCell(
                new Phrase(ConfigDoc.Empresa.TELEFAX + " " + ConfigDoc.Empresa.EMAIL, fontCabecalhoN));
        pCellTeleFax.setBorder(0);
        PdfPCell pCellSociedade = new PdfPCell(new Phrase(ConfigDoc.Empresa.SOCIEDADE, fontCabecalhoN));
        pCellSociedade.setBorder(0);

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

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

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

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

        PdfPCell cellTabela6 = new PdfPCell(imageEmpresa);
        cellTabela6.setBorder(0);

        pTableEmpresaPricipal.setWidthPercentage(97);
        pTableEmpresaPricipal.addCell(cellTabela6);
        pTableEmpresaPricipal.addCell(cellTabela5);
        Document documento = new Document(PageSize.A4.rotate());

        SimpleDateFormat sdf1 = new SimpleDateFormat("dd-MM-yyyy hh'.'mm'.'ss");
        File ff = new File(ConfigDoc.Fontes.getDiretorio() + "/" + user + "/Relatorio");
        ff.mkdirs();

        String Ddata = sdf1.format(new Date());
        ff = new File(ff.getAbsoluteFile() + "/" + "Lista de Veiculos" + " " + Ddata + ".pdf");

        outputStraem = new FileOutputStream(ff);
        String reString = "../Documentos/" + user + "/Relatorio/" + "Lista de Veiculos" + " " + Ddata + ".pdf";
        PdfWriter writer = PdfWriter.getInstance(documento, outputStraem);

        BaseColor colorAzul = new BaseColor(176, 196, 222);
        BaseColor colorCinza = new BaseColor(240, 240, 240);
        //            BaseColor colorAzulEscuro = new BaseColor(100, 149, 237);

        PdfPTable pTableSubTitile = new PdfPTable(new float[] { 100 });
        pTableSubTitile.setWidthPercentage(97f);

        PdfPCell cellSubTitile = new PdfPCell(new Paragraph("Lista de Veiculos", fontCorpoTitile));
        cellSubTitile.setBorder(PdfPCell.NO_BORDER);
        cellSubTitile.setPaddingTop(0f);
        cellSubTitile.setPaddingBottom(0f);
        pTableSubTitile.addCell(cellSubTitile);

        PdfPTable tableDados = new PdfPTable(
                new float[] { 12.8f, 12.8f, 12.8f, 12.8f, 12.8f, 12.8f, 12.8f, 12.8f });
        tableDados.setWidthPercentage(97f);

        for (int i = 0; i < 8; i++) {
            PdfPCell cellTitileTable = new PdfPCell(new Phrase(getList(i), fontCorpoNG));
            cellTitileTable.setBorderWidth(1f);
            cellTitileTable.setPaddingTop(8f);
            cellTitileTable.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
            cellTitileTable.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
            cellTitileTable.setBackgroundColor(colorAzul);
            cellTitileTable.setPaddingBottom(8f);
            tableDados.addCell(cellTitileTable);
        }

        PdfPCell dados;

        for (int i = 0; i < ls.size(); i++) {

            dados = new PdfPCell(new Phrase(ls.get(i).getNumeroMatricula(), fontCorpoTable));
            dados.setPaddingTop(5f);
            dados.setPaddingBottom(5f);
            dados.setBackgroundColor(((i % 2 != 0) ? colorCinza : null));
            tableDados.addCell(dados);

            dados = new PdfPCell(new Phrase(ls.get(i).getMarca(), fontCorpoTable));
            dados.setPaddingTop(5f);
            dados.setPaddingBottom(5f);
            dados.setBackgroundColor(((i % 2 != 0) ? colorCinza : null));
            tableDados.addCell(dados);

            dados = new PdfPCell(new Phrase(ls.get(i).getModelo(), fontCorpoTable));
            dados.setPaddingTop(5f);
            dados.setPaddingBottom(5f);
            dados.setBackgroundColor(((i % 2 != 0) ? colorCinza : null));
            tableDados.addCell(dados);

            dados = new PdfPCell(new Phrase(ls.get(i).getNumMotor(), fontCorpoTable));
            dados.setPaddingTop(5f);
            dados.setPaddingBottom(5f);
            dados.setBackgroundColor(((i % 2 != 0) ? colorCinza : null));
            tableDados.addCell(dados);

            dados = new PdfPCell(new Phrase(ls.get(i).getChassi(), fontCorpoTable));
            dados.setPaddingTop(5f);
            dados.setPaddingBottom(5f);
            dados.setBackgroundColor(((i % 2 != 0) ? colorCinza : null));
            tableDados.addCell(dados);

            dados = new PdfPCell(new Phrase(ls.get(i).getAnoFabrico(), fontCorpoTable));
            dados.setPaddingTop(5f);
            dados.setPaddingBottom(5f);
            dados.setBackgroundColor(((i % 2 != 0) ? colorCinza : null));
            tableDados.addCell(dados);

            dados = new PdfPCell(new Phrase(ls.get(i).getAnoCompra(), fontCorpoTable));
            dados.setPaddingTop(5f);
            dados.setPaddingBottom(5f);
            dados.setBackgroundColor(((i % 2 != 0) ? colorCinza : null));
            tableDados.addCell(dados);

            dados = new PdfPCell(new Phrase(ls.get(i).getCapacidade(), fontCorpoTable));
            dados.setPaddingTop(5f);
            dados.setPaddingBottom(5f);
            dados.setBackgroundColor(((i % 2 != 0) ? colorCinza : null));
            tableDados.addCell(dados);

        }

        documento.open();
        documento.add(pTableEmpresaPricipal);
        documento.add(pTableNull);
        documento.add(pTableNull);
        documento.add(pTableSubTitile);
        documento.add(pTableNull);
        documento.add(tableDados);
        documento.close();

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

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

}

From source file:Export.ReciboPagamento.java

public PdfPTable detaDoc(HashMap<String, Object> map, Font fontTitile, Font fontRecibo, Font fontTitileShort,
        Font fontReciboTxt, Font fontConteudo, Font fontConteudoTxt, Font fontConteudoTxtUl)
        throws DocumentException {
    PdfPTable pTablePrincipal = new PdfPTable(new float[] { 100 });
    try {//from w  w  w  . jav a 2 s  .c o m
        pTablePrincipal.setWidthPercentage(100f);

        PdfPTable pTableTitulo = new PdfPTable(new float[] { 60, 40 });
        pTableTitulo.setWidthPercentage(100);

        PdfPTable pTableTituloImage = new PdfPTable(new float[] { 20, 80 });
        pTableTituloImage.setWidthPercentage(100);

        PdfPCell cellTitulo = new PdfPCell(new Phrase(ConfigDoc.Empresa.NOME, fontTitile));
        cellTitulo.setHorizontalAlignment(Element.ALIGN_CENTER);
        cellTitulo.setBorder(0);
        cellTitulo.setPaddingTop(20f);
        cellTitulo.setPaddingLeft(70f);
        pTableTitulo.addCell(cellTitulo);
        cellTitulo = new PdfPCell(new Phrase("Recibo N ".toUpperCase() + map.get(IDAMORTIZACAO), fontRecibo));
        cellTitulo.setVerticalAlignment(Element.ALIGN_BOTTOM);
        cellTitulo.setHorizontalAlignment(Element.ALIGN_RIGHT);
        cellTitulo.setBorder(0);
        pTableTitulo.addCell(cellTitulo);

        cellTitulo = new PdfPCell(new Phrase(ConfigDoc.Empresa.ENDERECO + ", " + ConfigDoc.Empresa.CAIXAPOSTAL
                + ", " + ConfigDoc.Empresa.TELEFAX, fontTitileShort));
        cellTitulo.setHorizontalAlignment(Element.ALIGN_CENTER);
        cellTitulo.setPaddingLeft(70f);
        cellTitulo.setBorder(0);
        pTableTitulo.addCell(cellTitulo);
        cellTitulo = new PdfPCell(new Phrase(" ", fontTitileShort));
        cellTitulo.setPaddingBottom(0f);
        cellTitulo.setPaddingTop(0f);
        cellTitulo.setBorder(0);
        pTableTitulo.addCell(cellTitulo);

        cellTitulo = new PdfPCell(new Phrase(ConfigDoc.Empresa.REPUBLICA, fontTitileShort));
        cellTitulo.setHorizontalAlignment(Element.ALIGN_CENTER);
        cellTitulo.setBorder(0);
        cellTitulo.setPaddingLeft(70f);
        pTableTitulo.addCell(cellTitulo);
        cellTitulo = new PdfPCell(new Phrase(" ", fontTitileShort));
        cellTitulo.setPaddingBottom(0f);
        cellTitulo.setPaddingTop(0f);
        cellTitulo.setBorder(0);
        pTableTitulo.addCell(cellTitulo);

        cellTitulo = new PdfPCell(new Phrase(ConfigDoc.Empresa.EMAIL, fontTitileShort));
        cellTitulo.setHorizontalAlignment(Element.ALIGN_CENTER);
        cellTitulo.setBorder(0);
        cellTitulo.setPaddingLeft(70f);
        pTableTitulo.addCell(cellTitulo);
        cellTitulo = new PdfPCell(new Phrase(" ", fontTitileShort));
        cellTitulo.setPaddingBottom(0f);
        cellTitulo.setPaddingTop(0f);
        cellTitulo.setBorder(0);
        pTableTitulo.addCell(cellTitulo);

        cellTitulo = new PdfPCell(new Phrase("Ordem de receita / recibo".toUpperCase(), fontRecibo));
        cellTitulo.setHorizontalAlignment(Element.ALIGN_CENTER);
        cellTitulo.setBorder(0);
        cellTitulo.setPaddingLeft(70f);
        pTableTitulo.addCell(cellTitulo);
        cellTitulo = new PdfPCell(new Phrase(" ", fontTitileShort));
        cellTitulo.setVerticalAlignment(Element.ALIGN_TOP);
        cellTitulo.setPaddingBottom(30f);
        cellTitulo.setPaddingTop(0f);
        cellTitulo.setBorder(0);
        pTableTitulo.addCell(cellTitulo);

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

        PdfPCell cellImagem = new PdfPCell(imageEmpresa);
        cellImagem.setBorder(PdfPCell.NO_BORDER);
        cellImagem.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
        cellImagem.setHorizontalAlignment(PdfPCell.ALIGN_RIGHT);

        PdfPCell cellpTableTitulo = new PdfPCell(pTableTitulo);
        cellpTableTitulo.setBorder(PdfPCell.NO_BORDER);
        cellpTableTitulo.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);

        pTableTituloImage.addCell(cellImagem);
        pTableTituloImage.addCell(cellpTableTitulo);

        PdfPCell cellpTableTituloPrincipal = new PdfPCell(pTableTituloImage);
        cellpTableTituloPrincipal.setBorder(PdfPCell.NO_BORDER);

        pTablePrincipal.addCell(cellpTableTituloPrincipal);

        PdfPTable pTableDataCaixaMontante = new PdfPTable(new float[] { 35f, 5f, 60f });
        pTableDataCaixaMontante.setWidthPercentage(100f);

        PdfPCell cellDataCaixaMontante = new PdfPCell(new Phrase(" ", fontRecibo));
        cellDataCaixaMontante.setBorder(0);
        pTableDataCaixaMontante.addCell(cellDataCaixaMontante);
        pTableDataCaixaMontante.addCell(cellDataCaixaMontante);
        cellDataCaixaMontante = new PdfPCell();
        cellDataCaixaMontante.setBorder(0);
        Paragraph p = new Paragraph();
        p.add(new Phrase("Data: ".toUpperCase(), fontRecibo));

        p.add(new Phrase(converterData(map.get(REGISTROAMORTIZACAO), 1), fontReciboTxt));
        p.setAlignment(Element.ALIGN_RIGHT);
        cellDataCaixaMontante.addElement(p);
        cellDataCaixaMontante.setPaddingBottom(5f);
        pTableDataCaixaMontante.addCell(cellDataCaixaMontante);

        cellDataCaixaMontante = new PdfPCell();
        p = new Paragraph();
        p.add(new Phrase("Caixa de: ".toUpperCase(), fontRecibo));
        p.add(new Phrase("So Tom", fontReciboTxt));
        p.setAlignment(Element.ALIGN_LEFT);
        cellDataCaixaMontante.addElement(p);
        cellDataCaixaMontante.setPaddingTop(-2f);
        cellDataCaixaMontante.setPaddingBottom(5f);
        cellDataCaixaMontante.setBorderColor(BaseColor.BLUE.darker().darker().darker());
        pTableDataCaixaMontante.addCell(cellDataCaixaMontante);

        cellDataCaixaMontante = new PdfPCell(new Phrase(" ", fontRecibo));
        cellDataCaixaMontante.setBorder(0);
        pTableDataCaixaMontante.addCell(cellDataCaixaMontante);

        cellDataCaixaMontante = new PdfPCell();
        p = new Paragraph();
        p.add(new Phrase("Montante: ".toUpperCase(), fontRecibo));

        Double montade = Moeda.arrendodamento(toString(map.get(VALORAMORTIZADO)));

        //            SimpleDateFormat sdf = new SimpleDateFormat("dd-MM-yyyy HH:");
        Object dRegistro = map.get(DATAREGAPOLICE);
        montade *= valorCompra(map.get(SIGLAMOEDA) + "", dRegistro);

        p.add(new Phrase(converterMoeda(montade, "STD") + "", fontReciboTxt));
        p.setAlignment(Element.ALIGN_LEFT);
        cellDataCaixaMontante.addElement(p);
        cellDataCaixaMontante.setPaddingTop(-2f);
        cellDataCaixaMontante.setPaddingBottom(5f);
        cellDataCaixaMontante.setBorderColor(BaseColor.BLUE.darker().darker().darker());
        pTableDataCaixaMontante.addCell(cellDataCaixaMontante);

        PdfPCell cellDataCaixaMontantePrincipal = new PdfPCell(pTableDataCaixaMontante);
        cellDataCaixaMontantePrincipal.setBorder(PdfPCell.NO_BORDER);

        pTablePrincipal.addCell(cellDataCaixaMontantePrincipal);

        PdfPTable pTableConteudo = new PdfPTable(new float[] { 40, 60 });
        pTableConteudo.setWidthPercentage(100f);
        PdfPCell cellConteudo = new PdfPCell();
        cellConteudo.setBorder(0);

        Paragraph pConteudo = new Paragraph();
        pConteudo.add(new Phrase("N Assegurado: ".toUpperCase(), fontConteudo));
        pConteudo.add(new Phrase(map.get(NUMREGISTRO) + "\n", fontConteudoTxt));

        /**
         * For alter
         */
        pConteudo.add(new Phrase("Prmio Liquido: ".toUpperCase(), fontConteudo));
        pConteudo.add(new Phrase(converterMoeda(map.get(TOTALBRUTO), map.get(SIGLAMOEDA) + "") + "\n",
                fontConteudoTxt));

        pConteudo.add(new Phrase("Impostos: ".toUpperCase(), fontConteudo));
        pConteudo.add(new Phrase(converterMoeda(impostosCalculo(map.get(TOTAl), map.get(IMPOSTOCONSUMO)),
                map.get(SIGLAMOEDA) + "") + "\n", fontConteudoTxt));

        pConteudo.add(new Phrase("Impostos Selo: ".toUpperCase(), fontConteudo));
        pConteudo.add(new Phrase(
                converterMoeda(impostosCalculo(map.get(TOTAl), map.get(IMPOSTOSELO)), map.get(SIGLAMOEDA) + "")
                        + "\n",
                fontConteudoTxt));

        pConteudo.add(new Phrase("FGA: ", fontConteudo));
        pConteudo.add(new Phrase(
                converterMoeda(impostosCalculo(map.get(TOTAl), map.get(MOTORFOUND)), map.get(SIGLAMOEDA) + "")
                        + "\n",
                fontConteudoTxt));

        pConteudo.add(new Phrase("Total: ".toUpperCase(), fontConteudo));
        pConteudo.add(
                new Phrase(converterMoeda(map.get(TOTAl), map.get(SIGLAMOEDA) + "") + "\n", fontConteudoTxt));

        pConteudo.add(new Phrase("Efeito: ".toUpperCase(), fontConteudo));
        pConteudo.add(new Phrase(converterData(map.get(EFEITO), 1) + "\n", fontConteudoTxt));

        pConteudo.add(new Phrase("Vencimento: ".toUpperCase(), fontConteudo));
        pConteudo.add(new Phrase(converterData(map.get(VENCIMENTO), 1) + "\n", fontConteudoTxt));

        cellConteudo.addElement(pConteudo);
        pTableConteudo.addCell(cellConteudo);

        cellConteudo = new PdfPCell();
        cellConteudo.setBorder(0);

        pConteudo = new Paragraph();
        pConteudo.add(new Phrase("Recebido do Sr: ".toUpperCase(), fontConteudo));
        pConteudo.add(new Phrase(map.get(CLIENTE) + "\n", fontConteudoTxt));

        PdfPTable pTableNomeCod = new PdfPTable(new float[] { 70, 30 });
        pTableNomeCod.setWidthPercentage(100);

        Paragraph pNomeCod = new Paragraph();
        pNomeCod.add(new Phrase("Nome do Assegurado/Pagador: ".toUpperCase(), fontConteudo));
        pNomeCod.add(new Phrase(map.get(CLIENTE) + "", fontConteudoTxt));
        PdfPCell cellNomeCod = new PdfPCell();
        cellNomeCod.addElement(pNomeCod);
        cellNomeCod.setBorder(0);
        cellNomeCod.setPaddingTop(-2f);
        cellNomeCod.setPaddingBottom(2f);
        pTableNomeCod.addCell(cellNomeCod);

        cellNomeCod = new PdfPCell();
        pNomeCod = new Paragraph();
        pNomeCod.add(new Phrase("Codigo: ".toUpperCase(), fontConteudo));
        pNomeCod.add(new Phrase(" ", fontConteudoTxt));
        cellNomeCod.addElement(pNomeCod);
        cellNomeCod.setBorder(0);
        cellNomeCod.setPaddingTop(-2f);
        cellNomeCod.setPaddingBottom(2f);
        pTableNomeCod.addCell(cellNomeCod);

        pNomeCod = new Paragraph();
        pNomeCod.add(new Phrase("Nome do Intermedirio: ".toUpperCase(), fontConteudo));
        pNomeCod.add(new Phrase(" ", fontConteudoTxt));
        cellNomeCod = new PdfPCell();
        cellNomeCod.addElement(pNomeCod);
        cellNomeCod.setBorder(0);
        cellNomeCod.setPaddingTop(-2f);
        cellNomeCod.setPaddingBottom(2f);
        pTableNomeCod.addCell(cellNomeCod);

        cellNomeCod = new PdfPCell();
        pNomeCod = new Paragraph();
        pNomeCod.add(new Phrase("Codigo: ".toUpperCase(), fontConteudo));
        pNomeCod.add(new Phrase(" ", fontConteudoTxt));
        cellNomeCod.addElement(pNomeCod);
        cellNomeCod.setBorder(0);
        cellNomeCod.setPaddingTop(-2f);
        cellNomeCod.setPaddingBottom(2f);
        pTableNomeCod.addCell(cellNomeCod);

        pConteudo.add(pTableNomeCod);

        JTextPane jtp = new JTextPane();
        Double valor = Moeda.arrendodamento((map.get(VALORPRESTACAO) + ""));
        valor *= valorCompra(map.get(SIGLAMOEDA) + "", dRegistro);
        Moeda.EscreverEstenso(valor, jtp, "Dobras");

        pConteudo.add(new Phrase("A soma (por extenso) ".toUpperCase(), fontConteudo));
        pConteudo.add(new Phrase(jtp.getText().trim() + "\n", fontConteudoTxt));

        PdfPTable pTableApoliceDatasP = new PdfPTable(new float[] { 20, 80 });
        pTableApoliceDatasP.setWidthPercentage(100);
        PdfPTable pTableApoliceDatas = new PdfPTable(new float[] { 60, 40 });
        pTableApoliceDatas.setWidthPercentage(100);

        for (int i = 0; i < 1; i++) {
            PdfPCell cellApolice = new PdfPCell();
            Paragraph pApolice = new Paragraph();
            pApolice.add(new Phrase("N ", fontConteudo));
            pApolice.add(new Phrase(map.get(APOLICA) + "", fontConteudoTxt));
            cellApolice.addElement(pApolice);
            cellApolice.setPaddingTop(-2f);
            cellApolice.setPaddingBottom(2f);
            cellApolice.setBorder(0);
            pTableApoliceDatas.addCell(cellApolice);

            PdfPCell cellDatas = new PdfPCell();
            Paragraph pDatas = new Paragraph();
            pDatas.add(new Phrase("Data: ".toUpperCase(), fontConteudo));
            pDatas.add(new Phrase(converterData(map.get(DATAREGAPOLICE), 2) + "", fontConteudoTxt));
            cellDatas.addElement(pDatas);
            cellDatas.setBorder(0);
            cellDatas.setPaddingTop(-2f);
            cellDatas.setPaddingBottom(2f);
            pTableApoliceDatas.addCell(cellDatas);
        }
        PdfPCell cellApoliceP = new PdfPCell(new Phrase("Apolices".toUpperCase(), fontConteudo));
        cellApoliceP.setVerticalAlignment(Element.ALIGN_MIDDLE);
        cellApoliceP.setBorder(0);
        pTableApoliceDatasP.addCell(cellApoliceP);
        cellApoliceP = new PdfPCell(pTableApoliceDatas);
        cellApoliceP.setBorder(0);
        pTableApoliceDatasP.addCell(cellApoliceP);

        pConteudo.add(pTableApoliceDatasP);
        //            
        PdfPTable pTableTipoPagemento = new PdfPTable(new float[] { 70f, 30f });
        pTableTipoPagemento.setWidthPercentage(100f);

        PdfPCell cellTipoPageme = new PdfPCell();
        Paragraph pDatas = new Paragraph();
        pDatas.add(new Phrase("Pagamento: ".toUpperCase(), fontConteudo));
        pDatas.add(new Phrase(map.get(TIPOPAGAMENTO) + " ", fontConteudoTxt));
        cellTipoPageme.addElement(pDatas);
        cellTipoPageme.setBorder(0);
        cellTipoPageme.setPaddingTop(-2f);
        cellTipoPageme.setPaddingBottom(2f);
        //           cellTipoPageme.setBorderColor(BaseColor.BLUE.darker().darker().darker());
        //           cellTipoPageme.setBorderWidthTop((i==0)?0.5f:0f);
        //           cellTipoPageme.setBorderWidthBottom(0.5f);
        pTableTipoPagemento.addCell(cellTipoPageme);

        cellTipoPageme = new PdfPCell();
        pDatas = new Paragraph();
        pDatas.add(new Phrase("N ".toUpperCase(), fontConteudo));
        pDatas.add(new Phrase(toString(map.get(DOCUMENTOAMORTIZACAO)) + " ", fontConteudoTxt));
        cellTipoPageme.addElement(pDatas);
        cellTipoPageme.setBorder(0);
        cellTipoPageme.setPaddingTop(-2f);
        cellTipoPageme.setPaddingBottom(2f);
        //                cellTipoPageme.setBorderColor(BaseColor.BLUE.darker().darker().darker());
        //                cellTipoPageme.setBorderWidthTop((i==0)?0.5f:0f);
        //                cellTipoPageme.setBorderWidthBottom(0.5f);
        pTableTipoPagemento.addCell(cellTipoPageme);

        pConteudo.add(pTableTipoPagemento);

        cellConteudo.addElement(pConteudo);
        pTableConteudo.addCell(cellConteudo);

        PdfPCell cellConteudoPrincipal = new PdfPCell(new PdfPTable(pTableConteudo));
        cellConteudoPrincipal.setBorder(PdfPCell.NO_BORDER);
        pTablePrincipal.addCell(cellConteudoPrincipal);

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

        Font fontConteudoTxt_acess = FontFactory.getFont(ConfigDoc.Fontes.FONT, BaseFont.WINANSI,
                BaseFont.EMBEDDED, 5f, Font.ITALIC, BaseColor.BLACK.darker().darker().darker());
        Font fontConteudo_acess = FontFactory.getFont(ConfigDoc.Fontes.FONTB, BaseFont.WINANSI,
                BaseFont.EMBEDDED, 5f, Font.NORMAL, BaseColor.BLUE.darker().darker());

        PdfPCell cellAcessorio = new PdfPCell();
        Paragraph pAcessorio = new Paragraph();
        pAcessorio.add(new Phrase("Acessrios: ".toUpperCase(), fontConteudo_acess));
        pAcessorio.add(new Phrase(
                (map.get(ACCESSORIO) == null) ? " " : (map.get(ACCESSORIO) + "").replaceAll("\n", " "),
                fontConteudoTxt_acess));
        cellAcessorio.addElement(pAcessorio);
        cellAcessorio.setColspan(2);
        cellAcessorio.setBorder(0);
        cellAcessorio.setPaddingBottom(4f);
        cellAcessorio.setPaddingTop(-2f);
        pTableAssinatura.addCell(cellAcessorio);

        PdfPCell cellLinhaAssina = new PdfPCell();
        Paragraph pAssinatura = new Paragraph();
        pAssinatura.add(new Paragraph("_________________________________", fontConteudo));
        pAssinatura.add(new Paragraph("                Carimbo e Assinatura", fontConteudo));
        pAssinatura.setAlignment(Element.ALIGN_CENTER);
        cellLinhaAssina.addElement(pAssinatura);
        cellLinhaAssina.setPaddingBottom(2f);
        cellLinhaAssina.setBorder(0);
        cellLinhaAssina.setPaddingTop(25f);
        pTableAssinatura.addCell(cellLinhaAssina);

        PdfPCell cellCambio = new PdfPCell();
        Paragraph pCombio = new Paragraph();
        pCombio.add(new Phrase("Cambio (USD): ".toUpperCase(), fontConteudo));
        pCombio.add(new Phrase(converterMoeda(valorCompra("USD", dRegistro), "") + "\n", fontConteudoTxt));
        pCombio.add(new Phrase("Cambio (EUR): ".toUpperCase(), fontConteudo));
        pCombio.add(new Phrase(converterMoeda(valorCompra("EUR", dRegistro), "") + "\n", fontConteudoTxt));
        cellCambio.addElement(pCombio);
        cellCambio.setBorder(0);
        cellCambio.setPaddingTop(-2f);
        cellCambio.setPaddingBottom(2f);
        pTableAssinatura.addCell(cellCambio);

        PdfPCell cellpTableAssinaturaPrincipal = new PdfPCell(pTableAssinatura);
        cellpTableAssinaturaPrincipal.setBorder(PdfPCell.NO_BORDER);
        pTablePrincipal.addCell(new PdfPCell(cellpTableAssinaturaPrincipal));

        //            pTableAssinatura.writeSelectedRows(-1, 2, 10, 70, writer.getDirectContent());
        //            pTableImagem.writeSelectedRows(-1, 2, 52.5f, 402.5f, writer.getDirectContent());
    } catch (BadElementException | IOException ex) {
        Logger.getLogger(ReciboPagamento.class.getName()).log(Level.SEVERE, null, ex);
    }
    return pTablePrincipal;
}

From source file:Export.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   www  .j  a v a  2s .c  o  m*/

    //        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.SeguroIncendio.java

public String criarDoc(String numApolice, String numCliente, Contrato c, IncendioBean ib, String user,
        String sigla, String arquivo) {
    try {/*from w w  w .  ja  va  2  s  . c  om*/
        SimpleDateFormat sdf = new SimpleDateFormat("dd 'DE' MMMM 'DE' yyyy", new Locale("pt", "BR"));
        SimpleDateFormat sdfS = new SimpleDateFormat("dd/MM/yyyy", new Locale("pt", "BR"));
        SimpleDateFormat sdf1 = new SimpleDateFormat("dd-MM-yyyy hh'.'mm'.'ss");

        Font fontCabecalhoN = FontFactory.getFont(Fontes.FONTB, BaseFont.WINANSI, BaseFont.EMBEDDED, 9.5f);
        Font fontCorpo = FontFactory.getFont(Fontes.FONT, BaseFont.WINANSI, BaseFont.EMBEDDED, 9f);
        //            Font fontTableCo= new Font(Font.FontFamily.HELVETICA,9f , Font.NORMAL);
        //            Font fontTableCa= new Font(Font.FontFamily.HELVETICA,9.5f , Font.BOLD);
        Font fontCorpoP = FontFactory.getFont(Fontes.FONT, BaseFont.WINANSI, BaseFont.EMBEDDED, 8f);
        Font fontCorpoN = FontFactory.getFont(Fontes.FONTB, BaseFont.WINANSI, BaseFont.EMBEDDED, 9f);
        //            Font fontCorpoNG= FontFactory.getFont(Fontes.FONTB, BaseFont.WINANSI, BaseFont.EMBEDDED ,8.5f );
        Font fontCorpoNGT = FontFactory.getFont(Fontes.FONTB, BaseFont.WINANSI, BaseFont.EMBEDDED, 10f);
        Font fontCabecalhoNG = FontFactory.getFont(Fontes.FONTB, BaseFont.WINANSI, BaseFont.EMBEDDED, 16f,
                Font.UNDERLINE);
        Font fontUK = FontFactory.getFont(Fontes.FONT, BaseFont.WINANSI, BaseFont.EMBEDDED, 5.5f, Font.ITALIC);

        PdfPTable pTableEmpresaPricipal = new PdfPTable(new float[] { 25f, 75f });
        pTableEmpresaPricipal.setWidthPercentage(90f);
        PdfPTable pTableEmpresaInforImpres1 = new PdfPTable(1);
        //            PdfPTable pTableEmpresaInforImpres2= new PdfPTable(1);
        PdfPTable pTableEmpresaInforImpres5 = new PdfPTable(1);

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

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

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

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

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

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

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

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

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

        pTableEmpresaInforImpres1.addCell(pCellPolice);

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

        pTableEmpresaInforImpres5.addCell(cellTabela3);

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

        PdfPCell cellTabela6 = new PdfPCell(imageEmpresa);
        cellTabela6.setBorder(0);

        pTableEmpresaPricipal.addCell(cellTabela6);
        pTableEmpresaPricipal.addCell(cellTabela5);

        //            PdfPTable pTableSeguro =new PdfPTable(1);
        PdfPTable pTableCliente = new PdfPTable(1);
        pTableCliente.setWidthPercentage(90f);

        Phrase phraseUK;

        PdfPTable pTableTitulo = new PdfPTable(1);
        Paragraph pTitulo = new Paragraph("", fontCorpo);
        phraseUK = new Phrase("Formulario de SEguro Incndio".toUpperCase(), fontCorpoNGT);
        pTitulo.add(phraseUK);
        phraseUK = new Phrase("\nfire insurance schedule".toUpperCase(), fontUK);
        pTitulo.add(phraseUK);
        PdfPCell cellTitulo = new PdfPCell(pTitulo);
        cellTitulo.setBorder(0);
        cellTitulo.setHorizontalAlignment(Element.ALIGN_CENTER);
        pTableTitulo.addCell(cellTitulo);

        ClienteI ci = new ClienteI(numCliente);

        Paragraph p = new Paragraph("", fontCorpo);
        phraseUK = new Phrase("1 - Informaes Cliente".toUpperCase(), fontCorpoNGT);
        p.add(phraseUK);
        phraseUK = new Phrase("\n(1 - Customer information)".toUpperCase(), fontUK);
        p.add(phraseUK);
        PdfPCell cellTituloTsbleSegurado = new PdfPCell(p);
        cellTituloTsbleSegurado.setBorder(0);

        Paragraph pCl = new Paragraph();
        pCl.add(new Phrase(ci.getNOMEL_(), fontCorpo));
        pCl.add(new Phrase(ci.getNOME_(), fontCorpoN));
        pCl.add(new Phrase("\n(THE INSURED)", fontUK));
        PdfPCell cellNome = new PdfPCell(new Phrase(pCl));
        cellNome.setBorder(0);

        pCl = new Paragraph();
        pCl.add(new Phrase(ci.getENDERECOL_(), fontCorpo));
        pCl.add(new Phrase(ci.getENDERECO_(), fontCorpoN));
        pCl.add(new Phrase("\nAddress".toUpperCase(), fontUK));
        PdfPCell cellEndereco = new PdfPCell(pCl);
        cellEndereco.setBorder(0);

        pCl = new Paragraph();
        pCl.add(new Phrase("A SEGURADORA: ", fontCorpo));
        pCl.add(new Phrase("NICON SEGUROS S.A", fontCorpoN));
        pCl.add(new Phrase("\n(THE COMPANY)", fontUK));
        PdfPCell cellNCliente = new PdfPCell(pCl);
        cellNCliente.setBorder(0);

        pCl = new Paragraph();
        pCl.add(new Phrase(ci.getPROFISSAOL_(), fontCorpo));
        pCl.add(new Phrase(ci.getPROFISSAO_(), fontCorpoN));
        pCl.add(new Phrase("\n(occupation)".toUpperCase(), fontUK));
        PdfPCell cellProfissao = new PdfPCell(pCl);
        cellProfissao.setBorder(0);

        pCl = new Paragraph();
        pCl.add(new Phrase(ci.getLOCALTRABALHOL_(), fontCorpo));
        pCl.add(new Phrase(ci.getLOCALTRABALHO_(), fontCorpoN));
        pCl.add(new Phrase("\n(workplace)", fontUK));
        PdfPCell cellLocalTrabalho = new PdfPCell(pCl);
        cellLocalTrabalho.setBorder(0);

        cellTituloTsbleSegurado.setPaddingBottom(8f);
        pTableCliente.addCell(cellTituloTsbleSegurado);
        cellNome.setPaddingBottom(8f);
        pTableCliente.addCell(cellNome);
        cellEndereco.setPaddingBottom(8f);
        pTableCliente.addCell(cellEndereco);
        cellProfissao.setPaddingBottom(8f);
        pTableCliente.addCell(cellProfissao);
        cellLocalTrabalho.setPaddingBottom(8f);
        pTableCliente.addCell(cellLocalTrabalho);
        cellNCliente.setPaddingBottom(8f);
        pTableCliente.addCell(cellNCliente);
        //            CellData.setPaddingBottom(8f);
        pTableCliente.addCell(cellNull);

        //            PdfPTable pTableDadosTitulo= new PdfPTable(1);
        //            PdfPCell cellDadosTitulo= new PdfPCell(new Phrase());
        //            cellDadosTitulo.setBorder(0);

        Paragraph pInfoTitulo = new Paragraph("".toUpperCase(), fontCorpo);
        phraseUK = new Phrase("2 - Informaes do seguro".toUpperCase(), fontCorpoN);
        pInfoTitulo.add(phraseUK);
        phraseUK = new Phrase("\n(2 - insurance information)".toUpperCase(), fontUK);
        pInfoTitulo.add(phraseUK);

        Paragraph pInfoPro1 = new Paragraph("".toUpperCase(), fontCorpo);
        phraseUK = new Phrase("Valor Da propriedade segurada: ".toUpperCase(), fontCorpo);
        pInfoPro1.add(phraseUK);
        phraseUK = new Phrase(c.getPremioLiquidoMoeda().toUpperCase(), fontCorpo);
        pInfoPro1.add(phraseUK);
        phraseUK = new Phrase("\n(insured property value)".toUpperCase(), fontUK);
        pInfoPro1.add(phraseUK);

        Paragraph pInfoPro = new Paragraph("".toUpperCase(), fontCorpo);
        phraseUK = new Phrase("Endereo da propriedade segurada: ".toUpperCase(), fontCorpo);
        pInfoPro.add(phraseUK);
        phraseUK = new Phrase(ib.getIncendio().getEndereco(), fontCorpo);
        pInfoPro.add(phraseUK);
        phraseUK = new Phrase("\n(property address insured)".toUpperCase(), fontUK);
        pInfoPro.add(phraseUK);

        Paragraph pInfo1 = new Paragraph("".toUpperCase(), fontCorpoN);
        phraseUK = new Phrase("Riscos Bascos:".toUpperCase(), fontCorpoN);
        pInfo1.add(phraseUK);
        phraseUK = new Phrase("\n(basic risks)".toUpperCase(), fontUK);
        pInfo1.add(phraseUK);

        Paragraph pInfo2 = new Paragraph("".toUpperCase(), fontCorpo);
        phraseUK = new Phrase("-Edifcio".toUpperCase(), fontCorpo);
        pInfo2.add(phraseUK);
        phraseUK = new Phrase("\n(Building)".toUpperCase(), fontUK);
        pInfo2.add(phraseUK);

        Paragraph pInfo3 = new Paragraph("".toUpperCase(), fontCorpo);
        phraseUK = new Phrase("-Maquinaria: ".toUpperCase() + testeUsado(""), fontCorpo);
        pInfo3.add(phraseUK);
        phraseUK = new Phrase("\n(Machinery)".toUpperCase(), fontUK);
        pInfo3.add(phraseUK);

        Paragraph pInfo4 = new Paragraph("".toUpperCase(), fontCorpo);
        phraseUK = new Phrase("-Contedos".toUpperCase(), fontCorpo);
        pInfo4.add(phraseUK);
        phraseUK = new Phrase("\n(contents)".toUpperCase(), fontUK);
        pInfo4.add(phraseUK);

        Paragraph pInfo5 = new Paragraph("".toUpperCase(), fontCorpo);
        phraseUK = new Phrase("-Reserva: ".toUpperCase() + testeUsado(""), fontCorpo);
        pInfo5.add(phraseUK);
        phraseUK = new Phrase("\n(STOKS) NA".toUpperCase(), fontUK);
        pInfo5.add(phraseUK);

        Paragraph pInfo6 = new Paragraph("", fontCorpo);
        phraseUK = new Phrase("-Risco Para com Terceiro/Vizinhos: ".toUpperCase() + testeUsado(""), fontCorpo);
        pInfo6.add(phraseUK);
        phraseUK = new Phrase("\n(third party/neighbour's risk )".toUpperCase(), fontUK);
        pInfo6.add(phraseUK);

        Paragraph pInfo7 = new Paragraph("".toUpperCase(), fontCorpo);
        phraseUK = new Phrase("-Renda: ".toUpperCase() + testeUsado(""), fontCorpo);
        pInfo7.add(phraseUK);
        phraseUK = new Phrase("\n(RENT)".toUpperCase(), fontUK);
        pInfo7.add(phraseUK);

        Paragraph pInfo8 = new Paragraph("".toUpperCase(), fontCorpo);
        phraseUK = new Phrase("-Despesas com perito: ".toUpperCase() + testeUsado(""), fontCorpo);
        pInfo8.add(phraseUK);
        phraseUK = new Phrase("\n(expert fees)".toUpperCase(), fontUK);
        pInfo8.add(phraseUK);

        Paragraph pInfo9 = new Paragraph("".toUpperCase(), fontCorpo);
        phraseUK = new Phrase("-risco especiais: ".toUpperCase() + testeUsado(""), fontCorpo);
        pInfo9.add(phraseUK);
        phraseUK = new Phrase("\n(Special risk)".toUpperCase(), fontUK);
        pInfo9.add(phraseUK);

        Paragraph pInfo10 = new Paragraph("".toUpperCase(), fontCorpo);
        phraseUK = new Phrase("-impactos: ".toUpperCase() + testeUsado(""), fontCorpo);
        pInfo10.add(phraseUK);
        phraseUK = new Phrase("\n(impacts)".toUpperCase(), fontUK);
        pInfo10.add(phraseUK);

        Paragraph pInfo11 = new Paragraph("".toUpperCase(), fontCorpo);
        phraseUK = new Phrase("-motim & greve".toUpperCase(), fontCorpo);
        pInfo11.add(phraseUK);
        phraseUK = new Phrase("\n(Riot & Strike)".toUpperCase(), fontUK);
        pInfo11.add(phraseUK);

        Paragraph pInfo12 = new Paragraph("".toUpperCase(), fontCorpo);
        phraseUK = new Phrase(
                "-incndio florestal: ".toUpperCase() + testeUsado(ib.getIncendioRisco().getIncendioFId()),
                fontCorpo);
        pInfo12.add(phraseUK);
        phraseUK = new Phrase("\n(bush fire)".toUpperCase(), fontUK);
        pInfo12.add(phraseUK);

        Paragraph pInfo12_1 = new Paragraph("".toUpperCase(), fontCorpo);
        phraseUK = new Phrase("-exploso de tubos".toUpperCase(), fontCorpo);
        pInfo12_1.add(phraseUK);
        phraseUK = new Phrase("\n(Burst pipes)".toUpperCase(), fontUK);
        pInfo12_1.add(phraseUK);

        Paragraph pInfo12_2 = new Paragraph("".toUpperCase(), fontCorpo);
        phraseUK = new Phrase(
                "-danos maliciosos: ".toUpperCase() + testeUsado(ib.getIncendioRisco().getDanoId()), fontCorpo);
        pInfo12_2.add(phraseUK);
        phraseUK = new Phrase("\n(malicious damage)".toUpperCase(), fontUK);
        pInfo12_2.add(phraseUK);

        Paragraph pInfo13 = new Paragraph("".toUpperCase(), fontCorpo);
        phraseUK = new Phrase("-Exploso: ".toUpperCase() + testeUsado(ib.getIncendioRisco().getExplosaoId()),
                fontCorpo);
        pInfo13.add(phraseUK);
        phraseUK = new Phrase("\n(Explosion)".toUpperCase(), fontUK);
        pInfo13.add(phraseUK);

        Paragraph pInfo14 = new Paragraph("".toUpperCase(), fontCorpo);
        phraseUK = new Phrase("-terramoto: ".toUpperCase() + testeUsado(ib.getIncendioRisco().getTerramotoId()),
                fontCorpo);
        pInfo14.add(phraseUK);
        phraseUK = new Phrase("\n(earthquake)".toUpperCase(), fontUK);
        pInfo14.add(phraseUK);

        Paragraph pInfo14_1 = new Paragraph("", fontCorpo);
        phraseUK = new Phrase(
                "-Queda de aeronave: ".toUpperCase() + testeUsado(ib.getIncendioRisco().getRiscoAviaoId()),
                fontCorpo);
        pInfo14_1.add(phraseUK);
        phraseUK = new Phrase("\n(plane crash)".toUpperCase(), fontUK);
        pInfo14_1.add(phraseUK);

        Paragraph pInfo15 = new Paragraph("", fontCorpo);
        phraseUK = new Phrase("-trovoada, tempestade e inundao: ".toUpperCase()
                + testeUsado(ib.getIncendioRisco().getTempestadeId()), fontCorpo);
        pInfo15.add(phraseUK);
        phraseUK = new Phrase("\n(storm, tempest and flood)".toUpperCase(), fontUK);
        pInfo15.add(phraseUK);

        PdfPCell CellData = new PdfPCell(pInfoTitulo);
        CellData.setBorder(0);
        CellData.setPaddingBottom(8f);
        pTableCliente.addCell(CellData);

        CellData = new PdfPCell(pInfoPro);
        CellData.setBorder(0);
        CellData.setPaddingBottom(8f);
        pTableCliente.addCell(CellData);

        CellData = new PdfPCell(pInfoPro1);
        CellData.setBorder(0);
        CellData.setPaddingBottom(8f);
        pTableCliente.addCell(CellData);
        //            cellDadosTitulo.addElement(pInfoPro1);

        CellData = new PdfPCell(pInfo1);
        CellData.setBorder(0);
        CellData.setPaddingBottom(8f);
        pTableCliente.addCell(CellData);
        //            cellDadosTitulo.addElement(pInfo1);

        CellData = new PdfPCell(pInfo2);
        CellData.setBorder(0);
        CellData.setPaddingBottom(8f);
        pTableCliente.addCell(CellData);
        //            cellDadosTitulo.addElement(pInfo2);

        CellData = new PdfPCell(pInfo3);
        CellData.setBorder(0);
        CellData.setPaddingBottom(8f);
        pTableCliente.addCell(CellData);
        //            cellDadosTitulo.addElement(pInfo3);

        CellData = new PdfPCell(pInfo4);
        CellData.setBorder(0);
        pTableCliente.addCell(CellData);
        //            cellDadosTitulo.addElement(pInfo4);

        CellData = new PdfPCell(pInfo5);
        CellData.setBorder(0);
        CellData.setPaddingBottom(8f);
        pTableCliente.addCell(CellData);
        //            cellDadosTitulo.addElement(pInfo5);

        CellData = new PdfPCell(pInfo6);
        CellData.setBorder(0);
        pTableCliente.addCell(CellData);
        //            cellDadosTitulo.addElement(pInfo6);

        CellData = new PdfPCell(pInfo7);
        CellData.setBorder(0);
        CellData.setPaddingBottom(8f);
        pTableCliente.addCell(CellData);
        //            cellDadosTitulo.addElement(pInfo7);

        CellData = new PdfPCell(pInfo8);
        CellData.setBorder(0);
        pTableCliente.addCell(CellData);
        //            cellDadosTitulo.addElement(pInfo8);

        CellData = new PdfPCell(pInfo9);
        CellData.setBorder(0);
        CellData.setPaddingBottom(8f);
        pTableCliente.addCell(CellData);
        //            cellDadosTitulo.addElement(pInfo9);

        CellData = new PdfPCell(pInfo10);
        CellData.setBorder(0);
        CellData.setPaddingBottom(8f);
        pTableCliente.addCell(CellData);
        //            cellDadosTitulo.addElement(pInfo10);

        CellData = new PdfPCell(pInfo11);
        CellData.setBorder(0);
        CellData.setPaddingBottom(8f);
        pTableCliente.addCell(CellData);
        //            cellDadosTitulo.addElement(pInfo11);

        CellData = new PdfPCell(pInfo12);
        CellData.setBorder(0);
        CellData.setPaddingBottom(8f);
        pTableCliente.addCell(CellData);
        //            cellDadosTitulo.addElement(pInfo12);

        CellData = new PdfPCell(pInfo12_1);
        CellData.setBorder(0);
        CellData.setPaddingBottom(8f);
        pTableCliente.addCell(CellData);
        //            cellDadosTitulo.addElement(pInfo12_1);

        CellData = new PdfPCell(pInfo12_2);
        CellData.setBorder(0);
        CellData.setPaddingBottom(8f);
        pTableCliente.addCell(CellData);
        //            cellDadosTitulo.addElement(pInfo12_2);

        CellData = new PdfPCell(pInfo13);
        CellData.setBorder(0);
        CellData.setPaddingBottom(8f);
        pTableCliente.addCell(CellData);
        //            cellDadosTitulo.addElement(pInfo13);

        CellData = new PdfPCell(pInfo14);
        CellData.setBorder(0);
        CellData.setPaddingBottom(8f);
        pTableCliente.addCell(CellData);
        //            cellDadosTitulo.addElement(pInfo14);

        CellData = new PdfPCell(pInfo14_1);
        CellData.setBorder(0);
        CellData.setPaddingBottom(8f);
        pTableCliente.addCell(CellData);
        //            cellDadosTitulo.addElement(pInfo14_1);

        CellData = new PdfPCell(pInfo15);
        CellData.setBorder(0);
        CellData.setPaddingBottom(8f);
        pTableCliente.addCell(CellData);

        pTableCliente.addCell(cellNull);
        //            cellDadosTitulo.addElement(pInfo15);

        //            PdfPCell cellSeguro= new PdfPCell(new Phrase());
        //            cellSeguro.setBorder(0);
        Paragraph pSegTitulo = new Paragraph("".toUpperCase(), fontCorpoN);
        phraseUK = new Phrase("3 - Informaes Montante e periodo de Segurado".toUpperCase(), fontCorpoN);
        pSegTitulo.add(phraseUK);
        phraseUK = new Phrase("\n(3 - Amount information and period of Insured)".toUpperCase(), fontUK);
        pSegTitulo.add(phraseUK);

        Paragraph pSeg1 = new Paragraph("".toUpperCase(), fontCorpo);
        phraseUK = new Phrase("perodo Seguro de: ".toUpperCase(), fontCorpo);
        pSeg1.add(phraseUK);
        phraseUK = new Phrase(sdfS.format(c.getDataInicio()) + " at ".toUpperCase()
                + sdfS.format(c.getDataFim()) + " (16H00 HORAS DA DATA DE EXPIRAo)".toUpperCase(),
                fontCorpoN);
        pSeg1.add(phraseUK);
        phraseUK = new Phrase(
                "\n(preiod of insurance)     (from)     (to)     (4 o'clock in the afternoon of the expiring date)"
                        .toUpperCase(),
                fontUK);
        pSeg1.add(phraseUK);

        Paragraph pSeg2 = new Paragraph("", fontCorpo);
        phraseUK = new Phrase("Data Da renovao: ".toUpperCase(), fontCorpo);
        pSeg2.add(phraseUK);
        phraseUK = new Phrase(
                ((c.getDataRenovacao() == null) ? "" : sdfS.format(c.getDataRenovacao())).toUpperCase(),
                fontCorpo);
        pSeg2.add(phraseUK);
        phraseUK = new Phrase("\n(renewal date)".toUpperCase(), fontUK);
        pSeg2.add(phraseUK);

        //            Paragraph pSeg3= new Paragraph("   Valo".toUpperCase(), fontCorpo);
        //            Paragraph pSeg4= new Paragraph("   Data de Renovao: ".toUpperCase()+, fontCorpo);

        Paragraph pSeg5 = new Paragraph("", fontCorpo);
        phraseUK = new Phrase("valor do primeiro prMio: ".toUpperCase(), fontCorpo);
        pSeg5.add(phraseUK);
        phraseUK = new Phrase(c.getPrimeiroPremio(), fontCorpo);
        pSeg5.add(phraseUK);
        phraseUK = new Phrase("\n(first premiun)".toUpperCase(), fontUK);
        pSeg5.add(phraseUK);

        Paragraph pSeg6 = new Paragraph("".toUpperCase(), fontCorpo);
        phraseUK = new Phrase("Valor do Prmio Anual: ".toUpperCase(), fontCorpo);
        pSeg6.add(phraseUK);
        phraseUK = new Phrase(c.getPremioAnual(), fontCorpo);
        pSeg6.add(phraseUK);
        phraseUK = new Phrase("\n(annuals premium)".toUpperCase(), fontUK);
        pSeg6.add(phraseUK);

        Paragraph pSeg7 = new Paragraph("".toUpperCase(), fontCorpo);
        phraseUK = new Phrase("valor do prmio bruto: ".toUpperCase(), fontCorpo);
        pSeg7.add(phraseUK);
        phraseUK = new Phrase(c.getPremioBrutoMoeda(), fontCorpo);
        pSeg7.add(phraseUK);
        phraseUK = new Phrase("\n(gross premium)".toUpperCase(), fontUK);
        pSeg7.add(phraseUK);

        Paragraph pSeg8 = new Paragraph("".toUpperCase(), fontCorpo);
        phraseUK = new Phrase("menos (SE aplicvel) No".toUpperCase(), fontCorpo);
        pInfo14_1.add(phraseUK);
        phraseUK = new Phrase("\nLESS (if applicable)".toUpperCase(), fontUK);
        pInfo14_1.add(phraseUK);

        Paragraph pSeg9 = new Paragraph("".toUpperCase(), fontCorpo);
        phraseUK = new Phrase("a adicionar: impst. @ 5% + IMpost. sobre selo @ 0.6% = ".toUpperCase(),
                fontCorpo);
        pSeg9.add(phraseUK);
        phraseUK = new Phrase(" ", fontCorpo);
        pSeg9.add(phraseUK);
        phraseUK = new Phrase("\n(add)".toUpperCase(), fontUK);
        pSeg9.add(phraseUK);

        Paragraph pSeg10 = new Paragraph("".toUpperCase(), fontCorpo);
        phraseUK = new Phrase("Valor do prmio liquido a pagar: ".toUpperCase(), fontCorpo);
        pSeg10.add(phraseUK);
        phraseUK = new Phrase(c.getPremioLiquidoMoeda(), fontCorpo);
        pSeg10.add(phraseUK);
        phraseUK = new Phrase("\n(net premium payable)".toUpperCase(), fontUK);
        pSeg10.add(phraseUK);

        //            Paragraph pSeg11= new Paragraph("   outras condies/memorado                                                                              por favor, volte a pgina".toUpperCase(), fontCorpo);
        Paragraph pSeg13 = new Paragraph("   ".toUpperCase(), fontCorpo);

        Paragraph pSegData = new Paragraph("", fontCorpo);
        phraseUK = new Phrase("Data Em: ".toUpperCase(), fontCorpo);
        pSegData.add(phraseUK);
        phraseUK = new Phrase(sdf.format(new Date()).toUpperCase(), fontCorpo);
        pSegData.add(phraseUK);
        phraseUK = new Phrase("\n(DATE IN)".toUpperCase(), fontUK);
        pSegData.add(phraseUK);

        CellData = new PdfPCell(pSegTitulo);
        CellData.setBorder(0);
        pTableCliente.addCell(CellData);
        //            cellSeguro.addElement(pSegTitulo);

        CellData = new PdfPCell(pSeg1);
        CellData.setBorder(0);
        CellData.setPaddingBottom(8f);
        pTableCliente.addCell(CellData);
        //            cellSeguro.addElement(pSeg1);

        CellData = new PdfPCell(pSeg2);
        CellData.setBorder(0);
        CellData.setPaddingBottom(8f);
        pTableCliente.addCell(CellData);
        //            cellSeguro.addElement(pSeg2);

        //            cellSeguro.addElement(pSeg3);
        //            cellSeguro.addElement(pSeg4);

        CellData = new PdfPCell(pSeg5);
        CellData.setBorder(0);
        CellData.setPaddingBottom(8f);
        pTableCliente.addCell(CellData);
        //            cellSeguro.addElement(pSeg5);

        CellData = new PdfPCell(pSeg6);
        CellData.setBorder(0);
        CellData.setPaddingBottom(8f);
        pTableCliente.addCell(CellData);
        //            cellSeguro.addElement(pSeg6);

        CellData = new PdfPCell(pSeg7);
        CellData.setBorder(0);
        CellData.setPaddingBottom(8f);
        pTableCliente.addCell(CellData);
        //            cellSeguro.addElement(pSeg7);

        CellData = new PdfPCell(pSeg8);
        CellData.setBorder(0);
        CellData.setPaddingBottom(8f);
        pTableCliente.addCell(CellData);
        //            cellSeguro.addElement(pSeg8);

        CellData = new PdfPCell(pSeg9);
        CellData.setBorder(0);
        CellData.setPaddingBottom(8f);
        pTableCliente.addCell(CellData);

        //            cellSeguro.addElement(pSeg9);

        CellData = new PdfPCell(pSeg10);
        CellData.setBorder(0);
        CellData.setPaddingBottom(8f);
        pTableCliente.addCell(CellData);
        //            cellSeguro.addElement(pSeg10);

        //            cellSeguro.addElement(pSeg11);

        CellData = new PdfPCell(pSeg13);
        CellData.setBorder(0);
        CellData.setPaddingBottom(8f);
        pTableCliente.addCell(CellData);
        //            cellSeguro.addElement(pSeg13);

        CellData = new PdfPCell(pSegData);
        CellData.setBorder(0);
        pTableCliente.addCell(CellData);
        //            cellSeguro.addElement(pSegData);

        //            pTableCliente.addCell(cellSeguro);

        PdfPTable pTableAssinaturaTitulo = new PdfPTable(1);
        PdfPTable pTableAssinatura = new PdfPTable(new float[] { 50f, 50f });

        Paragraph p1 = new Paragraph(new Phrase("Assinaturas".toUpperCase(), fontCorpoN));
        p1.add(new Phrase("\nsignature".toUpperCase(), fontUK));

        PdfPCell cellAssinatora = new PdfPCell(p1);
        cellAssinatora.setBorder(0);
        cellAssinatora.setHorizontalAlignment(Element.ALIGN_CENTER);
        PdfPCell celllinha1 = new PdfPCell(
                new Phrase("________________________________".toUpperCase(), fontCorpo));
        celllinha1.setBorder(0);
        celllinha1.setHorizontalAlignment(Element.ALIGN_CENTER);
        PdfPCell celllinha2 = new PdfPCell(
                new Phrase("________________________________".toUpperCase(), fontCorpo));
        celllinha2.setBorder(0);
        celllinha2.setHorizontalAlignment(Element.ALIGN_CENTER);

        p1 = new Paragraph(new Phrase("para nicon Seguro sa stp".toUpperCase(), fontCorpoP));
        p1.add(new Phrase("\nFor nicon seguros sa stp".toUpperCase(), fontUK));

        PdfPCell celllinha11 = new PdfPCell(p1);
        celllinha11.setBorder(0);
        celllinha11.setHorizontalAlignment(Element.ALIGN_CENTER);

        p1 = new Paragraph(new Phrase("o segurado".toUpperCase(), fontCorpoP));
        p1.add(new Phrase("\nthe insured".toUpperCase(), fontUK));
        PdfPCell celllinha21 = new PdfPCell(p1);
        celllinha21.setBorder(0);
        celllinha21.setHorizontalAlignment(Element.ALIGN_CENTER);

        pTableAssinaturaTitulo.addCell(cellAssinatora);
        pTableAssinatura.addCell(celllinha1);
        pTableAssinatura.addCell(celllinha2);
        pTableAssinatura.addCell(celllinha11);
        pTableAssinatura.addCell(celllinha21);

        Document documento = new Document();
        documento.setPageSize(PageSize.A4);
        documento.setMargins(20f, 20f, 35f, 60f);

        File ff = new File(arquivo + "/" + user + "/Seguro Incendio/");

        ff.mkdirs();
        String Ddata = sdf1.format(new Date());
        ff = new File(ff.getAbsoluteFile() + "/" + "Formulario Seguro Incendio " + Ddata + ".pdf");

        reString = "../Documentos/" + user + "/Seguro Incendio/" + "Formulario Seguro Incendio " + Ddata
                + ".pdf";

        OutputStream outputStraem = new FileOutputStream(ff);
        PdfWriter writer = PdfWriter.getInstance(documento, outputStraem);

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

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

        documento.open();
        documento.add(pTableEmpresaPricipal);
        documento.add(pTableNull);
        documento.add(pTableTitulo);
        documento.add(pTableNull);
        documento.add(pTableCliente);
        //            documento.add(pTableNull);
        //            documento.add(pTableDadosTitulo);
        //            documento.add(pTableNull);
        //            documento.add(pTableSeguro);
        documento.add(pTableNull);
        documento.add(pTableAssinaturaTitulo);
        documento.add(pTableNull);
        documento.add(pTableNull);
        documento.add(pTableAssinatura);
        documento.close();

        //           PrintPdf printPdf = new PrintPdf(ff.getAbsolutePath(), ff.getAbsolutePath(), 0, 595f,842f,"Enviar Para o OneNote 2013",1); 
        //           //PrintPdf printPdf = new PrintPdf(ff.getAbsolutePath(), ff.getAbsolutePath(), 0, 595f,842f,"Hewlett-Packard HP LaserJet P2035",1); 
        //             
        //            printPdf.print();
    } catch (BadElementException | IOException ex) {
        Logger.getLogger(SeguroAPG.class.getName()).log(Level.SEVERE, null, ex);
    } catch (DocumentException ex) {
        Logger.getLogger(SeguroAPG.class.getName()).log(Level.SEVERE, null, ex);
    }
    return reString;
}