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

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

Introduction

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

Prototype

public void setBorderWidth(final float borderWidth) 

Source Link

Document

Sets the borderwidth of the table.

Usage

From source file:Export.ExportMapaProducao__.java

public void newDado(String dados, Font fontCorpoTable, PdfPTable pTableDate, Document documento, int align,
        float border) throws DocumentException {
    PdfPCell cellDados;
    cellDados = new PdfPCell(new Phrase(dados, fontCorpoTable));
    cellDados.setHorizontalAlignment(align);
    cellDados.setBorderWidth(border);
    pTableDate.addCell(cellDados);/* www. ja  v a 2  s . c  o  m*/
    documento.add(pTableDate);
}

From source file:Export.ExportMapaProducao__.java

public PdfPTable HeadTablePrincipal() {
    PdfPTable pTableDate = new PdfPTable(new float[] { 9.7f, 28.8f, 14.7f, 10.7f, 10.7f, 10.7f, 14.7f });
    pTableDate.setWidthPercentage(95);/*from   w  ww . j a  v  a 2 s . c  o  m*/
    for (int i = 0; i < 7; i++) {
        PdfPCell cellDados = new PdfPCell(funcaoTitulo(i));
        cellDados.setHorizontalAlignment(a);
        cellDados.setBorderWidth(0.85f);
        pTableDate.addCell(cellDados);
    }
    return pTableDate;
}

From source file:Export.GenericPDFs.java

/**
 *
 * @param user//w  w  w. j a v  a2s. c om
 * @param nomeDoc
 * @param titleDoc
 * @param rs
 * @param op
 * @param paramFilter
 * @return
 */
public static String createDoc(String user, String nomeDoc, String titleDoc, DataTableControl rs,
        OrientacaoPagina op, int paramFilter) {
    nomeDocR = nomeDoc;
    try {

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

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

        Document documento = new Document();

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

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

        ff.mkdirs();
        String Ddata = sdf1.format(new Date());
        ff = new File(ff.getAbsoluteFile() + "/" + nomeDoc + " " + Ddata + ".pdf");
        OutputStream outputStraem = new FileOutputStream(ff);

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

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

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

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

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

        PdfPTable pTableEmpresaPricipal = new PdfPTable(
                (OrientacaoPagina.HORIZONTAL == op) ? new float[] { 14f, 86f } : new float[] { 18.5f, 82.5f });
        PdfPTable pTableEmpresaInforImpres1 = new PdfPTable(1);
        PdfPTable pTableEmpresaInforImpres5 = new PdfPTable(1);

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

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

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

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

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

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

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

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

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

        pTableEmpresaInforImpres5.addCell(cellTabela3);

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

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

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

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

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

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

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

                documento.add(tableDados);

            }

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

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

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

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

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

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

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

                    documento.add(tableDados);

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

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

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

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

From source file:Export.ListaVeiculo.java

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        PdfPCell dados;

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

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

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

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

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

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

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

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

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

        }

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

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

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

}

From source file:Export.SeguroAPG.java

