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

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

Introduction

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

Prototype

public void setVerticalAlignment(int verticalAlignment) 

Source Link

Document

Sets the vertical alignment for the cell.

Usage

From source file:Export.GrossSarary.java

public static void criaDoc(String user) {
    OutputStream outputStraem;//www . j ava2  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 {//w  ww.  j av  a2 s  .co 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  ww  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.SeguroViatura.java

public String criarDoc(String numApolice, String numCliente, Contrato c, VeiculoBean vb, String user,
        String arquivo) {/*from   w  ww .j a  v a  2 s  . com*/
    try {
        SimpleDateFormat sdf = new SimpleDateFormat("dd-MM-yyyy");
        SimpleDateFormat sdf1 = new SimpleDateFormat("dd-MM-yyyy hh'.'mm'.'ss");

        Font fontCabecalhoN = FontFactory.getFont(Fontes.FONTB, BaseFont.WINANSI, BaseFont.EMBEDDED, 10.5f);
        Font fontCorpo = FontFactory.getFont(Fontes.FONT, BaseFont.WINANSI, BaseFont.EMBEDDED, 9f);
        Font fontCorpoTabT = FontFactory.getFont(Fontes.FONTB, BaseFont.WINANSI, BaseFont.EMBEDDED, 6.5f);
        Font fontCorpoTab = FontFactory.getFont(Fontes.FONT, BaseFont.WINANSI, BaseFont.EMBEDDED, 6.5f);
        Font fontCorpoP = FontFactory.getFont(Fontes.FONT, BaseFont.WINANSI, BaseFont.EMBEDDED, 8f);
        Font fontCorpoN = FontFactory.getFont(Fontes.FONTB, BaseFont.WINANSI, BaseFont.EMBEDDED, 9f);
        Font fontCorpoNG = FontFactory.getFont(Fontes.FONTB, BaseFont.WINANSI, BaseFont.EMBEDDED, 9.5f);
        Font fontCorpoNGT = FontFactory.getFont(Fontes.FONTB, BaseFont.WINANSI, BaseFont.EMBEDDED, 10f);
        Font fontCabecalhoNG = FontFactory.getFont(Fontes.FONTB, BaseFont.WINANSI, BaseFont.EMBEDDED, 16f,
                Font.UNDERLINE);
        Font fontUK = FontFactory.getFont(Fontes.FONT, BaseFont.WINANSI, BaseFont.EMBEDDED, 6f, Font.ITALIC);
        Font fontUKb = FontFactory.getFont(Fontes.FONTB, BaseFont.WINANSI, BaseFont.EMBEDDED, 6f, Font.ITALIC);

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

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

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

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

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

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

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

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

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

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

        pTableEmpresaInforImpres1.addCell(pCellPolice);

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

        pTableEmpresaInforImpres5.addCell(cellTabela3);

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

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

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

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

        PdfPTable pTableTitulo = new PdfPTable(1);
        pTableTitulo.setWidthPercentage(88f);

        Paragraph paTitulo = new Paragraph();
        Paragraph pTitulo = new Paragraph("resumo de aplice para Automvel".toUpperCase(), fontCorpoNGT);
        Paragraph pTituloUk = new Paragraph("\nthe motor policy sumay".toUpperCase(), fontUKb);
        paTitulo.add(pTitulo);
        paTitulo.add(pTituloUk);

        PdfPCell cellTitulo = new PdfPCell(paTitulo);
        cellTitulo.setBorder(0);
        cellTitulo.setHorizontalAlignment(Element.ALIGN_CENTER);
        pTableTitulo.addCell(cellTitulo);

        ClienteI ci = new ClienteI(numCliente);
        Paragraph para = new Paragraph();
        Paragraph phrase = new Paragraph("1 - Informaes Do Cliente".toUpperCase(), fontCorpoNG);
        Paragraph paraUK = new Paragraph("\n1 - Customer information".toUpperCase(), fontUKb);

        para.add(phrase);
        para.add(paraUK);

        PdfPCell cellTituloTsbleSegurado = new PdfPCell(para);
        cellTituloTsbleSegurado.setBorder(0);

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

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

        /**
        pCl = new Paragraph();
        pCl.add(new Phrase("   " +ci.getNUNCLIENTEL_(),fontCorpo));
        pCl.add(new Phrase(ci.getNUNCLIENTE_(),fontCorpoN));
        PdfPCell cellNCliente = new PdfPCell( pCl );
        cellNCliente.setBorder(0);
        * */

        pCl = new Paragraph();
        pCl.add(new Phrase(ci.getPROFISSAOL_(), fontCorpo));
        pCl.add(new Phrase(ci.getPROFISSAO_(), fontCorpoN));
        pCl.add(new Phrase("\nPROFISSION/OCCUPATION/ACTIVITY AREA:", fontUK));
        PdfPCell cellProfissao = new PdfPCell(pCl);
        cellProfissao.setBorder(0);

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

        cellNome.setPaddingTop(7f);
        cellNome.setPaddingBottom(7f);
        cellNome.setBorder(0);

        cellEndereco.setPaddingTop(7f);
        cellEndereco.setPaddingBottom(7f);
        cellEndereco.setBorder(0);

        //            PdfPCell cellNCliente= new PdfPCell( new Phrase("   "+ci.getNUNCLIENTE(),fontCorpo));cellNome.setPaddingTop(5f);
        //            cellNCliente.setPaddingTop(7f);
        //            cellNCliente.setPaddingBottom(7f);
        //            cellNCliente.setBorder(0);

        cellProfissao.setPaddingTop(7f);
        cellProfissao.setPaddingBottom(7f);
        cellProfissao.setBorder(0);

        cellLocalTrabalho.setPaddingTop(7f);
        cellLocalTrabalho.setPaddingBottom(7f);
        cellLocalTrabalho.setBorder(0);

        pTableCliente.addCell(cellTituloTsbleSegurado);
        pTableCliente.addCell(cellNome);
        pTableCliente.addCell(cellEndereco);
        //            pTableCliente.addCell(cellNCliente);
        pTableCliente.addCell(cellProfissao);
        pTableCliente.addCell(cellLocalTrabalho);

        para = new Paragraph();
        Paragraph p = new Paragraph("3 - Premio E Cobertura".toUpperCase(), fontCorpoNG);
        Paragraph p1 = new Paragraph("\n3 - PREMIUM AND COVER".toUpperCase(), fontUKb);
        para.add(p);
        para.add(p1);

        PdfPCell cellTiltuloSegro = new PdfPCell(para);
        cellTiltuloSegro.setPaddingTop(7f);
        cellTiltuloSegro.setPaddingBottom(7f);
        cellTiltuloSegro.setBorder(0);

        //            PdfPCell cellApolice= new PdfPCell( new Phrase("   N Aplice: ".toUpperCase()+numApolice,fontCorpo));
        //            cellApolice.setPaddingTop(7f);
        //            cellApolice.setPaddingBottom(7f);
        //            cellApolice.setBorder(0);
        Paragraph pTotalSegurado = new Paragraph();
        pTotalSegurado.add(new Phrase("Prmio: ".toUpperCase().toUpperCase(), fontCorpo));
        /**
         * *
         * ildo - premio liquido ->
         */
        pTotalSegurado.add(new Phrase(
                ((c.getPremioLiquidoMoeda() == null /*&& vb.getVeiculo().getTipoCobertura().equals("41") */ )
                        ? " "
                        : c.getPremioLiquidoMoeda() + " " + c.getSigla()),
                fontCorpoN));
        pTotalSegurado.add(new Phrase("\nPREMIUM", fontUK));
        PdfPCell cellTotalSegurado = new PdfPCell(pTotalSegurado);
        cellTotalSegurado.setPaddingTop(7f);
        cellTotalSegurado.setPaddingBottom(7f);
        cellTotalSegurado.setBorder(0);

        Paragraph pExcesso = new Paragraph();
        pExcesso.add(new Phrase("Excesso: ".toUpperCase(), fontCorpo));
        pExcesso.add(new Phrase((c.getFranquia() == null) ? "No aplicvel".toUpperCase() : c.getFranquia(),
                fontCorpoN));
        pExcesso.add(new Phrase("\nEXCESS: ", fontUK));
        PdfPCell cellExcesso = new PdfPCell(pExcesso);
        cellExcesso.setPaddingTop(7f);
        cellExcesso.setPaddingBottom(7f);
        cellExcesso.setBorder(0);

        //            PdfPCell cellValor1Preminio= new PdfPCell( new Phrase("   Valor Primeiro Premio: ".toUpperCase()+((c.getPrimeiroPremio()==null)?" ":c.getPrimeiroPremio()),fontCorpo));
        //            cellValor1Preminio.setPaddingTop(7f);
        //            cellValor1Preminio.setPaddingBottom(7f);
        //            cellValor1Preminio.setBorder(0);
        //            
        //            PdfPCell cellTotalPremioAnual= new PdfPCell( new Phrase("   Valor Premio Anual: ".toUpperCase()+((c.getPremioAnual()==null)?" ":c.getPremioAnual()),fontCorpo));
        //            cellTotalPremioAnual.setPaddingTop(7f);
        //            cellTotalPremioAnual.setPaddingBottom(7f);
        //            cellTotalPremioAnual.setBorder(0);
        //            PdfPCell cellPeriodo= new PdfPCell( new Phrase("   Periodo Do Seguro: ".toUpperCase()+((c.getDataInicio()!= null) ? sdf.format(c.getDataInicio()): " " )+"  "+((c.getDataFim()!= null) ? sdf.format(c.getDataFim()): " " ),fontCorpo));
        //            cellPeriodo.setPaddingTop(7f);
        //            cellPeriodo.setPaddingBottom(7f);
        //            cellPeriodo.setBorder(0)
        Paragraph pDataRenovacao = new Paragraph();
        pDataRenovacao.add(new Phrase("Data Renovao de Seguro: ".toUpperCase(), fontCorpo));
        pDataRenovacao.add(new Phrase(((c.getDataRenovacao() != null) ? sdf.format(c.getDataRenovacao()) : " "),
                fontCorpoN));
        pDataRenovacao.add(new Phrase("\nRENEWAL DATE OF COVER", fontUK));
        PdfPCell cellDataRenovacao = new PdfPCell(pDataRenovacao);
        cellDataRenovacao.setPaddingTop(7f);
        cellDataRenovacao.setPaddingBottom(7f);
        cellDataRenovacao.setBorder(0);

        Paragraph pTipoCobert = new Paragraph();
        pTipoCobert.add(new Phrase("Tipo De Cobertura: ".toUpperCase(), fontCorpo));
        pTipoCobert
                .add(new Phrase(
                        ((vb.getVeiculo().getTipoCobertura() != null)
                                ? (vb.getVeiculo().getTipoCobertura().equals("41")
                                        ? "Contra Terceiros".toUpperCase()
                                        : (vb.getVeiculo().getTipoCobertura().equals("42")
                                                ? "CONTRA Todos os riscos".toUpperCase()
                                                : (vb.getVeiculo().getTipoCobertura().equals("43")
                                                        ? "Compreensivo limitado".toUpperCase()
                                                        : vb.getVeiculo().getTipoCobertura())))
                                : " "),
                        fontCorpoN));
        pTipoCobert.add(new Phrase("\nTYPE OF CAVER", fontUK));
        PdfPCell cellTipoCobert = new PdfPCell(pTipoCobert);
        cellTipoCobert.setPaddingTop(7f);
        cellTipoCobert.setPaddingBottom(7f);
        cellTipoCobert.setBorder(0);

        Paragraph pLimiteArea = new Paragraph();
        pLimiteArea.add(new Phrase("Limite de rea geogrfica: ".toUpperCase(), fontCorpo));
        pLimiteArea.add(new Phrase("so Tom e principe".toUpperCase(), fontCorpoN));
        pLimiteArea.add(new Phrase("\nLIMIT OF GEOGRAPHICAL AREA".toUpperCase(), fontUK));
        PdfPCell cellLimiteArea = new PdfPCell(pLimiteArea);
        cellLimiteArea.setPaddingTop(7f);
        cellLimiteArea.setPaddingBottom(7f);
        cellLimiteArea.setBorder(0);

        Paragraph pLeis = new Paragraph();
        pLeis.add(new Phrase("legislao: ".toUpperCase(), fontCorpo));
        pLeis.add(new Phrase("artigos 1  36, lei n 30/2000 da repblica democrtica de stp".toUpperCase(),
                fontCorpoN));
        pLeis.add(new Phrase("\nLEGISLATION: ", fontUK));
        pLeis.add(new Phrase("ARTICLES 1 TO 36, LAW NO 30/2000 OF THE DEMOCRATIC REPUBLIC OF STP", fontUKb));
        PdfPCell cellLeis = new PdfPCell(pLeis);
        cellLeis.setPaddingTop(7f);
        cellLeis.setPaddingBottom(7f);
        cellLeis.setBorder(0);

        pTableSeguro.addCell(cellTiltuloSegro);
        //            pTableSeguro.addCell(cellApolice);
        pTableSeguro.addCell(cellTotalSegurado);
        //            pTableSeguro.addCell(cellValor1Preminio);
        //            pTableSeguro.addCell(cellTotalPremioAnual);
        pTableSeguro.addCell(cellExcesso);
        pTableSeguro.addCell(cellDataRenovacao);
        pTableSeguro.addCell(cellTipoCobert);
        pTableSeguro.addCell(cellLimiteArea);
        pTableSeguro.addCell(cellLeis);

        PdfPTable pTableDadosTitulo = new PdfPTable(1);
        pTableDadosTitulo.setWidthPercentage(88f);

        para = new Paragraph();
        Phrase PDadosTitulo = new Phrase("2 - Informaes do(s) Veculo(s)".toUpperCase(), fontCorpoN);
        Phrase PDadosTitulos = new Phrase("\n2 - VEHICLE (S) INFORMATIONS".toUpperCase(), fontUKb);
        para.add(PDadosTitulo);
        para.add(PDadosTitulos);
        PdfPCell cellDadosTitulo = new PdfPCell(para);

        cellDadosTitulo.setBorder(0);
        pTableDadosTitulo.addCell(cellDadosTitulo);
        pTableDadosTitulo.addCell(cellNull);

        PdfPTable pTableDados = new PdfPTable(new float[] { 13.5f, 13.5f, 14, 17, 16, 12, 14 });
        pTableDados.setWidthPercentage(88f);

        para = new Paragraph();
        Phrase PMarca = new Phrase("Marca".toUpperCase(), fontCorpoTabT);
        Phrase PMarcaUK = new Phrase("\nMARK".toUpperCase(), fontUK);
        para.add(PMarca);
        para.add(PMarcaUK);

        PdfPCell cellMarca = new PdfPCell(para);
        cellMarca.setPaddingTop(5f);
        cellMarca.setPaddingBottom(5f);
        cellMarca.setHorizontalAlignment(Element.ALIGN_CENTER);

        para = new Paragraph();
        Paragraph PModelo = new Paragraph("Modelo".toUpperCase(), fontCorpoTabT);
        Paragraph PModeloUK = new Paragraph("\nMODEL".toUpperCase(), fontUK);
        para.add(PModelo);
        para.add(PModeloUK);

        PdfPCell cellModelo = new PdfPCell(para);
        cellModelo.setHorizontalAlignment(Element.ALIGN_CENTER);
        cellModelo.setPaddingTop(5f);
        cellModelo.setPaddingBottom(5f);

        para = new Paragraph();
        Phrase PMatricula = new Phrase("NO DE MATR?CULA".toUpperCase(), fontCorpoTabT);
        Phrase PMatriculaUK = new Phrase("\nREG. NUMBER".toUpperCase(), fontUK);
        para.add(PMatricula);
        para.add(PMatriculaUK);

        PdfPCell cellMatricula = new PdfPCell(para);
        cellMatricula.setHorizontalAlignment(Element.ALIGN_CENTER);
        cellMatricula.setPaddingTop(5f);
        cellMatricula.setPaddingBottom(5f);

        para = new Paragraph();
        Phrase PChasii = new Phrase("No. de chissi/Motor".toUpperCase(), fontCorpoTabT);
        Phrase PChasiiUK = new Phrase("\nchissiS/ENGINE NO.".toUpperCase(), fontUK);
        para.add(PChasii);
        para.add(PChasiiUK);

        PdfPCell cellChasii = new PdfPCell(para);
        cellChasii.setHorizontalAlignment(Element.ALIGN_CENTER);
        cellChasii.setPaddingTop(5f);
        cellChasii.setPaddingBottom(5f);

        para = new Paragraph();
        Phrase PAnoFabricoCompra = new Phrase("ano de Fabrico/Compra".toUpperCase(), fontCorpoTabT);
        Phrase PAnoFabricoCompraUK = new Phrase("\nYear of Manufacture/PURCHASE".toUpperCase(), fontUK);
        para.add(PAnoFabricoCompra);
        para.add(PAnoFabricoCompraUK);

        PdfPCell cellAnoFabricoCompra = new PdfPCell(para);
        cellAnoFabricoCompra.setHorizontalAlignment(Element.ALIGN_CENTER);
        cellAnoFabricoCompra.setPaddingTop(5f);
        cellAnoFabricoCompra.setPaddingBottom(5f);

        para = new Paragraph();
        Phrase PTotalLuagares = new Phrase("lotao".toUpperCase(), fontCorpoTabT);
        Phrase PTotalLuagaresUK = new Phrase("\nSTOCKING", fontUK);
        para.add(PTotalLuagares);
        para.add(PTotalLuagaresUK);

        PdfPCell cellTotalLuagares = new PdfPCell(para);
        cellTotalLuagares.setHorizontalAlignment(Element.ALIGN_CENTER);
        cellTotalLuagares.setPaddingTop(5f);
        cellTotalLuagares.setPaddingBottom(5f);

        para = new Paragraph();
        Phrase PDadosValorSeguro = new Phrase("Estimativa / Valor Segurado".toUpperCase(), fontCorpoTabT);
        Phrase PDadosValorSeguroUK = new Phrase("\nEstimation / Amount Insured".toUpperCase(), fontUK);
        para.add(PDadosValorSeguro);
        para.add(PDadosValorSeguroUK);

        PdfPCell cellDadosValorSeguro = new PdfPCell(para);
        cellDadosValorSeguro.setHorizontalAlignment(Element.ALIGN_CENTER);
        cellDadosValorSeguro.setPaddingTop(5f);
        cellDadosValorSeguro.setPaddingBottom(5f);

        pTableDados.addCell(cellMarca);
        pTableDados.addCell(cellModelo);
        pTableDados.addCell(cellMatricula);
        pTableDados.addCell(cellChasii);
        pTableDados.addCell(cellAnoFabricoCompra);
        pTableDados.addCell(cellTotalLuagares);
        pTableDados.addCell(cellDadosValorSeguro);

        int total = vb.getInfo().size();
        for (int i = 0; i < total; i++) {
            cellMarca = new PdfPCell(
                    new Phrase((vb.getInfo().get(i).getMarca() == null) ? " " : vb.getInfo().get(i).getMarca(),
                            fontCorpoTab));
            cellMarca.setHorizontalAlignment(Element.ALIGN_CENTER);
            cellModelo = new PdfPCell(new Phrase(
                    (vb.getInfo().get(i).getModelo() == null) ? " " : vb.getInfo().get(i).getModelo(),
                    fontCorpoTab));
            cellModelo.setHorizontalAlignment(Element.ALIGN_CENTER);
            cellMatricula = new PdfPCell(
                    new Phrase(((vb.getInfo().get(i).getNumeroMatricula() == null) ? ".........."
                            : vb.getInfo().get(i).getNumeroMatricula()), fontCorpoTab));
            cellMatricula.setHorizontalAlignment(Element.ALIGN_CENTER);
            cellDadosValorSeguro = new PdfPCell(new Phrase(
                    ((vb.getInfo().get(i).getValorAtual() == null
                            || vb.getInfo().get(i).getValorAtual().isEmpty()
                            || vb.getVeiculo().getTipoCobertura().equals("41")) ? " NA "
                                    : Moeda.format(Double.valueOf(vb.getInfo().get(i).getValorAtual()))),
                    fontCorpoTab));
            cellDadosValorSeguro.setHorizontalAlignment(Element.ALIGN_CENTER);
            cellAnoFabricoCompra = new PdfPCell(new Phrase(((vb.getInfo().get(i).getAnoFabrico() == null
                    || (vb.getInfo().get(i).getAnoFabrico().isEmpty())) ? "......."
                            : vb.getInfo().get(i).getAnoFabrico())
                    + "/"
                    + ((vb.getInfo().get(i).getAnoCompra() == null
                            || (vb.getInfo().get(i).getAnoCompra().isEmpty())) ? "......."
                                    : vb.getInfo().get(i).getAnoCompra()),
                    fontCorpoTab));
            cellAnoFabricoCompra.setHorizontalAlignment(Element.ALIGN_CENTER);
            cellTotalLuagares = new PdfPCell(
                    new Phrase(vb.getInfo().get(i).getCapacidade() + " LUGARES", fontCorpoTab));
            cellTotalLuagares.setHorizontalAlignment(Element.ALIGN_CENTER);
            cellChasii = new PdfPCell(new Phrase(vb.getInfo().get(i).getChassi() + " ", fontCorpoTab));
            cellChasii.setHorizontalAlignment(Element.ALIGN_CENTER);

            float pad = getPadding(total);

            cellMarca.setPaddingTop(pad);
            cellMarca.setPaddingBottom(pad);
            pTableDados.addCell(cellMarca);

            cellModelo.setPaddingTop(pad);
            cellModelo.setPaddingBottom(pad);
            pTableDados.addCell(cellModelo);

            cellMatricula.setPaddingTop(pad);
            cellMatricula.setPaddingBottom(pad);
            pTableDados.addCell(cellMatricula);

            cellChasii.setPaddingTop(pad);
            cellChasii.setPaddingBottom(pad);
            pTableDados.addCell(cellChasii);

            cellAnoFabricoCompra.setPaddingTop(pad);
            cellAnoFabricoCompra.setPaddingBottom(pad);
            pTableDados.addCell(cellAnoFabricoCompra);

            cellTotalLuagares.setPaddingTop(pad);
            cellTotalLuagares.setPaddingBottom(pad);
            pTableDados.addCell(cellTotalLuagares);

            cellDadosValorSeguro.setPaddingTop(pad);
            cellDadosValorSeguro.setPaddingBottom(pad);
            pTableDados.addCell(cellDadosValorSeguro);
        }

        //            PdfPTable pTableAssinaturaTitulo= new PdfPTable(1);
        //            pTableAssinaturaTitulo.setWidthPercentage(88f);
        //            PdfPTable pTableAssinatura= new PdfPTable( new float[]{50f,50f});
        //            pTableAssinatura.setWidthPercentage(88f);
        //            PdfPCell cellAssinatora= new PdfPCell(new Phrase("Assinaturas".toUpperCase(),fontCorpoN));
        //            cellAssinatora.setBorder(0);
        //            cellAssinatora.setHorizontalAlignment(Element.ALIGN_CENTER);
        //            PdfPCell celllinha1= new PdfPCell(new Phrase("____________________________________________".toUpperCase(),fontCorpo));
        //            celllinha1.setBorder(0);
        //            celllinha1.setHorizontalAlignment(Element.ALIGN_CENTER);
        //            PdfPCell celllinha2= new PdfPCell(new Phrase("____________________________________________".toUpperCase(),fontCorpo));
        //            celllinha2.setBorder(0);
        //            celllinha2.setHorizontalAlignment(Element.ALIGN_CENTER);
        //            PdfPCell celllinha11= new PdfPCell(new Phrase("para nicon Seguro sa stp".toUpperCase(),fontCorpoP));
        //            celllinha11.setBorder(0);
        //            celllinha11.setHorizontalAlignment(Element.ALIGN_CENTER);
        //            PdfPCell celllinha21= new PdfPCell(new Phrase("o segurado ".toUpperCase(),fontCorpoP));
        //            celllinha21.setBorder(0);
        //            celllinha21.setHorizontalAlignment(Element.ALIGN_CENTER);
        //            pTableAssinaturaTitulo.addCell(cellAssinatora);
        //            pTableAssinatura.addCell(celllinha1);
        //            pTableAssinatura.addCell(celllinha2);
        //            pTableAssinatura.addCell(celllinha11);
        //            pTableAssinatura.addCell(celllinha21);
        Document documento = new Document();
        documento.setPageSize(PageSize.A4);
        documento.setMargins(20f, 20f, 35f, 5f);

        //            File ff= new File("Documentos\\"+user+"\\Seguro Automovel\\");
        //            ff.mkdirs();
        //            ff =new File(ff.getAbsoluteFile()+"\\"+"Formulario Seguro Automovel "+sdf1.format(new Date())+".pdf");
        File ff = new File(arquivo + "/" + user + "/Seguro Automovel/");

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

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

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

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

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

        PdfPTable pTableLinha = new PdfPTable(1);
        pTableLinha.setWidthPercentage(88f);
        PdfPCell cellLinha = new PdfPCell(new Phrase(
                "----------------------------------------------------------------------------------------------------------------------",
                fontCorpo));
        cellLinha.setBorder(0);
        pTableLinha.addCell(cellLinha);
        cellLinha.setPaddingTop(-9f);
        pTableLinha.addCell(cellLinha);

        PdfPTable pTableApoliceAndPeriodo = new PdfPTable(new float[] { 40, 60 });
        pTableApoliceAndPeriodo.setWidthPercentage(88f);

        Paragraph pApolice = new Paragraph();
        pApolice.add(new Phrase("N Aplice: ".toUpperCase(), fontCorpo));
        pApolice.add(new Phrase(numApolice, fontCorpoN));
        pApolice.add(new Phrase("\nPOLICY NO:", fontUK));
        PdfPCell cellApolice = new PdfPCell(pApolice);
        //            cellApolice.setPaddingTop(-2);
        //            cellApolice.setPaddingBottom(4.5f);
        cellApolice.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
        pTableApoliceAndPeriodo.addCell(cellApolice);

        Paragraph pPeriodo = new Paragraph();
        pPeriodo.add(new Phrase("Periodo Do Seguro: ".toUpperCase(), fontCorpo));
        pPeriodo.add(new Phrase(((c.getDataInicio() != null) ? sdf.format(c.getDataInicio()) : " ") + "  "
                + ((c.getDataFim() != null) ? sdf.format(c.getDataFim()) : " "), fontCorpoN));
        pPeriodo.add(new Phrase("\nPERIOD OF INSURANCE:", fontUK));
        PdfPCell cellPeriodo = new PdfPCell(pPeriodo);
        //            cellPeriodo.setPaddingTop(-2);
        //            cellPeriodo.setPaddingBottom(4.5f);
        cellPeriodo.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
        pTableApoliceAndPeriodo.addCell(cellPeriodo);

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

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

From source file:Export.TableOfSalary.java

public static void ciarDoc(String user, String idProcesso, String data) {
    FileOutputStream outputStraem;
    try {//from  ww w.ja v  a2s.  c o m
        Font fontCabecalhoN = FontFactory.getFont(ConfigDoc.Fontes.FONTB, BaseFont.WINANSI, BaseFont.EMBEDDED,
                9f);
        Font fontCorpo = FontFactory.getFont(ConfigDoc.Fontes.FONT, BaseFont.WINANSI, BaseFont.EMBEDDED, 6f);
        Font fontCorpoN = FontFactory.getFont(ConfigDoc.Fontes.FONTB, BaseFont.WINANSI, BaseFont.EMBEDDED, 7f);
        Font fontCabecalhoNG = FontFactory.getFont(ConfigDoc.Fontes.FONTB, BaseFont.WINANSI, BaseFont.EMBEDDED,
                16f, Font.UNDERLINE);

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

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

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

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

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

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

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

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

        PdfPTable pTableDados = new PdfPTable(new float[] { 2.5f, 7.5f, 2, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
                4, 4, 4, 4, 4, 4, 4, 4, 4, 4 });
        pTableDados.setWidthPercentage(105);

        /**
         * primeira linha de titulo inicio
         */
        PdfPCell cellDados;
        Paragraph pTitile = new Paragraph();

        //            SimpleDateFormat sdfPT = new SimpleDateFormat("MMMM yyyy",new Locale("pt", "BR"));
        pTitile.add(new Paragraph(ConfigDoc.Empresa.NOME + "\n" + "TABELA SAL?RIO REFERENTE A " + data,
                fontCorpoN));

        cellDados = new PdfPCell(pTitile);
        cellDados.setColspan(10);
        cellDados.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
        pTableDados.addCell(cellDados);

        cellDados = new PdfPCell(new Phrase("F\nSOC. SEGU. 4%", fontCorpoN));
        cellDados.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
        cellDados.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
        pTableDados.addCell(cellDados);

        cellDados = new PdfPCell(new Phrase("G", fontCorpoN));
        cellDados.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
        cellDados.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
        pTableDados.addCell(cellDados);

        cellDados = new PdfPCell(new Phrase("H", fontCorpoN));
        cellDados.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
        cellDados.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
        pTableDados.addCell(cellDados);

        cellDados = new PdfPCell(new Phrase("I", fontCorpoN));
        cellDados.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
        cellDados.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
        pTableDados.addCell(cellDados);

        cellDados = new PdfPCell(new Phrase("IMPOSTO\n18% : 20%", fontCorpoN));
        cellDados.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
        cellDados.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
        pTableDados.addCell(cellDados);

        for (int j = 0; j < 8; j++) {
            cellDados = new PdfPCell(new Phrase(" ", fontCorpo));
            pTableDados.addCell(cellDados);
        }

        cellDados = new PdfPCell(new Phrase("6\nSOC. SEGU.", fontCorpoN));
        cellDados.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
        cellDados.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
        pTableDados.addCell(cellDados);

        cellDados = new PdfPCell(new Phrase(" ", fontCorpoN));
        cellDados.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
        pTableDados.addCell(cellDados);
        /**
         * primeira linha de titulo Fim
         */

        /**
         * Segunda linha de titulo Inicio
         */
        for (int j = 0; j < 3; j++) {
            cellDados = new PdfPCell(new Phrase(" ", fontCorpo));
            pTableDados.addCell(cellDados);
        }

        cellDados = new PdfPCell(new Phrase("A", fontCorpoN));
        cellDados.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
        cellDados.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
        pTableDados.addCell(cellDados);

        cellDados = new PdfPCell(new Phrase("B", fontCorpoN));
        cellDados.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
        cellDados.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
        pTableDados.addCell(cellDados);

        cellDados = new PdfPCell(new Phrase("C", fontCorpoN));
        cellDados.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
        cellDados.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
        pTableDados.addCell(cellDados);

        cellDados = new PdfPCell(new Phrase("D", fontCorpoN));
        cellDados.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
        cellDados.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
        pTableDados.addCell(cellDados);

        cellDados = new PdfPCell(new Phrase("E", fontCorpoN));
        cellDados.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
        cellDados.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
        pTableDados.addCell(cellDados);

        cellDados = new PdfPCell(new Phrase("SUBSIDIO DE", fontCorpoN));
        cellDados.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
        cellDados.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
        pTableDados.addCell(cellDados);

        cellDados = new PdfPCell(new Phrase("VALOR A SER", fontCorpoN));
        cellDados.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
        cellDados.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
        pTableDados.addCell(cellDados);

        cellDados = new PdfPCell(new Phrase("F=(E*4%)", fontCorpoN));
        cellDados.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
        cellDados.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
        pTableDados.addCell(cellDados);

        cellDados = new PdfPCell(new Phrase("G=(E-F)", fontCorpoN));
        cellDados.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
        cellDados.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
        pTableDados.addCell(cellDados);

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

        cellDados = new PdfPCell(new Phrase("I=G+", fontCorpoN));
        cellDados.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
        cellDados.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
        pTableDados.addCell(cellDados);

        cellDados = new PdfPCell(new Phrase("J=", fontCorpoN));
        cellDados.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
        cellDados.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
        pTableDados.addCell(cellDados);

        for (int j = 0; j < 4; j++) {
            cellDados = new PdfPCell(new Phrase(" ", fontCorpo));
            pTableDados.addCell(cellDados);
        }

        cellDados = new PdfPCell(new Phrase("SUBSIDIO DE", fontCorpoN));
        cellDados.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
        pTableDados.addCell(cellDados);

        cellDados = new PdfPCell(new Phrase("k=E-(F+G)", fontCorpoN));
        cellDados.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
        pTableDados.addCell(cellDados);

        cellDados = new PdfPCell(new Phrase("PYT", fontCorpoN));
        cellDados.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
        pTableDados.addCell(cellDados);

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

        cellDados = new PdfPCell(new Phrase("I", fontCorpoN));
        cellDados.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
        pTableDados.addCell(cellDados);

        cellDados = new PdfPCell(new Phrase("J", fontCorpoN));
        cellDados.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
        pTableDados.addCell(cellDados);

        /**
         * Segunda linha de titulo Fim
         */
        /**
         * Terceira linha de titulo Inicio
         */
        for (int i = 0; i < 25; i++) {
            cellDados = new PdfPCell(new Phrase(getTitile(i), fontCorpoN));
            cellDados.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
            cellDados.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
            pTableDados.addCell(cellDados);
        }
        /**
         * Terceira linha de titulo FIM
         */
        ArrayList<Processo> ps = getListData(idProcesso);

        for (Processo p : ps) {
            cellDados = new PdfPCell(new Phrase(p.CODIGO1, fontCorpo));
            cellDados.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
            pTableDados.addCell(cellDados);

            cellDados = new PdfPCell(new Phrase(p.NOME2, fontCorpo));
            pTableDados.addCell(cellDados);

            cellDados = new PdfPCell(new Phrase(p.DIAS3, fontCorpo));
            cellDados.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
            pTableDados.addCell(cellDados);

            cellDados = new PdfPCell(new Phrase(p.S_BASE4, fontCorpo));
            cellDados.setHorizontalAlignment(PdfPCell.ALIGN_RIGHT);
            pTableDados.addCell(cellDados);

            cellDados = new PdfPCell(new Phrase(p.S_ALOJAMENTO5, fontCorpo));
            cellDados.setHorizontalAlignment(PdfPCell.ALIGN_RIGHT);
            pTableDados.addCell(cellDados);

            cellDados = new PdfPCell(new Phrase(p.S_TRANSPORTE6, fontCorpo));
            cellDados.setHorizontalAlignment(PdfPCell.ALIGN_RIGHT);
            pTableDados.addCell(cellDados);

            cellDados = new PdfPCell(new Phrase(p.S_ALMOCO7, fontCorpo));
            cellDados.setHorizontalAlignment(PdfPCell.ALIGN_RIGHT);
            pTableDados.addCell(cellDados);

            cellDados = new PdfPCell(new Phrase(p.TT_SEM8, fontCorpo));
            cellDados.setHorizontalAlignment(PdfPCell.ALIGN_RIGHT);
            pTableDados.addCell(cellDados);

            cellDados = new PdfPCell(new Phrase(p.ALMOCOLIVREIMPOSTO9, fontCorpo));
            cellDados.setHorizontalAlignment(PdfPCell.ALIGN_RIGHT);
            pTableDados.addCell(cellDados);

            cellDados = new PdfPCell(new Phrase(p.TRIBUTADO10, fontCorpo));
            cellDados.setHorizontalAlignment(PdfPCell.ALIGN_RIGHT);
            pTableDados.addCell(cellDados);

            cellDados = new PdfPCell(new Phrase(p.SSFUNCIONARIO11, fontCorpo));
            cellDados.setHorizontalAlignment(PdfPCell.ALIGN_RIGHT);
            pTableDados.addCell(cellDados);

            cellDados = new PdfPCell(new Phrase(p.MENOS_SS_FUNCIONARIO12, fontCorpo));
            cellDados.setHorizontalAlignment(PdfPCell.ALIGN_RIGHT);
            pTableDados.addCell(cellDados);

            cellDados = new PdfPCell(new Phrase(p.COMISOES13, fontCorpo));
            cellDados.setHorizontalAlignment(PdfPCell.ALIGN_RIGHT);
            pTableDados.addCell(cellDados);

            cellDados = new PdfPCell(new Phrase(p.TOTAL_E_COMISAO14, fontCorpo));
            cellDados.setHorizontalAlignment(PdfPCell.ALIGN_RIGHT);
            pTableDados.addCell(cellDados);

            cellDados = new PdfPCell(new Phrase(p.IRS15, fontCorpo));
            cellDados.setHorizontalAlignment(PdfPCell.ALIGN_RIGHT);
            pTableDados.addCell(cellDados);

            cellDados = new PdfPCell(new Phrase(p.PARCELABATER16, fontCorpo));
            cellDados.setHorizontalAlignment(PdfPCell.ALIGN_RIGHT);
            pTableDados.addCell(cellDados);

            cellDados = new PdfPCell(new Phrase(p.IRSAPURADO17, fontCorpo));
            cellDados.setHorizontalAlignment(PdfPCell.ALIGN_RIGHT);
            pTableDados.addCell(cellDados);

            cellDados = new PdfPCell(new Phrase(p.SITUAFAMILIAR18, fontCorpo));
            cellDados.setHorizontalAlignment(PdfPCell.ALIGN_RIGHT);
            pTableDados.addCell(cellDados);

            cellDados = new PdfPCell(new Phrase(p.IRSLIQUIDO19, fontCorpo));
            cellDados.setHorizontalAlignment(PdfPCell.ALIGN_RIGHT);
            pTableDados.addCell(cellDados);

            cellDados = new PdfPCell(new Phrase(p.ALMOCO20, fontCorpo));
            cellDados.setHorizontalAlignment(PdfPCell.ALIGN_RIGHT);
            pTableDados.addCell(cellDados);

            cellDados = new PdfPCell(new Phrase(p.SALARIOLIQUIDO21, fontCorpo));
            cellDados.setHorizontalAlignment(PdfPCell.ALIGN_RIGHT);
            pTableDados.addCell(cellDados);

            cellDados = new PdfPCell(new Phrase(p.AVANCO22, fontCorpo));
            cellDados.setHorizontalAlignment(PdfPCell.ALIGN_RIGHT);
            pTableDados.addCell(cellDados);

            cellDados = new PdfPCell(new Phrase(p.NETOUT23, fontCorpo));
            cellDados.setHorizontalAlignment(PdfPCell.ALIGN_RIGHT);
            pTableDados.addCell(cellDados);

            cellDados = new PdfPCell(new Phrase(p.SSEMPRESA24, fontCorpo));
            cellDados.setHorizontalAlignment(PdfPCell.ALIGN_RIGHT);
            pTableDados.addCell(cellDados);

            cellDados = new PdfPCell(new Phrase(p.TOTAL25, fontCorpo));
            cellDados.setHorizontalAlignment(PdfPCell.ALIGN_RIGHT);
            pTableDados.addCell(cellDados);
        }

        PdfPTable pTableRodape = new PdfPTable(new float[] { 33.333333333f, 33.333333333f, 33.333333333f });
        PdfPTable pTableSegurancaSocial = new PdfPTable(
                new float[] { 35f, 21.666666667f, 21.666666667f, 21.666666667f });
        pTableSegurancaSocial.setWidthPercentage(75f);

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

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

        PdfPTable pTableAssinatura = new PdfPTable(new float[] { 25f, 25f, 25f, 25f });

        /**
         * segurano social inicio
         */
        cellDados = new PdfPCell(new Phrase("SEGURANA SOCIAL", fontCorpoN));
        cellDados.setBorder(PdfPCell.NO_BORDER);
        cellDados.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
        cellDados.setPaddingTop(8.5f);
        pTableRodape.addCell(cellDados);
        /**
         * segurano social Fim
         */

        /**
         * IMPOSTO DE SAL?RIO inicio
         */
        cellDados = new PdfPCell(new Phrase("IMPOSTO DE SAL?RIO", fontCorpoN));
        cellDados.setBorder(PdfPCell.NO_BORDER);
        cellDados.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
        cellDados.setPaddingTop(8.5f);
        pTableRodape.addCell(cellDados);
        /**
         * IMPOSTO DE SAL?RIO Fim
         */

        /**
         * NET SALARY PAYABLE incial
         */
        cellDados = new PdfPCell(new Phrase("NET SALARY PAYABLE", fontCorpoN));
        cellDados.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
        cellDados.setBorder(PdfPCell.NO_BORDER);
        cellDados.setPaddingTop(8.5f);
        pTableRodape.addCell(cellDados);
        /**
         * NET SALARY PAYABLE Fim
         */

        /**
         * segurano social inicio
         */
        cellDados = new PdfPCell(new Phrase(" ", fontCorpoN));
        cellDados.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
        cellDados.setBorder(PdfPCell.NO_BORDER);
        pTableSegurancaSocial.addCell(cellDados);

        cellDados = new PdfPCell(new Phrase("4%", fontCorpoN));
        cellDados.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
        pTableSegurancaSocial.addCell(cellDados);

        cellDados = new PdfPCell(new Phrase("6%", fontCorpoN));
        cellDados.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
        pTableSegurancaSocial.addCell(cellDados);

        cellDados = new PdfPCell(new Phrase("TOTAL", fontCorpoN));
        cellDados.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
        pTableSegurancaSocial.addCell(cellDados);

        cellDados = new PdfPCell(new Phrase("TOTAL", fontCorpoN));
        cellDados.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
        pTableSegurancaSocial.addCell(cellDados);

        cellDados = new PdfPCell(new Phrase(
                Moeda.format(Double.valueOf(psList.get(0).SSFUNCIONARIO11.replace(',', '.'))), fontCorpoN));
        cellDados.setHorizontalAlignment(PdfPCell.ALIGN_RIGHT);
        pTableSegurancaSocial.addCell(cellDados);

        cellDados = new PdfPCell(new Phrase(
                Moeda.format(Double.valueOf(psList.get(0).SSEMPRESA24.replace(',', '.'))), fontCorpoN));
        cellDados.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
        pTableSegurancaSocial.addCell(cellDados);

        cellDados = new PdfPCell(
                new Phrase(Moeda.format((Double.valueOf(psList.get(0).SSFUNCIONARIO11.replace(',', '.'))
                        + Double.valueOf(psList.get(0).SSEMPRESA24.replace(',', '.')))), fontCorpoN));
        cellDados.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
        pTableSegurancaSocial.addCell(cellDados);
        pTableSegurancaSocial.setComplete(true);

        cellDados = new PdfPCell(pTableSegurancaSocial);
        cellDados.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
        cellDados.setBorder(PdfPCell.NO_BORDER);
        cellDados.setPadding(8.5f);
        //            cellDados.setCalculatedHeight(100);
        pTableRodape.addCell(cellDados);
        /**
         * segurano social Fim
         */

        /**
         * IMPOSTO DE SAL?RIO inicio
         */
        cellDados = new PdfPCell(new Phrase("TOTAL", fontCorpoN));
        cellDados.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
        pTableImpostoSalario.addCell(cellDados);

        cellDados = new PdfPCell(new Phrase(" ", fontCorpoN));
        cellDados.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
        pTableImpostoSalario.addCell(cellDados);

        cellDados = new PdfPCell(new Phrase(" ", fontCorpoN));
        cellDados.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
        pTableImpostoSalario.addCell(cellDados);

        cellDados = new PdfPCell(new Phrase(
                Moeda.format(Double.valueOf(psList.get(0).IRSLIQUIDO19.replace(',', '.'))), fontCorpoN));
        cellDados.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
        pTableImpostoSalario.addCell(cellDados);
        pTableImpostoSalario.setComplete(true);

        cellDados = new PdfPCell(pTableImpostoSalario);
        cellDados.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
        //            cellDados.setCalculatedHeight(100);
        cellDados.setBorder(PdfPCell.NO_BORDER);
        cellDados.setPadding(8.5f);
        pTableRodape.addCell(cellDados);
        /**
         * IMPOSTO DE SAL?RIO Fim
         */

        /**
         * NET SALARY PAYABLE incial
         */
        for (Map.Entry<String, TotalBank> entrySet : tbs.entrySet()) {

            cellDados = new PdfPCell(
                    new Phrase(((entrySet.getValue().nome.isEmpty()) ? "INDEFINIDO" : entrySet.getValue().nome),
                            fontCorpoN));
            cellDados.setHorizontalAlignment(PdfPCell.ALIGN_LEFT);
            pTableNetSalaryPayble.addCell(cellDados);

            cellDados = new PdfPCell(new Phrase(Moeda.format(entrySet.getValue().value), fontCorpoN));
            cellDados.setHorizontalAlignment(PdfPCell.ALIGN_RIGHT);
            pTableNetSalaryPayble.addCell(cellDados);

        }

        cellDados = new PdfPCell(pTableNetSalaryPayble);
        cellDados.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
        //            cellDados.setCalculatedHeight(100);
        cellDados.setBorder(PdfPCell.NO_BORDER);
        cellDados.setPadding(8.5f);
        pTableRodape.addCell(cellDados);
        /**
         * NET SALARY PAYABLE Fim
         */

        /**
         * Asssinatura inicio
         */
        cellDados = new PdfPCell(new Phrase("VISTO\nRESPONS?VEL CONTABILIDADE", fontCorpoN));
        cellDados.setBorder(PdfPCell.NO_BORDER);
        cellDados.setHorizontalAlignment(PdfPTable.ALIGN_CENTER);
        cellDados.setPaddingBottom(20.f);
        pTableAssinatura.addCell(cellDados);

        cellDados = new PdfPCell(new Phrase("VISTO\nDIRETOR ADMINISTRATIVO & FINANCEIRO", fontCorpoN));
        cellDados.setBorder(PdfPCell.NO_BORDER);
        cellDados.setHorizontalAlignment(PdfPTable.ALIGN_CENTER);
        cellDados.setPaddingBottom(20.f);
        pTableAssinatura.addCell(cellDados);

        cellDados = new PdfPCell(new Phrase("VISTO\nDIRETOR GERAL", fontCorpoN));
        cellDados.setBorder(PdfPCell.NO_BORDER);
        cellDados.setHorizontalAlignment(PdfPTable.ALIGN_CENTER);
        cellDados.setPaddingBottom(20.f);
        pTableAssinatura.addCell(cellDados);

        cellDados = new PdfPCell(new Phrase("VISTO\nAUDITOR INTERNO", fontCorpoN));
        cellDados.setBorder(PdfPCell.NO_BORDER);
        cellDados.setHorizontalAlignment(PdfPTable.ALIGN_CENTER);
        cellDados.setPaddingBottom(20.f);
        pTableAssinatura.addCell(cellDados);

        cellDados = new PdfPCell(
                new Phrase("______________________________________________________", fontCorpoN));
        cellDados.setBorder(PdfPCell.NO_BORDER);
        cellDados.setHorizontalAlignment(PdfPTable.ALIGN_CENTER);
        cellDados.setPaddingBottom(5.f);
        pTableAssinatura.addCell(cellDados);

        cellDados = new PdfPCell(
                new Phrase("______________________________________________________", fontCorpoN));
        cellDados.setBorder(PdfPCell.NO_BORDER);
        cellDados.setHorizontalAlignment(PdfPTable.ALIGN_CENTER);
        pTableAssinatura.addCell(cellDados);

        cellDados = new PdfPCell(
                new Phrase("______________________________________________________", fontCorpoN));
        cellDados.setBorder(PdfPCell.NO_BORDER);
        cellDados.setHorizontalAlignment(PdfPTable.ALIGN_CENTER);
        pTableAssinatura.addCell(cellDados);

        cellDados = new PdfPCell(
                new Phrase("______________________________________________________", fontCorpoN));
        cellDados.setBorder(PdfPCell.NO_BORDER);
        cellDados.setHorizontalAlignment(PdfPTable.ALIGN_CENTER);
        pTableAssinatura.addCell(cellDados);

        cellDados = new PdfPCell(pTableAssinatura);
        cellDados.setBorder(PdfPCell.NO_BORDER);
        cellDados.setHorizontalAlignment(PdfPTable.ALIGN_CENTER);
        cellDados.setColspan(3);
        pTableRodape.addCell(cellDados);
        /**
         * Asssinatura fim
         */

        cellDados = new PdfPCell(pTableRodape);
        cellDados.setColspan(25);
        pTableDados.addCell(cellDados);

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

        psList = new ArrayList<>();
        tbs = new LinkedHashMap<>();

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

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

From source file:fc.extensions.itext.Writer.java

License:MIT License

public void addCell(PdfPTable table, String content, int fontSize, float borderWidth, int columnSpan) {
    PdfPCell pCell = new PdfPCell();
    if (columnSpan > 1) {
        pCell.setColspan(columnSpan);/*from   w w  w  . j  av a2 s. c  o m*/
    }
    pCell.setBorderWidth(borderWidth);
    pCell.setPhrase(new Phrase(content, getFont(fontSize)));
    pCell.setNoWrap(false);
    pCell.setHorizontalAlignment(PdfContentByte.ALIGN_LEFT);
    pCell.setVerticalAlignment(Element.ALIGN_MIDDLE);
    table.addCell(pCell);
}

From source file:fc.extensions.itext.Writer.java

License:MIT License

public void addAnsiCell(PdfPTable table, String content, int fontSize, float borderWidth, int columnSpan) {
    PdfPCell pCell = new PdfPCell();
    if (columnSpan > 1) {
        pCell.setColspan(columnSpan);//from   w  w w . j  a v  a2 s . c  o  m
    }
    pCell.setBorderWidth(borderWidth);
    pCell.setPhrase(new Phrase(content, getAnsiFont(fontSize)));
    pCell.setNoWrap(false);
    pCell.setHorizontalAlignment(PdfContentByte.ALIGN_LEFT);
    pCell.setVerticalAlignment(Element.ALIGN_MIDDLE);
    table.addCell(pCell);
}

From source file:femr.ui.controllers.PDFController.java

License:Open Source License

/**
 * Builds the page header - Title and Empty cell (for border)
 *
 * @return PdfPTable the itext table to add to the document
 *///from  ww  w. j a  va2 s  . c o m
public PdfPTable createHeaderTable() {

    PdfPTable table = new PdfPTable(2);
    table.setSpacingAfter(10);
    table.setWidthPercentage(100);

    Paragraph title = new Paragraph("Medical Record", new Font(Font.FontFamily.TIMES_ROMAN, 18, Font.BOLD));
    PdfPCell cell = new PdfPCell(title);
    cell.setVerticalAlignment(Element.ALIGN_BOTTOM);
    cell.setBorder(PdfPCell.NO_BORDER);
    cell.setBorderColorBottom(BaseColor.BLACK);
    cell.setBorderWidthBottom(1);
    cell.setPaddingBottom(5);
    table.addCell(cell);

    //Paragraph encounterId = new Paragraph("Encounter ID: " + patientEncounter.getId(), new Font(Font.FontFamily.TIMES_ROMAN, 12, Font.NORMAL));
    cell = new PdfPCell(table.getDefaultCell());
    cell.setVerticalAlignment(Element.ALIGN_BOTTOM);
    cell.setBorder(PdfPCell.NO_BORDER);
    cell.setBorderColorBottom(BaseColor.BLACK);
    cell.setBorderWidthBottom(1);
    cell.setHorizontalAlignment(Element.ALIGN_RIGHT);
    cell.setPaddingBottom(5);
    table.addCell(cell);

    return table;
}

From source file:fll.web.playoff.ScoresheetGenerator.java

License:Open Source License

public void writeFile(final OutputStream out, final boolean orientationIsPortrait) throws DocumentException {

    // This creates our new PDF document and declares its orientation
    Document pdfDoc;/*from  w w  w. j  a v a  2s . c  om*/
    if (orientationIsPortrait) {
        pdfDoc = new Document(PageSize.LETTER); // portrait
    } else {
        pdfDoc = new Document(PageSize.LETTER.rotate()); // landscape
    }
    PdfWriter.getInstance(pdfDoc, out);

    // Measurements are always in points (72 per inch)
    // This sets up 1/2 inch margins side margins and 0.35in top and bottom
    // margins
    pdfDoc.setMargins(0.5f * POINTS_PER_INCH, 0.5f * POINTS_PER_INCH, 0.35f * POINTS_PER_INCH,
            0.35f * POINTS_PER_INCH);
    pdfDoc.open();

    // Header cell with challenge title to add to both scoresheets
    final Paragraph titleParagraph = new Paragraph();
    final Chunk titleChunk = new Chunk(m_pageTitle,
            FontFactory.getFont(FontFactory.HELVETICA_BOLD, 14, Font.NORMAL, BaseColor.WHITE));
    titleParagraph.setAlignment(Element.ALIGN_CENTER);
    titleParagraph.add(titleChunk);

    titleParagraph.add(Chunk.NEWLINE);
    final Chunk swVersionChunk = new Chunk("SW version: " + Version.getVersion(),
            FontFactory.getFont(FontFactory.HELVETICA, 8, Font.NORMAL, BaseColor.WHITE));
    titleParagraph.add(swVersionChunk);
    if (null != m_revision) {

        final Chunk revisionChunk = new Chunk(" Descriptor revision: " + m_revision,
                FontFactory.getFont(FontFactory.HELVETICA, 8, Font.NORMAL, BaseColor.WHITE));

        titleParagraph.add(revisionChunk);
    }

    final PdfPCell head = new PdfPCell();
    head.setColspan(2);
    head.setBorder(1);
    head.setPaddingTop(0);
    head.setPaddingBottom(3);
    head.setBackgroundColor(new BaseColor(64, 64, 64));
    head.setVerticalAlignment(Element.ALIGN_TOP);
    head.addElement(titleParagraph);

    // Cells for score field, and 2nd check initials
    final Phrase des = new Phrase("Data Entry Score _______", ARIAL_8PT_NORMAL);
    final PdfPCell desC = new PdfPCell(des);
    desC.setBorder(0);
    desC.setPaddingTop(9);
    desC.setPaddingRight(36);
    desC.setHorizontalAlignment(Element.ALIGN_RIGHT);
    final Phrase sci = new Phrase("2nd Check Initials _______", ARIAL_8PT_NORMAL);
    final PdfPCell sciC = new PdfPCell(sci);
    sciC.setBorder(0);
    sciC.setPaddingTop(9);
    sciC.setPaddingRight(36);
    sciC.setHorizontalAlignment(Element.ALIGN_RIGHT);

    // Create a table with a grid cell for each scoresheet on the page
    PdfPTable wholePage = getTableForPage(orientationIsPortrait);
    wholePage.setWidthPercentage(100);
    for (int i = 0; i < m_numSheets; i++) {
        if (i > 0 && (orientationIsPortrait || (i % 2) == 0)) {
            pdfDoc.newPage();
            wholePage = getTableForPage(orientationIsPortrait);
            wholePage.setWidthPercentage(100);
        }

        // This table is a single score sheet
        final PdfPTable scoreSheet = new PdfPTable(2);
        // scoreSheet.getDefaultCell().setBorder(Rectangle.LEFT | Rectangle.BOTTOM
        // | Rectangle.RIGHT | Rectangle.TOP); //FIXME DEBUG should be NO_BORDER
        scoreSheet.getDefaultCell().setBorder(Rectangle.NO_BORDER);
        scoreSheet.getDefaultCell().setPaddingRight(1);
        scoreSheet.getDefaultCell().setPaddingLeft(0);

        scoreSheet.addCell(head);

        final PdfPTable teamInfo = new PdfPTable(7);
        teamInfo.setWidthPercentage(100);
        teamInfo.setWidths(new float[] { 1f, 1f, 1f, 1f, 1f, 1f, .9f });

        // Time label cell
        final Paragraph timeP = new Paragraph("Time:", ARIAL_10PT_NORMAL);
        timeP.setAlignment(Element.ALIGN_RIGHT);
        final PdfPCell timeLc = new PdfPCell(scoreSheet.getDefaultCell());
        timeLc.addElement(timeP);
        teamInfo.addCell(timeLc);
        // Time value cell
        final Paragraph timeV = new Paragraph(null == m_time[i] ? SHORT_BLANK : m_time[i], COURIER_10PT_NORMAL);
        final PdfPCell timeVc = new PdfPCell(scoreSheet.getDefaultCell());
        timeVc.addElement(timeV);
        teamInfo.addCell(timeVc);

        // Table label cell
        final Paragraph tblP = new Paragraph("Table:", ARIAL_10PT_NORMAL);
        tblP.setAlignment(Element.ALIGN_RIGHT);
        final PdfPCell tblLc = new PdfPCell(scoreSheet.getDefaultCell());
        tblLc.addElement(tblP);
        teamInfo.addCell(tblLc);
        // Table value cell
        final Paragraph tblV = new Paragraph(m_table[i], COURIER_10PT_NORMAL);
        final PdfPCell tblVc = new PdfPCell(scoreSheet.getDefaultCell());
        tblVc.addElement(tblV);
        teamInfo.addCell(tblVc);

        // Round number label cell
        final Paragraph rndP = new Paragraph("Round:", ARIAL_10PT_NORMAL);
        rndP.setAlignment(Element.ALIGN_RIGHT);
        final PdfPCell rndlc = new PdfPCell(scoreSheet.getDefaultCell());
        rndlc.addElement(rndP);
        teamInfo.addCell(rndlc);
        // Round number value cell
        final Paragraph rndV = new Paragraph(m_round[i], COURIER_10PT_NORMAL);
        final PdfPCell rndVc = new PdfPCell(scoreSheet.getDefaultCell());
        // rndVc.setColspan(2);
        rndVc.addElement(rndV);
        teamInfo.addCell(rndVc);

        final PdfPCell temp1 = new PdfPCell(scoreSheet.getDefaultCell());
        // temp1.setColspan(2);
        temp1.addElement(new Paragraph("Judge ____", ARIAL_8PT_NORMAL));
        teamInfo.addCell(temp1);

        // Team number label cell
        final Paragraph nbrP = new Paragraph("Team #:", ARIAL_10PT_NORMAL);
        nbrP.setAlignment(Element.ALIGN_RIGHT);
        final PdfPCell nbrlc = new PdfPCell(scoreSheet.getDefaultCell());
        nbrlc.addElement(nbrP);
        teamInfo.addCell(nbrlc);
        // Team number value cell
        final Paragraph nbrV = new Paragraph(null == m_number[i] ? SHORT_BLANK : String.valueOf(m_number[i]),
                COURIER_10PT_NORMAL);
        final PdfPCell nbrVc = new PdfPCell(scoreSheet.getDefaultCell());
        nbrVc.addElement(nbrV);
        teamInfo.addCell(nbrVc);

        // Team division label cell
        final Paragraph divP = new Paragraph(m_divisionLabel[i], ARIAL_10PT_NORMAL);
        divP.setAlignment(Element.ALIGN_RIGHT);
        final PdfPCell divlc = new PdfPCell(scoreSheet.getDefaultCell());
        divlc.addElement(divP);
        divlc.setColspan(2);
        teamInfo.addCell(divlc);
        // Team division value cell
        final Paragraph divV = new Paragraph(m_division[i], COURIER_10PT_NORMAL);
        final PdfPCell divVc = new PdfPCell(scoreSheet.getDefaultCell());
        divVc.setColspan(2);
        divVc.addElement(divV);
        teamInfo.addCell(divVc);

        final PdfPCell temp2 = new PdfPCell(scoreSheet.getDefaultCell());
        // temp2.setColspan(2);
        temp2.addElement(new Paragraph("Team ____", ARIAL_8PT_NORMAL));
        teamInfo.addCell(temp2);

        // Team name label cell
        final Paragraph nameP = new Paragraph("Team Name:", ARIAL_10PT_NORMAL);
        nameP.setAlignment(Element.ALIGN_RIGHT);
        final PdfPCell namelc = new PdfPCell(scoreSheet.getDefaultCell());
        namelc.setColspan(2);
        namelc.addElement(nameP);
        teamInfo.addCell(namelc);
        // Team name value cell
        final Paragraph nameV = new Paragraph(m_name[i], COURIER_10PT_NORMAL);
        final PdfPCell nameVc = new PdfPCell(scoreSheet.getDefaultCell());
        nameVc.setColspan(5);
        nameVc.addElement(nameV);
        teamInfo.addCell(nameVc);

        // add team info cell to the team table
        final PdfPCell teamInfoCell = new PdfPCell(scoreSheet.getDefaultCell());
        teamInfoCell.addElement(teamInfo);
        teamInfoCell.setColspan(2);

        scoreSheet.addCell(teamInfoCell);

        if (null != m_goalsTable) {
            final PdfPCell goalCell = new PdfPCell(m_goalsTable);
            goalCell.setBorder(0);
            goalCell.setPadding(0);
            goalCell.setColspan(2);
            scoreSheet.addCell(goalCell);
        }

        scoreSheet.addCell(desC);
        scoreSheet.addCell(sciC);

        if (null != m_copyright) {
            final Phrase copyright = new Phrase("\u00A9" + m_copyright, f6i);
            final PdfPCell copyrightC = new PdfPCell(scoreSheet.getDefaultCell());
            copyrightC.addElement(copyright);
            copyrightC.setBorder(0);
            copyrightC.setHorizontalAlignment(Element.ALIGN_CENTER);
            copyrightC.setColspan(2);

            scoreSheet.addCell(copyrightC);
        }

        // the cell in the whole page table that will contain the single score
        // sheet
        final PdfPCell scoresheetCell = new PdfPCell(scoreSheet);
        scoresheetCell.setBorder(0);
        scoresheetCell.setPadding(0);

        // Interior borders between scoresheets on a page
        if (!orientationIsPortrait) {
            if (i % 2 == 0) {
                scoresheetCell.setPaddingRight(0.1f * POINTS_PER_INCH);
            } else {
                scoresheetCell.setPaddingLeft(0.1f * POINTS_PER_INCH);
            }
        }

        // Add the current scoresheet to the page
        wholePage.addCell(scoresheetCell);

        // Add the current table of scoresheets to the document
        if (orientationIsPortrait || (i % 2 != 0)) {
            pdfDoc.add(wholePage);
        }
    }

    // Add a blank cells to complete the table of the last page
    if (!orientationIsPortrait && m_numSheets % 2 != 0) {
        final PdfPCell blank = new PdfPCell();
        blank.setBorder(0);
        wholePage.addCell(blank);
        pdfDoc.add(wholePage);
    }

    pdfDoc.close();
}

From source file:fll.web.playoff.ScoresheetGenerator.java

License:Open Source License

/**
 * Stores the goal cells that are inserted into the output after the team name
 * headers and before the scoring/initials blanks at the bottom of the
 * scoresheet./* w w w.  j av a2 s.c  o m*/
 */
private void setChallengeInfo(final ChallengeDescription description) {
    setPageTitle(description.getTitle());

    if (null != description.getRevision()) {
        setRevisionInfo(description.getRevision());
    }

    if (null != description.getCopyright()) {
        m_copyright = description.getCopyright();
    } else {
        m_copyright = null;
    }

    final PerformanceScoreCategory performanceElement = description.getPerformance();
    // use ArrayList as we will be doing indexed access in the loop
    final List<AbstractGoal> goals = new ArrayList<>(performanceElement.getGoals());

    final float[] relativeWidths = new float[3];
    relativeWidths[0] = 4;
    relativeWidths[1] = 48;
    relativeWidths[2] = 48;
    m_goalsTable = new PdfPTable(relativeWidths);

    String prevCategory = null;
    for (int goalIndex = 0; goalIndex < goals.size(); ++goalIndex) {
        final AbstractGoal goal = goals.get(goalIndex);
        if (!goal.isComputed()) {
            final String category = goal.getCategory();

            // add category cell if needed
            boolean firstRowInCategory = false;
            if (!StringUtils.equals(prevCategory, category)) {
                if (!StringUtils.isEmpty(category)) {

                    // find out how many future goals have the same category
                    int categoryRowSpan = 1;
                    for (int otherIndex = goalIndex + 1; otherIndex < goals.size(); ++otherIndex) {
                        final AbstractGoal otherGoal = goals.get(otherIndex);
                        if (!otherGoal.isComputed()) {
                            if (StringUtils.equals(category, otherGoal.getCategory())) {
                                ++categoryRowSpan;
                            } else {
                                break;
                            }
                        }
                    }

                    final Paragraph catPara = new Paragraph(category, ARIAL_10PT_NORMAL);
                    final PdfPCell categoryCell = new PdfPCell(catPara);
                    categoryCell.setBorderWidthTop(1);
                    categoryCell.setBorderWidthBottom(0);
                    categoryCell.setBorderWidthLeft(0);
                    categoryCell.setBorderWidthRight(0);
                    categoryCell.setVerticalAlignment(Element.ALIGN_CENTER);
                    categoryCell.setHorizontalAlignment(Element.ALIGN_CENTER);
                    categoryCell.setRotation(90);
                    categoryCell.setRowspan(categoryRowSpan);
                    m_goalsTable.addCell(categoryCell);
                }

                // first row in a new category, which may be empty
                firstRowInCategory = true;
            }

            // This is the text for the left hand "label" cell
            final String title = goal.getTitle();
            final Paragraph p = new Paragraph(title, ARIAL_10PT_NORMAL);
            final PdfPCell goalLabel = new PdfPCell(p);
            goalLabel.setHorizontalAlignment(Element.ALIGN_RIGHT);
            goalLabel.setVerticalAlignment(Element.ALIGN_CENTER);
            if (firstRowInCategory) {
                goalLabel.setBorderWidthTop(1);
                goalLabel.setBorderWidthBottom(0);
                goalLabel.setBorderWidthLeft(0);
                goalLabel.setBorderWidthRight(0);
            } else {
                goalLabel.setBorder(0);
            }
            goalLabel.setPaddingRight(9);
            goalLabel.setVerticalAlignment(Element.ALIGN_TOP);
            if (StringUtils.isEmpty(category)) {
                // category column and goal label column
                goalLabel.setColspan(2);
            }
            m_goalsTable.addCell(goalLabel);

            // define the value cell
            final double min = goal.getMin();
            final String minStr = FP.equals(min, Math.round(min), 1E-6) ? String.valueOf((int) min)
                    : String.valueOf(min);
            final double max = goal.getMax();
            final String maxStr = FP.equals(max, Math.round(max), 1E-6) ? String.valueOf((int) max)
                    : String.valueOf(max);

            // If element has child nodes, then we have an enumerated list
            // of choices. Otherwise it is either yes/no or a numeric field.
            final PdfPCell goalValue = new PdfPCell();
            final Chunk choices = new Chunk("", COURIER_10PT_NORMAL);
            if (goal.isEnumerated()) {
                // replace spaces with "no-break" spaces
                boolean first = true;
                final List<EnumeratedValue> values = goal.getSortedValues();
                for (final EnumeratedValue value : values) {
                    if (!first) {
                        choices.append(" /" + Utilities.NON_BREAKING_SPACE);
                    } else {
                        first = false;
                    }
                    choices.append(value.getTitle().toUpperCase().replace(' ', Utilities.NON_BREAKING_SPACE));
                }
                goalValue.addElement(choices);

            } else {
                if (goal.isYesNo()) {
                    // order of yes/no needs to match ScoreEntry.generateYesNoButtons
                    final Paragraph q = new Paragraph("NO / YES", COURIER_10PT_NORMAL);
                    goalValue.addElement(q);

                } else {
                    final String range = "(" + minStr + " - " + maxStr + ")";
                    final PdfPTable t = new PdfPTable(2);
                    t.setHorizontalAlignment(Element.ALIGN_LEFT);
                    t.setTotalWidth(1 * POINTS_PER_INCH);
                    t.setLockedWidth(true);
                    final Phrase r = new Phrase("", ARIAL_8PT_NORMAL);
                    t.addCell(new PdfPCell(r));
                    final Phrase q = new Phrase(range, ARIAL_8PT_NORMAL);
                    t.addCell(new PdfPCell(q));
                    goalValue.setPaddingTop(9);
                    goalValue.addElement(t);
                }
            }

            if (firstRowInCategory) {
                goalValue.setBorderWidthTop(1);
                goalValue.setBorderWidthBottom(0);
                goalValue.setBorderWidthLeft(0);
                goalValue.setBorderWidthRight(0);
            } else {
                goalValue.setBorder(0);
            }
            goalValue.setVerticalAlignment(Element.ALIGN_MIDDLE);

            m_goalsTable.addCell(goalValue);

            // setup for next loop
            prevCategory = category;
        } // if not computed goal

    } // foreach goal

}