public String criarDoc(String numApolice, String numCliente, Contrato c, AcidentePGBean apg, String user,
        String moeda, String arquivo) {
    try {//from  w  w w  .  ja  va 2 s  . com
        SimpleDateFormat sdf = new SimpleDateFormat("dd 'de' MMMM 'de' yyyy", new Locale("pt", "BR"));
        SimpleDateFormat sdf1 = new SimpleDateFormat("dd-MM-yyyy hh'.'mm'.'ss");

        Font fontCabecalhoN = FontFactory.getFont(Fontes.FONTB, BaseFont.WINANSI, BaseFont.EMBEDDED, 10.5f);
        Font fontCorpo = FontFactory.getFont(Fontes.FONT, BaseFont.WINANSI, BaseFont.EMBEDDED, 9f);
        Font fontCorpoTab = FontFactory.getFont(Fontes.FONT, BaseFont.WINANSI, BaseFont.EMBEDDED, 7.5f);
        Font fontCorpoP = FontFactory.getFont(Fontes.FONT, BaseFont.WINANSI, BaseFont.EMBEDDED, 7.5f);
        Font fontCorpoN = FontFactory.getFont(Fontes.FONTB, BaseFont.WINANSI, BaseFont.EMBEDDED, 9f);
        Font fontCorpoNTable = FontFactory.getFont(Fontes.FONTB, BaseFont.WINANSI, BaseFont.EMBEDDED, 8f);
        Font fontCorpoNG = FontFactory.getFont(Fontes.FONTB, BaseFont.WINANSI, BaseFont.EMBEDDED, 10.5f);
        Font fontCorpoNGT = FontFactory.getFont(Fontes.FONTB, BaseFont.WINANSI, BaseFont.EMBEDDED, 11f);
        Font fontCabecalhoNG = FontFactory.getFont(Fontes.FONTB, BaseFont.WINANSI, BaseFont.EMBEDDED, 16f,
                Font.UNDERLINE);
        //            Font fontCorpoNGTi= FontFactory.getFont(Fontes.FONTB, BaseFont.WINANSI, BaseFont.EMBEDDED ,10f );

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

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

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

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

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

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

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

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

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

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

        pTableEmpresaInforImpres1.addCell(pCellPolice);

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

        pTableEmpresaInforImpres5.addCell(cellTabela3);

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

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

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

        PdfPTable pTableSeguro = new PdfPTable(1);
        PdfPTable pTableCliente = new PdfPTable(1);

        PdfPTable pTableTitulo = new PdfPTable(1);
        Phrase pTitulo = new Phrase("Formulario de SEguro Acidente Para grupo".toUpperCase(), fontCorpoNGT);
        PdfPCell cellTitulo = new PdfPCell(pTitulo);
        cellTitulo.setBorder(0);
        cellTitulo.setHorizontalAlignment(Element.ALIGN_CENTER);
        pTableTitulo.addCell(cellTitulo);

        ClienteI ci = new ClienteI(numCliente);

        PdfPCell cellTituloTsbleSegurado = new PdfPCell(
                new Phrase("1 - Informaes Cliente".toUpperCase(), fontCorpoNG));
        cellTituloTsbleSegurado.setBorder(0);

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

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

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

        pCl = new Paragraph();
        pCl.add(new Phrase("   " + ci.getPROFISSAOL_(), fontCorpo));
        pCl.add(new Phrase(ci.getPROFISSAO_(), fontCorpoN));
        PdfPCell cellProfissao = new PdfPCell(pCl);
        cellProfissao.setBorder(0);

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

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

        PdfPCell cellTiltuloSegro = new PdfPCell(
                new Phrase("2 - Informaes Premio".toUpperCase(), fontCorpoNG));
        cellTiltuloSegro.setBorder(0);
        PdfPCell cellApolice = new PdfPCell(
                new Phrase("   N Aplice: ".toUpperCase() + numApolice, fontCorpo));
        cellApolice.setBorder(0);
        PdfPCell cellPropriedadeSegurada = new PdfPCell(
                new Phrase(
                        "   Propriedade segurada: ".toUpperCase() + apg.getInfo().size() + " "
                                + "Trabalhodor".toUpperCase() + ((apg.getInfo().size() > 1) ? "ES" : ""),
                        fontCorpo));
        cellPropriedadeSegurada.setBorder(0);
        PdfPCell cellTotalSegurado = new PdfPCell(
                new Phrase("   Valor Total segrurado: ".toUpperCase() + c.getTotalSeguradoMoeda() + " " + moeda,
                        fontCorpo));
        cellTotalSegurado.setBorder(0);
        PdfPCell cellValor1Preminio = new PdfPCell(new Phrase(
                "   Valor Primeiro Premio: ".toUpperCase()
                        + ((c.getPrimeiroPremio() == null) ? "" : c.getPrimeiroPremio() + " " + moeda),
                fontCorpo));
        cellValor1Preminio.setBorder(0);
        PdfPCell cellTotalPremioAnual = new PdfPCell(new Phrase("   Valor Premio Anual: ".toUpperCase()
                + ((c.getPremioAnual() == null) ? " " : c.getPremioAnual() + " " + moeda), fontCorpo));
        cellTotalPremioAnual.setBorder(0);
        PdfPCell cellPeriodo = new PdfPCell(new Phrase("   Periodo Do Seguro: ".toUpperCase()
                + ((c.getDataInicio() != null) ? sdf.format(c.getDataInicio()) : "") + "  "
                + ((c.getDataFim() != null) ? sdf.format(c.getDataFim()) : ""), fontCorpo));
        cellPeriodo.setBorder(0);
        PdfPCell cellDataRenovacao = new PdfPCell(new Phrase(
                "   Data Renovao: ".toUpperCase()
                        + ((c.getDataRenovacao() == null) ? " " : c.getDataRenovacao() + " " + moeda),
                fontCorpo));
        cellDataRenovacao.setBorder(0);
        Paragraph p = new Paragraph();
        Phrase p1 = new Phrase("BEnefcio (s) De Peessoa e Plano: ".toUpperCase(), fontCorpoN);
        Phrase p2 = new Phrase(
                "O Seguro Sob esta seco se aplique apenas as pessoas ou grupo das pessoas seguradas indicadas"
                        .toUpperCase()
                        + " e apenas de acordo com s coberturas para qual o valor foi especificado. o Valor especificado ser aplicado para "
                                .toUpperCase()
                        + "cada pessoa segurada por sinistro subjeito a todos os termos da apolice."
                                .toUpperCase(),
                fontCorpo);

        p.add(p1);
        p.add(p2);

        PdfPCell cellNotaBenefi = new PdfPCell(p);
        cellNotaBenefi.setBorder(0);
        cellNotaBenefi.setHorizontalAlignment(Element.ALIGN_JUSTIFIED);

        PdfPCell cellCobertura = new PdfPCell(new Phrase(
                "Cobertuta Diria: ".toUpperCase() + ((apg.getAcidentePG().getTipoCobertura().equals("1"))
                        ? "Apenas em situao de acidente de trabalho"
                        : ((apg.getAcidentePG().getTipoCobertura().equals("2") ? "24 horas"
                                : apg.getAcidentePG().getTipoCobertura()))),
                fontCorpo));
        cellCobertura.setBorder(0);

        PdfPCell cellLimiteBeneficio = new PdfPCell(
                new Phrase("3 - Informaes de Limites de Benefcio:".toUpperCase(), fontCorpoNG));
        cellLimiteBeneficio.setBorder(0);

        PdfPCell cellLimiteA = new PdfPCell(new Phrase("   Benefcio A: Morte: ".toUpperCase()
                + apg.getAcidentePG().getPremioMorteMoeda() + " " + moeda, fontCorpo));
        cellLimiteA.setBorder(0);
        PdfPCell cellLimiteB = new PdfPCell(new Phrase("   Benefcio B: Invalidez permanete: ".toUpperCase()
                + apg.getAcidentePG().getPremioIncapacidadePermanenteMoeda() + " " + moeda, fontCorpo));
        cellLimiteB.setBorder(0);
        PdfPCell cellLimiteC = new PdfPCell(
                new Phrase("   Benefcio C: Reembolso das despesas Mdica Acidental: ".toUpperCase()
                        + apg.getAcidentePG().getPremioDespesaMedicaMoeda() + " " + moeda, fontCorpo));
        cellLimiteC.setBorder(0);
        PdfPCell cellLimiteGlobal = new PdfPCell(
                new Phrase("   Limite Global de Responsabilidade: ".toUpperCase() + c.getTotalSeguradoMoeda()
                        + " " + moeda, fontCorpo));
        cellLimiteGlobal.setBorder(0);

        pTableSeguro.addCell(cellTiltuloSegro);
        pTableSeguro.addCell(cellApolice);
        pTableSeguro.addCell(cellPropriedadeSegurada);
        pTableSeguro.addCell(cellTotalSegurado);
        pTableSeguro.addCell(cellValor1Preminio);
        pTableSeguro.addCell(cellTotalPremioAnual);
        pTableSeguro.addCell(cellPeriodo);
        pTableSeguro.addCell(cellDataRenovacao);
        pTableSeguro.addCell(cellNull);
        pTableSeguro.addCell(cellNotaBenefi);
        pTableSeguro.addCell(cellNull);
        pTableSeguro.addCell(cellCobertura);
        pTableSeguro.addCell(cellNull);
        pTableSeguro.addCell(cellLimiteBeneficio);
        pTableSeguro.addCell(cellLimiteA);
        pTableSeguro.addCell(cellLimiteB);
        pTableSeguro.addCell(cellLimiteC);
        pTableSeguro.addCell(cellLimiteGlobal);

        PdfPTable pTableDados = new PdfPTable(new float[] { 7, 15.5f, 15.5f, 15.5f, 15.f, 15.5f, 15.5f });
        PdfPCell cellDadosNum = new PdfPCell(new Phrase("No.".toUpperCase(), fontCorpoNTable));
        cellDadosNum.setBorderWidth(1);

        PdfPCell cellDadosSegurado = new PdfPCell(new Phrase("Nome Segurado".toUpperCase(), fontCorpoNTable));
        cellDadosSegurado.setBorderWidth(1);

        PdfPCell cellDadosCategoria = new PdfPCell(
                new Phrase("Categoria do Segurado".toUpperCase(), fontCorpoNTable));
        cellDadosCategoria.setBorderWidth(1);

        PdfPCell cellDadosBeneficioMorte = new PdfPCell(
                new Phrase("Beneficio Em caso de morte por pessoa".toUpperCase(), fontCorpoNTable));
        cellDadosBeneficioMorte.setBorderWidth(1);

        PdfPCell cellDadosInvalidez = new PdfPCell(new Phrase(
                "Beneficio Em caso de Invalidez permanente por pessoa".toUpperCase(), fontCorpoNTable));
        cellDadosInvalidez.setBorderWidth(1);

        PdfPCell cellDadosTemporaria = new PdfPCell(new Phrase(
                "Beneficio Em caso de Invalidez temporaria por pessoa".toUpperCase(), fontCorpoNTable));
        cellDadosTemporaria.setBorderWidth(1);

        PdfPCell cellDadosDepesasMedica = new PdfPCell(
                new Phrase("Despesa Medica Por Pessoa".toUpperCase(), fontCorpoNTable));
        cellDadosDepesasMedica.setBorderWidth(1);

        pTableDados.addCell(cellDadosNum);
        pTableDados.addCell(cellDadosSegurado);
        pTableDados.addCell(cellDadosCategoria);
        pTableDados.addCell(cellDadosBeneficioMorte);
        pTableDados.addCell(cellDadosInvalidez);
        pTableDados.addCell(cellDadosTemporaria);
        pTableDados.addCell(cellDadosDepesasMedica);

        int total = (apg.getInfo() == null) ? 0 : apg.getInfo().size();
        for (int i = 0; i < total; i++) {
            cellDadosNum = new PdfPCell(new Phrase((i + 1) + " ", fontCorpoTab));
            cellDadosNum.setBorderWidth(1);
            cellDadosNum.setPaddingTop(5f);
            cellDadosNum.setPaddingBottom(5f);

            cellDadosSegurado = new PdfPCell(new Phrase(apg.getInfo().get(i).getNome(), fontCorpoTab));
            cellDadosSegurado.setBorderWidth(1);
            cellDadosSegurado.setPaddingTop(5f);
            cellDadosSegurado.setPaddingBottom(5f);

            cellDadosCategoria = new PdfPCell(new Phrase(apg.getInfo().get(i).getCategoria(), fontCorpoTab));
            cellDadosCategoria.setHorizontalAlignment(Element.ALIGN_CENTER);
            cellDadosCategoria.setBorderWidth(1);
            cellDadosCategoria.setPaddingTop(5f);
            cellDadosCategoria.setPaddingBottom(5f);

            cellDadosBeneficioMorte = new PdfPCell(
                    new Phrase(apg.getInfo().get(i).getValorMorte() + " " + moeda, fontCorpoTab));
            cellDadosBeneficioMorte.setHorizontalAlignment(Element.ALIGN_CENTER);
            cellDadosBeneficioMorte.setBorderWidth(1);
            cellDadosBeneficioMorte.setPaddingTop(5f);
            cellDadosBeneficioMorte.setPaddingBottom(5f);

            cellDadosInvalidez = new PdfPCell(
                    new Phrase(apg.getInfo().get(i).getIncapacidadeTotal() + " " + moeda, fontCorpoTab));
            cellDadosInvalidez.setHorizontalAlignment(Element.ALIGN_CENTER);
            cellDadosInvalidez.setBorderWidth(1);
            cellDadosInvalidez.setPaddingTop(5f);
            cellDadosInvalidez.setPaddingBottom(5f);

            cellDadosTemporaria = new PdfPCell(new Phrase(
                    apg.getInfo().get(i).getIncapacidadeTotalTemporaria() + " " + moeda, fontCorpoTab));
            cellDadosTemporaria.setHorizontalAlignment(Element.ALIGN_CENTER);
            cellDadosTemporaria.setBorderWidth(1);
            cellDadosTemporaria.setPaddingTop(5f);
            cellDadosTemporaria.setPaddingBottom(5f);

            cellDadosDepesasMedica = new PdfPCell(
                    new Phrase(apg.getInfo().get(i).getDespesaMedica() + " " + moeda, fontCorpoTab));
            cellDadosDepesasMedica.setHorizontalAlignment(Element.ALIGN_CENTER);
            cellDadosDepesasMedica.setBorderWidth(1);
            cellDadosDepesasMedica.setPaddingTop(5f);
            cellDadosDepesasMedica.setPaddingBottom(5f);

            pTableDados.addCell(cellDadosNum);
            pTableDados.addCell(cellDadosSegurado);
            pTableDados.addCell(cellDadosCategoria);
            pTableDados.addCell(cellDadosBeneficioMorte);
            pTableDados.addCell(cellDadosInvalidez);
            pTableDados.addCell(cellDadosTemporaria);
            pTableDados.addCell(cellDadosDepesasMedica);
        }

        PdfPTable pTableRenovacaoDataHoje = new PdfPTable(1);
        PdfPCell cellRenovacao = new PdfPCell(new Phrase("Prmio de renovao: ".toUpperCase()
                + ((c.getPremioAnual() == null) ? " " : c.getPremioAnual() + " " + moeda), fontCorpo));
        cellRenovacao.setBorder(0);
        PdfPCell cellData = new PdfPCell(
                new Phrase("Data: ".toUpperCase() + sdf.format(new Date()), fontCorpo));
        cellData.setBorder(0);
        pTableRenovacaoDataHoje.addCell(cellRenovacao);
        pTableRenovacaoDataHoje.addCell(cellData);

        PdfPTable pTableAssinaturaTitulo = new PdfPTable(1);
        PdfPTable pTableAssinatura = new PdfPTable(new float[] { 50f, 50f });
        PdfPCell cellAssinatora = new PdfPCell(new Phrase("Assinaturas".toUpperCase(), fontCorpoN));
        cellAssinatora.setBorder(0);
        cellAssinatora.setHorizontalAlignment(Element.ALIGN_CENTER);
        PdfPCell celllinha1 = new PdfPCell(new Phrase("___________________________".toUpperCase(), fontCorpo));
        celllinha1.setBorder(0);
        celllinha1.setHorizontalAlignment(Element.ALIGN_CENTER);
        PdfPCell celllinha2 = new PdfPCell(new Phrase("___________________________".toUpperCase(), fontCorpo));
        celllinha2.setBorder(0);
        celllinha2.setHorizontalAlignment(Element.ALIGN_CENTER);

        PdfPCell celllinha11 = new PdfPCell(new Phrase("para nicon Seguro sa stp".toUpperCase(), fontCorpoP));
        celllinha11.setBorder(0);
        celllinha11.setHorizontalAlignment(Element.ALIGN_CENTER);
        PdfPCell celllinha21 = new PdfPCell(new Phrase("o segurado ".toUpperCase(), fontCorpoP));
        celllinha21.setBorder(0);
        celllinha21.setHorizontalAlignment(Element.ALIGN_CENTER);

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

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

        //            File ff= new File("Documentos\\"+user+"\\Seguro Acidente para Grupo\\");
        //            ff.mkdirs();
        //            ff =new File(ff.getAbsoluteFile()+"\\"+"Formulario Seguro Acidente Para Grupo "+sdf1.format(new Date())+".pdf");
        File ff = new File(arquivo + "/" + user + "/Seguro Acidente Para Grupo/");
        ff.mkdirs();
        String Ddata = sdf1.format(new Date());
        System.err.println(ff.getAbsoluteFile());
        ff = new File(ff.getAbsoluteFile() + "/" + "Formulario Seguro Acidente Para Grupo " + Ddata + ".pdf");

        reString = "../Documentos/" + user + "/Seguro Acidente Para Grupo/"
                + "Formulario Seguro Acidente Para Grupo " + Ddata + ".pdf";

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

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

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

        documento.open();
        documento.add(pTableEmpresaPricipal);
        documento.add(pTableNull);
        documento.add(pTableNull);
        documento.add(pTableNull);
        documento.add(pTableTitulo);
        documento.add(pTableNull);
        documento.add(pTableNull);
        documento.add(pTableCliente);
        documento.add(pTableNull);
        documento.add(pTableSeguro);
        documento.newPage();
        documento.add(pTableDados);
        documento.add(pTableNull);
        documento.add(pTableRenovacaoDataHoje);
        documento.add(pTableNull);
        documento.add(pTableAssinaturaTitulo);
        documento.add(pTableNull);
        documento.add(pTableNull);
        documento.add(pTableAssinatura);
        documento.close();

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

From source file: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 www  . java2s.  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  a2s .  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:gov.va.cem.eoas.business.FaxArchivesPDF.java

public InputStream generatePDF(FaxRecord data) {
    SimpleDateFormat newFormat = new SimpleDateFormat("MM/dd/yyyy");

    Date curDate = new Date();
    String caseIdData = (data.getCaseId() != null) ? data.getCaseId() : "";
    String currentDate = new String(newFormat.format(curDate));
    String sepDocs = (data.getSepDocs()) ? "X" : "";
    String marLicense = (data.getMarLicense()) ? "X" : "";
    String adminDecision = (data.getAdminDecision()) ? "X" : "";
    String deathCert = (data.getDeathCert()) ? "X" : "";
    String divorceDecree = (data.getDivorceDecree()) ? "X" : "";
    String otherCheck = (data.getOtherCheck()) ? "X" : "";
    String transDate = (data.getTransDate() != null) ? new String(newFormat.format(data.getTransDate())) : "";
    String priorLoc = (data.getPriorLoc() != null) ? data.getPriorLoc() : "";
    String otherComments = (data.getOtherComments() != null) ? data.getOtherComments() : "";
    String remarks = (data.getRemarks() != null) ? data.getRemarks() : "";
    String to = data.getTo().getDisplayName();
    String fileNo = (data.getFileNo() != null) ? data.getFileNo() : "";
    String vetName = (data.getVetName() != null) ? data.getVetName() : "";
    String ssnData = (data.getSSN() != null) ? data.getSSN() : "";
    String snData = (data.getSN() != null) ? data.getSN() : "";
    String farcNo = (data.getFarcNo() != null) ? data.getFarcNo() : "";
    String boxNoData = (data.getBoxNo() != null) ? data.getBoxNo() : "";
    String faxPages = (data.getFaxPages() != null) ? data.getFaxPages() : "";

    ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
    Document document = new Document(PageSize.A4, 50, 50, 50, 50);
    try {/*from  ww  w  .ja  v a2  s . c om*/
        PdfWriter.getInstance(document, outputStream);
        //Font font1 = new Font(Font.FontFamily.TIMES_ROMAN, 9);
        Font font2 = new Font(Font.FontFamily.TIMES_ROMAN, 10, Font.BOLD);
        Font font3 = new Font(Font.FontFamily.TIMES_ROMAN, 11);
        Font fontBold = new Font(Font.FontFamily.TIMES_ROMAN, 11, Font.BOLD);
        //Font fontUnderline = new Font(Font.FontFamily.TIMES_ROMAN, 11, Font.UNDERLINE);
        Font fontHeader = new Font(Font.FontFamily.TIMES_ROMAN, 12, Font.BOLD);

        document.open();

        String dirPath = FacesContext.getCurrentInstance().getExternalContext()
                .getInitParameter("image_file_path");
        // Check servlet context for invalid character
        if (dirPath.contains(".."))
            throw new IllegalArgumentException(
                    "Servlet context contains invalid character(s).  Security may have been compromised.");
        File dir = new File(dirPath);

        Image image = Image.getInstance(dir + "/ArchiveFaxHeader.jpg");
        image.scalePercent(69, 66);
        document.add(image);

        // Create first table
        float[] colsWidthTo = { .3f, 2f, .4f, 2f };
        PdfPTable addressTable = new PdfPTable(colsWidthTo);
        addressTable.setWidthPercentage(100);
        PdfPCell toLabel = new PdfPCell(new Phrase("TO:", fontBold));
        toLabel.setRowspan(3);
        toLabel.setBorderWidthRight(0);
        addressTable.addCell(toLabel);
        PdfPCell toName = new PdfPCell(new Phrase(to, fontBold));
        toName.setBorderWidthLeft(0);
        toName.setBorderWidthBottom(0);
        addressTable.addCell(toName);
        PdfPCell fromLabel = new PdfPCell(new Phrase("FROM:", fontBold));
        fromLabel.setBorderWidthRight(0);
        fromLabel.setBorderWidthBottom(0);
        addressTable.addCell(fromLabel);
        PdfPCell fromName = new PdfPCell(new Phrase("Eligibility Case Manager", fontBold));
        fromName.setBorderWidthBottom(0);
        fromName.setBorderWidthLeft(0);
        addressTable.addCell(fromName);
        PdfPCell toAddress = new PdfPCell(new Phrase("", fontBold));
        toAddress.setBorderWidthLeft(0);
        toAddress.setBorderWidthTop(0);
        addressTable.addCell(toAddress);
        PdfPCell fromDateLabel = new PdfPCell(new Phrase("DATE:", fontBold));
        fromDateLabel.setBorderWidthRight(0);
        fromDateLabel.setBorderWidthTop(0);
        //toLabel.setRowspan(2);
        addressTable.addCell(fromDateLabel);
        PdfPCell dateFrom = new PdfPCell(new Phrase(currentDate, fontBold));
        dateFrom.setBorderWidthTop(0);
        dateFrom.setBorderWidthLeft(0);
        addressTable.addCell(dateFrom);
        addressTable.setSpacingBefore(15);
        addressTable.setSpacingAfter(15);
        document.add(addressTable);

        float[] colsWidthCaseId = { .7f, 3f };
        PdfPTable caseTable = new PdfPTable(colsWidthCaseId);
        caseTable.setWidthPercentage(100);
        PdfPCell caseIdLabel = new PdfPCell(new Phrase("Eligibility Case Id:", font3));
        caseIdLabel.setBorderWidth(0);
        caseTable.addCell(caseIdLabel);
        PdfPCell caseIdInput = new PdfPCell(new Phrase(caseIdData, font3));
        caseIdInput.setBorderWidth(0);
        caseTable.addCell(caseIdInput);
        caseTable.setSpacingAfter(8);
        document.add(caseTable);

        float[] colsWidthFolder = { .5f, 3f };
        PdfPTable folderTable = new PdfPTable(colsWidthFolder);
        folderTable.setWidthPercentage(100);
        PdfPCell folderLabel = new PdfPCell(new Phrase("VA file No:", font3));
        folderLabel.setBorderWidth(0);
        folderTable.addCell(folderLabel);
        PdfPCell folder = new PdfPCell(new Phrase(fileNo, font3));
        folder.setBorderWidth(0);
        folderTable.addCell(folder);
        folderTable.setSpacingAfter(8);
        document.add(folderTable);

        float[] colsWidthRef = { .7f, 3f };
        PdfPTable refTable = new PdfPTable(colsWidthRef);
        refTable.setWidthPercentage(100);
        PdfPCell ref = new PdfPCell(new Phrase("Veteran's Name:", font3));
        ref.setBorderWidth(0);
        refTable.addCell(ref);
        PdfPCell refName = new PdfPCell(new Phrase(vetName, font3));
        refName.setBorderWidth(0);
        refTable.addCell(refName);
        refTable.setSpacingAfter(8);
        document.add(refTable);

        float[] colsWidthSSN = { .3f, 2f, .25f, 2f };
        PdfPTable ssnTable = new PdfPTable(colsWidthSSN);
        ssnTable.setWidthPercentage(100);
        PdfPCell ssnLabel = new PdfPCell(new Phrase("SSN:", font3));
        ssnLabel.setBorderWidth(0);
        ssnTable.addCell(ssnLabel);
        PdfPCell ssn = new PdfPCell(new Phrase(ssnData, font3));
        ssn.setBorderWidth(0);
        ssnTable.addCell(ssn);
        PdfPCell snLabel = new PdfPCell(new Phrase("SN:", font3));
        snLabel.setBorderWidth(0);
        ssnTable.addCell(snLabel);
        PdfPCell sn = new PdfPCell(new Phrase(snData, font3));
        sn.setBorderWidth(0);
        ssnTable.addCell(sn);
        ssnTable.setSpacingAfter(8);
        document.add(ssnTable);

        float[] colsWidthFARC = { .6f, 2f, .8f, 2f };
        PdfPTable farcTable = new PdfPTable(colsWidthFARC);
        farcTable.setWidthPercentage(100);
        PdfPCell farcLabel = new PdfPCell(new Phrase("FARC No:", font3));
        farcLabel.setBorderWidth(0);
        farcTable.addCell(farcLabel);
        PdfPCell farc = new PdfPCell(new Phrase(farcNo, font3));
        farc.setBorderWidth(0);
        farcTable.addCell(farc);
        PdfPCell farcDateLabel = new PdfPCell(new Phrase("Transfer Date:", font3));
        farcDateLabel.setBorderWidth(0);
        farcTable.addCell(farcDateLabel);
        PdfPCell farcDate = new PdfPCell(new Phrase(transDate, font3));
        farcDate.setBorderWidth(0);
        farcTable.addCell(farcDate);
        farcTable.setSpacingAfter(8);
        document.add(farcTable);

        float[] colsWidthLoc = { .8f, 2f, .6f, 2f };
        PdfPTable locTable = new PdfPTable(colsWidthLoc);
        locTable.setWidthPercentage(100);
        PdfPCell locLabel = new PdfPCell(new Phrase("Prior Location:", font3));
        locLabel.setBorderWidth(0);
        locTable.addCell(locLabel);
        PdfPCell location = new PdfPCell(new Phrase(priorLoc, font3));
        location.setBorderWidth(0);
        locTable.addCell(location);
        PdfPCell boxNoLabel = new PdfPCell(new Phrase("Box No:", font3));
        boxNoLabel.setBorderWidth(0);
        locTable.addCell(boxNoLabel);
        PdfPCell boxNo = new PdfPCell(new Phrase(boxNoData, font3));
        boxNo.setBorderWidth(0);
        locTable.addCell(boxNo);
        locTable.setSpacingAfter(8);
        document.add(locTable);

        float[] colsWidthRemarks = { .6f, 5f };
        PdfPTable remarks1Table = new PdfPTable(colsWidthRemarks);
        remarks1Table.setWidthPercentage(100);
        PdfPCell remark1Label = new PdfPCell(new Phrase("Remarks:", font3));
        remark1Label.setBorderWidth(0);
        remarks1Table.addCell(remark1Label);
        PdfPCell remarks1Input = new PdfPCell(new Phrase(
                "Please provide copy(ies) of the following document(s) to establish eligibility for burial in a national cemetery.",
                font3));
        remarks1Input.setBorderWidth(0);
        remarks1Table.addCell(remarks1Input);
        remarks1Table.setSpacingAfter(8);
        document.add(remarks1Table);

        float[] colsWidthDocs = { .4f, 2f, .4f, 2f };
        PdfPTable docsTable = new PdfPTable(colsWidthDocs);
        docsTable.setWidthPercentage(100);
        PdfPCell docsLabel = new PdfPCell(new Phrase(sepDocs, font3));
        docsLabel.setHorizontalAlignment(Element.ALIGN_CENTER);
        docsLabel.setBorderWidth(0);
        docsLabel.setBorderWidthBottom(1);
        docsTable.addCell(docsLabel);
        PdfPCell docs1 = new PdfPCell(new Phrase("Separation Document(s)", font3));
        docs1.setBorderWidth(0);
        docsTable.addCell(docs1);
        PdfPCell docs2 = new PdfPCell(new Phrase(deathCert, font3));
        docs2.setHorizontalAlignment(Element.ALIGN_CENTER);
        docs2.setBorderWidth(0);
        docs2.setBorderWidthBottom(1);
        docsTable.addCell(docs2);
        PdfPCell docs3 = new PdfPCell(new Phrase("Death Certificate", font3));
        docs3.setBorderWidth(0);
        docsTable.addCell(docs3);
        PdfPCell docs4 = new PdfPCell(new Phrase(marLicense, font3));
        docs4.setHorizontalAlignment(Element.ALIGN_CENTER);
        docs4.setBorderWidth(0);
        docs4.setBorderWidthBottom(1);
        docsTable.addCell(docs4);
        PdfPCell docs5 = new PdfPCell(new Phrase("Marriage License", font3));
        docs5.setBorderWidth(0);
        docsTable.addCell(docs5);
        PdfPCell docs6 = new PdfPCell(new Phrase(divorceDecree, font3));
        docs6.setHorizontalAlignment(Element.ALIGN_CENTER);
        docs6.setBorderWidth(0);
        docs6.setBorderWidthBottom(1);
        docsTable.addCell(docs6);
        PdfPCell docs7 = new PdfPCell(new Phrase("Divorce Decree", font3));
        docs7.setBorderWidth(0);
        docsTable.addCell(docs7);
        PdfPCell docs8 = new PdfPCell(new Phrase(adminDecision, font3));
        docs8.setHorizontalAlignment(Element.ALIGN_CENTER);
        docs8.setBorderWidth(0);
        docs8.setBorderWidthBottom(1);
        docsTable.addCell(docs8);
        PdfPCell docs9 = new PdfPCell(new Phrase("VA Admin Decision", font3));
        docs9.setBorderWidth(0);
        docsTable.addCell(docs9);
        PdfPCell docs10 = new PdfPCell(new Phrase("", font3));
        docs10.setBorderWidth(0);
        docsTable.addCell(docs10);
        PdfPCell docs11 = new PdfPCell(new Phrase("", font3));
        docs11.setBorderWidth(0);
        docsTable.addCell(docs11);
        document.add(docsTable);

        float[] colsWidthOther = { .4f, .4f, 4f };
        PdfPTable otherDocTable = new PdfPTable(colsWidthOther);
        otherDocTable.setWidthPercentage(100);
        PdfPCell otherDoc1 = new PdfPCell(new Phrase(otherCheck, font3));
        otherDoc1.setHorizontalAlignment(Element.ALIGN_CENTER);
        otherDoc1.setBorderWidth(0);
        otherDoc1.setBorderWidthBottom(1);
        otherDocTable.addCell(otherDoc1);
        PdfPCell otherDoc2 = new PdfPCell(new Phrase("Other", font3));
        otherDoc2.setBorderWidth(0);
        otherDocTable.addCell(otherDoc2);
        PdfPCell otherDoc3 = new PdfPCell(new Phrase("", font3));
        otherDoc3.setBorderWidth(0);
        otherDocTable.addCell(otherDoc3);
        otherDocTable.setSpacingAfter(8);
        document.add(otherDocTable);

        if (!otherComments.equals("")) {
            float[] colsWidthOtherComments = { 1.1f, 5f };
            PdfPTable otherCommentsTable = new PdfPTable(colsWidthOtherComments);
            otherCommentsTable.setWidthPercentage(100);
            PdfPCell otherCommentLabel = new PdfPCell(new Phrase("Other Comments:", font3));
            otherCommentLabel.setBorderWidth(0);
            otherCommentsTable.addCell(otherCommentLabel);
            PdfPCell otherCommentsInput = new PdfPCell(new Phrase(otherComments, font3));
            otherCommentsInput.setBorderWidth(0);
            otherCommentsTable.addCell(otherCommentsInput);
            otherCommentsTable.setSpacingAfter(8);
            document.add(otherCommentsTable);
        }

        PdfPTable remarksTable = new PdfPTable(colsWidthRemarks);
        remarksTable.setWidthPercentage(100);
        PdfPCell remarkLabel = new PdfPCell(new Phrase("Remarks:", font3));
        remarkLabel.setBorderWidth(0);
        remarksTable.addCell(remarkLabel);
        PdfPCell remarksInput = new PdfPCell(new Phrase(remarks, font3));
        remarksInput.setBorderWidth(0);
        remarksTable.addCell(remarksInput);
        remarksTable.setSpacingAfter(8);
        document.add(remarksTable);

        Paragraph expediteOne = new Paragraph("-- PLEASE EXPEDITE --", font3);
        expediteOne.setSpacingBefore(5);
        expediteOne.setSpacingAfter(10);
        document.add(expediteOne);

        Paragraph disclosure = new Paragraph(
                "This fax is intended only for the use of the person or office to which it is addressed and may contain information that is privileged, confidential, or protected by law.  All others are hereby notified that the receipt of this fax does not waive any applicable privilege or exemption for disclosure and that any dissemination, distribution, or copying of this communication is prohibited.  If you have received this fax in error, please notify this office immediately at the telephone number listed above.",
                font2);
        disclosure.setAlignment(Element.ALIGN_JUSTIFIED);
        disclosure.setSpacingBefore(5);
        disclosure.setSpacingAfter(10);
        document.add(disclosure);

        float[] colsWidthPages = { 5f, .5f, 2f };
        PdfPTable pagesTable = new PdfPTable(colsWidthPages);
        pagesTable.setWidthPercentage(71);
        PdfPCell pageOneLabel = new PdfPCell(
                new Phrase("This fax sheet consists of the cover page and ", fontHeader));
        pageOneLabel.setBorderWidth(0);
        pageOneLabel.setHorizontalAlignment(Element.ALIGN_RIGHT);
        pagesTable.addCell(pageOneLabel);
        PdfPCell pages = new PdfPCell(new Phrase(faxPages, fontHeader));
        pages.setBorderWidth(0);
        pages.setHorizontalAlignment(Element.ALIGN_CENTER);
        pages.setBorderWidthBottom(1);
        pagesTable.addCell(pages);
        PdfPCell pageTwoLabel = new PdfPCell(new Phrase(" additional pages", fontHeader));
        pageTwoLabel.setBorderWidth(0);
        pagesTable.addCell(pageTwoLabel);
        pagesTable.setSpacingAfter(8);
        document.add(pagesTable);

        Paragraph expediteTwo = new Paragraph("FAX:  816-268-8163  ***** BURIAL  PLEASE EXPEDITE   *****",
                fontBold);
        expediteTwo.setSpacingBefore(5);
        expediteTwo.setSpacingAfter(10);
        document.add(expediteTwo);

        document.close();
    } catch (Exception ex) {
        System.err.println(ex.getMessage());
    }
    return new ByteArrayInputStream(outputStream.toByteArray());

}

From source file:GUI_Apoteker.Panel_Detil_PO.java

private PdfPTable createTableBulanan(List<detil_pesan_obat> a) {
    PdfPTable tabel = new PdfPTable(2);
    PdfPCell cell;
    cell = new PdfPCell(new Phrase(("Nama Obat"), font6));
    cell.setRowspan(2);//from   ww  w.  jav  a2 s  .  c om
    cell.setHorizontalAlignment(Element.ALIGN_LEFT);
    cell.setBorder(Rectangle.BOX);
    cell.setBorderWidth(1);
    tabel.addCell(cell);
    cell = new PdfPCell(new Phrase(("Jumlah Obat yang dipesan"), font6));
    cell.setRowspan(2);
    cell.setBorder(Rectangle.BOX);
    cell.setBorderWidth(1);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER);
    tabel.addCell(cell);
    for (int i = 0; i < a.size(); i++) {
        cell = new PdfPCell(new Phrase(("" + a.get(i).getNama_Obat()), font5));
        cell.setHorizontalAlignment(Element.ALIGN_LEFT);
        tabel.addCell(cell);

        cell = new PdfPCell(new Phrase(("" + a.get(i).getJumlah_Pesan()), font5));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        tabel.addCell(cell);
    }
    return tabel;
}

From source file:GUI_StafKlinik.Panel_Laporan_Keuangan.java

private PdfPTable createTableLaporan(List<Laporan_Keuangan> list) {
    PdfPTable tabel = new PdfPTable(6);
    PdfPCell cell;
    cell = new PdfPCell(new Phrase(("Tanggal"), font6));
    cell.setHorizontalAlignment(Element.ALIGN_CENTER);
    cell.setRowspan(1);/*  w w  w.  java2 s.  com*/
    cell.setBorder(Rectangle.BOX);
    cell.setBorderWidth(1);
    tabel.addCell(cell);
    cell = new PdfPCell(new Phrase(("Keterangan"), font6));
    cell.setRowspan(1);
    cell.setColspan(1);
    cell.setBorder(Rectangle.BOX);
    cell.setBorderWidth(1);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER);
    tabel.addCell(cell);
    cell = new PdfPCell(new Phrase(("Ref"), font6));
    cell.setHorizontalAlignment(Element.ALIGN_CENTER);
    cell.setRowspan(1);
    cell.setBorder(Rectangle.BOX);
    cell.setBorderWidth(1);
    tabel.addCell(cell);
    cell = new PdfPCell(new Phrase(("Pemasukan"), font6));
    cell.setHorizontalAlignment(Element.ALIGN_CENTER);
    cell.setRowspan(1);
    cell.setBorder(Rectangle.BOX);
    cell.setBorderWidth(1);
    tabel.addCell(cell);
    cell = new PdfPCell(new Phrase(("Pengeluaran"), font6));
    cell.setHorizontalAlignment(Element.ALIGN_CENTER);
    cell.setRowspan(1);
    cell.setBorder(Rectangle.BOX);
    cell.setBorderWidth(1);
    tabel.addCell(cell);
    cell = new PdfPCell(new Phrase(("Saldo"), font6));
    cell.setColspan(1);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER);
    cell.setBorder(Rectangle.BOX);
    cell.setBorderWidth(1);
    tabel.addCell(cell);

    for (int i = 0; i < list.size(); i++) {
        cell = new PdfPCell(new Phrase(("" + list.get(i).getTanggal()), font5));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        tabel.addCell(cell);

        cell = new PdfPCell(new Phrase(("" + list.get(i).getKeterangan()), font5));
        cell.setHorizontalAlignment(Element.ALIGN_LEFT);
        tabel.addCell(cell);

        cell = new PdfPCell(new Phrase(("" + list.get(i).getRef()), font5));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        tabel.addCell(cell);

        cell = new PdfPCell(new Phrase(("" + list.get(i).getPemasukan()), font5));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        tabel.addCell(cell);

        cell = new PdfPCell(new Phrase(("" + list.get(i).getPengeluaran()), font5));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        tabel.addCell(cell);

        cell = new PdfPCell(new Phrase(("" + list.get(i).getSaldo()), font5));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        tabel.addCell(cell);
    }
    return tabel;
}