Example usage for com.itextpdf.text BaseColor BaseColor

List of usage examples for com.itextpdf.text BaseColor BaseColor

Introduction

In this page you can find the example usage for com.itextpdf.text BaseColor BaseColor.

Prototype

public BaseColor(final float red, final float green, final float blue) 

Source Link

Document

Construct a BaseColor with float values.

Usage

From source file:Export.ExportViagemSemanaPdf.java

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

    Font fontRoadape = FontFactory.getFont(ConfigDoc.Fontes.FONTB, BaseFont.WINANSI, BaseFont.EMBEDDED, 8f);
    Font fontRoadapeP = FontFactory.getFont(ConfigDoc.Fontes.FONTB, BaseFont.WINANSI, BaseFont.EMBEDDED, 6f);
    Font fontRoadapeB = FontFactory.getFont(ConfigDoc.Fontes.FONTB, BaseFont.WINANSI, BaseFont.EMBEDDED, 8f);
    Font fontRoadapeBU = FontFactory.getFont(ConfigDoc.Fontes.FONTB, BaseFont.WINANSI, BaseFont.EMBEDDED, 8f,
            Font.UNDEFINED);/*www. j av a  2  s.  c  om*/

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

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

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

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

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

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

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

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

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

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

        dataViagem(dataInicio, dateFim);

        float premiototal = 0;

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

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

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

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

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

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

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

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

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

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

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

        pTableEmpresaPricipal.setHorizontalAlignment(Element.ALIGN_CENTER);

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

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

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

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

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

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

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

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

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

From source file:Export.GenericPDFs.java

/**
 *
 * @param user/*  w w  w.  jav a  2s  . c o m*/
 * @param nomeDoc
 * @param titleDoc
 * @param rs
 * @param op
 * @param paramFilter
 * @return
 */
public static String createDoc(String user, String nomeDoc, String titleDoc, DataTableControl rs,
        OrientacaoPagina op, int paramFilter) {
    nomeDocR = nomeDoc;
    try {

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

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

        Document documento = new Document();

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        pTableEmpresaInforImpres5.addCell(cellTabela3);

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

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

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

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

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

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

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

                documento.add(tableDados);

            }

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

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

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

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

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

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

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

                    documento.add(tableDados);

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

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

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

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

From source file:Export.ListaVeiculo.java

public static void criarDocPdf(List<Veiculo> ls, String user) {
    @SuppressWarnings("UnusedAssignment")
    OutputStream outputStraem = null;
    try {//  w w w  .  j a v  a2 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.SeguroCoberturaViagem.java

private static void criarDoc(Document documento, ViagemBean vb, String numCriente, String user, Contrato c,
        int i) throws DocumentException, FileNotFoundException, IOException, BadElementException {
    BaseColor colorVermelho = new BaseColor(193, 51, 51);
    BaseColor coloAzul = new BaseColor(0, 0, 179);

    Font fontCabecalhoN = FontFactory.getFont(Fontes.FONTB, BaseFont.WINANSI, BaseFont.EMBEDDED, 10.5f,
            Font.NORMAL, coloAzul);
    Font fontCabecalhoTitile = FontFactory.getFont(Fontes.FONTB, BaseFont.WINANSI, BaseFont.EMBEDDED, 14.5f,
            Font.UNDERLINE, colorVermelho);
    Font fontTableSimple = FontFactory.getFont(Fontes.FONT, BaseFont.WINANSI, BaseFont.EMBEDDED, 8.5f);
    Font fontTableNegrito = FontFactory.getFont(Fontes.FONTB, BaseFont.WINANSI, BaseFont.EMBEDDED, 8.5f);
    Font fontTableSimpleMenor = FontFactory.getFont(Fontes.FONT, BaseFont.WINANSI, BaseFont.EMBEDDED, 8f);
    Font fontTableItalico = FontFactory.getFont(Fontes.FONTBI, BaseFont.WINANSI, BaseFont.EMBEDDED, 8f);
    Font fontTableNormal = FontFactory.getFont(Fontes.FONT, BaseFont.WINANSI, BaseFont.EMBEDDED, 8f);
    Font fontTableSimpleCausulas = FontFactory.getFont(Fontes.FONT, BaseFont.WINANSI, BaseFont.EMBEDDED,
            8.999999f);/*from w  w w  . ja  va 2s.  c  o m*/

    //        SimpleDateFormat sdf= new SimpleDateFormat("dd-MM-yyyy");

    Font fontCabecalhoNP = FontFactory.getFont(Fontes.FONTB, BaseFont.WINANSI, BaseFont.EMBEDDED, 9.5f);
    Font fontCorpo = FontFactory.getFont(Fontes.FONT, BaseFont.WINANSI, BaseFont.EMBEDDED, 8.5f);
    Font fontCabecalhoNG = FontFactory.getFont(Fontes.FONTB, BaseFont.WINANSI, BaseFont.EMBEDDED, 16f,
            Font.UNDERLINE, coloAzul);

    PdfPTable pTableEmpresaPricipal = new PdfPTable(new float[] { 23f, 77f });
    pTableEmpresaPricipal.setWidthPercentage(92);
    PdfPTable pTableEmpresaInforImpres1 = new PdfPTable(1);
    PdfPTable pTableEmpresaInforImpres2 = new PdfPTable(1);
    PdfPTable pTableEmpresaInforImpres5 = new PdfPTable(1);

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

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

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

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

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

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

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

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

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

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

    pTableEmpresaInforImpres5.addCell(cellTabela3);

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

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

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

    PdfPTable pTableTitulo = new PdfPTable(1);
    pTableTitulo.setWidthPercentage(92f);
    PdfPCell paragraphTitulo = new PdfPCell(new Phrase("SEGURO DE VIAGEM", fontCabecalhoTitile));
    paragraphTitulo.setHorizontalAlignment(Element.ALIGN_CENTER);
    paragraphTitulo.setBorder(0);
    pTableTitulo.addCell(paragraphTitulo);

    PdfPTable pTablePrincipalSegurado = new PdfPTable(new float[] { 55, 45 });
    pTablePrincipalSegurado.setWidthPercentage(92);
    Paragraph pa = new Paragraph(new Phrase("NOME DO SEGURADO: ", fontTableSimple));
    pa.add(new Phrase(vb.getInfoPessoaSegurada().get(i).getNomePessoaSegurada().toUpperCase(),
            fontTableNegrito));
    PdfPCell cellSegurado02 = new PdfPCell(pa);

    pa = new Paragraph(new Phrase("Endereo: ".toUpperCase(), fontTableSimple));
    pa.add(new Phrase(vb.getInfoPessoaSegurada().get(i).getEndereco().toUpperCase(), fontTableNegrito));
    PdfPCell cellSegurado12 = new PdfPCell(pa);

    pa = new Paragraph(new Phrase("Data e Local de Nascimento: ".toUpperCase(), fontTableSimple));
    pa.add(new Phrase(vb.getInfoPessoaSegurada().get(i).getDataNascFormatada().toUpperCase(),
            fontTableNegrito));
    pa.add(new Phrase(" EM", fontTableSimple));
    pa.add(new Phrase(" " + vb.getInfoPessoaSegurada().get(i).getLocalNascimento().toUpperCase(),
            fontTableNegrito));
    PdfPCell cellSegurado21 = new PdfPCell(pa);

    pa = new Paragraph(new Phrase("Sexo: ".toUpperCase(), fontTableSimple));
    pa.add(new Phrase(vb.getInfoPessoaSegurada().get(i).getSexo().toUpperCase(), fontTableNegrito));
    pa.add(new Phrase("  Tel: ".toUpperCase(), fontTableSimple));
    pa.add(new Phrase(vb.getInfoPessoaSegurada().get(i).getTelefone().toUpperCase(), fontTableNegrito));
    PdfPCell cellSegurado22 = new PdfPCell(pa);

    pa = new Paragraph(new Phrase("Aplice: ".toUpperCase(), fontTableSimple));
    pa.add(new Phrase(vb.getInfoPessoaSegurada().get(i).getNumApolice().toUpperCase(), fontTableNegrito));
    PdfPCell cellSegurado31 = new PdfPCell(pa);

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

    pa = new Paragraph(new Phrase("Cliente: ".toUpperCase(), fontTableSimple));
    pa.add(new Phrase(((codCliente.length == 2) ? "TIN " + codCliente[1] : "TIN ").toUpperCase(),
            fontTableNegrito));
    PdfPCell cellSegurado32 = new PdfPCell(pa);

    pa = new Paragraph(new Phrase("Durao: ".toUpperCase(), fontTableSimple));
    pa.add(new Phrase(vb.getInfoPessoaSegurada().get(i).getNumDias() + " DIAS", fontTableNegrito));
    PdfPCell cellSegurado41 = new PdfPCell(pa);

    pa = new Paragraph(new Phrase("Perodo: DE ".toUpperCase(), fontTableSimple));
    pa.add(new Phrase(sdfPot.format(vb.getInfoPessoaSegurada().get(i).getDataInicio()).toUpperCase(),
            fontTableNegrito));
    pa.add(new Phrase("  ".toUpperCase(), fontTableSimple));
    pa.add(new Phrase(((vb.getInfoPessoaSegurada().get(i).getDataFim() != null)
            ? sdfPot.format(vb.getInfoPessoaSegurada().get(i).getDataFim())
            : " ").toUpperCase(), fontTableNegrito));
    PdfPCell cellSegurado42 = new PdfPCell(pa);

    pa = new Paragraph(new Phrase("Data de Emisso: ".toUpperCase(), fontTableSimple));
    pa.add(new Phrase(sdfPot.format(c.getDataContrato()).toUpperCase(), fontTableNegrito));
    PdfPCell cellSegurado51 = new PdfPCell(pa);

    pa = new Paragraph(new Phrase("Destino: ".toUpperCase(), fontTableSimple));
    pa.add(new Phrase(
            ClienteDao.paisesSelected(vb.getInfoPessoaSegurada().get(i).getPaisDestino().toUpperCase()),
            fontTableNegrito));
    pa.add(new Phrase(" N de Pessoas: ".toUpperCase(), fontTableSimple));
    pa.add(new Phrase((i + 1) + "".toUpperCase(), fontTableNegrito));
    PdfPCell cellSegurado52 = new PdfPCell(pa);

    //        PASSAPORTE   BILHETE IDENTIDADE
    pa = new Paragraph(new Phrase("Meio de Identificao: ".toUpperCase(), fontTableSimple));
    pa.add(new Phrase(
            (vb.getInfoPessoaSegurada().get(i).getTipoDoc().toUpperCase().equals("PASSAPORTE") ? "PASS"
                    : (vb.getInfoPessoaSegurada().get(i).getTipoDoc().toUpperCase().equals("BILHETE IDENTIDADE")
                            ? "BI"
                            : vb.getInfoPessoaSegurada().get(i).getTipoDoc().toUpperCase())),
            fontTableNegrito));
    pa.add(new Phrase(" N ".toUpperCase(), fontTableSimple));
    pa.add(new Phrase(vb.getInfoPessoaSegurada().get(i).getNumDoc().toUpperCase(), fontTableNegrito));
    PdfPCell cellSegurado61 = new PdfPCell(pa);

    pa = new Paragraph(new Phrase("Emitido EM: ".toUpperCase(), fontTableSimple));
    pa.add(new Phrase(vb.getInfoPessoaSegurada().get(i).getLocalEmissao().toUpperCase() + " ".toUpperCase(),
            fontTableNegrito));
    pa.add(new Phrase(" em ".toUpperCase(), fontTableSimple));
    pa.add(new Phrase(vb.getInfoPessoaSegurada().get(i).getDataEmissaoFormatada().toUpperCase(),
            fontTableNegrito));
    PdfPCell cellSegurado62 = new PdfPCell(pa);

    pa = new Paragraph(new Phrase("Outras Informaes: ".toUpperCase(), fontTableSimple));
    pa.add(new Phrase(
            ((vb.getInfoPessoaSegurada().get(i).getOutrasInformacoes() == null) ? " "
                    : vb.getInfoPessoaSegurada().get(i).getOutrasInformacoes().toUpperCase()).toUpperCase(),
            fontTableNegrito));
    PdfPCell cellSegurado72 = new PdfPCell(pa);

    cellSegurado02.setBorder(0);
    cellSegurado02.setColspan(2);
    pTablePrincipalSegurado.addCell(cellSegurado02);
    cellSegurado12.setColspan(2);
    cellSegurado12.setBorder(0);
    pTablePrincipalSegurado.addCell(cellSegurado12);
    cellSegurado21.setBorder(0);
    pTablePrincipalSegurado.addCell(cellSegurado21);
    cellSegurado22.setBorder(0);
    pTablePrincipalSegurado.addCell(cellSegurado22);
    cellSegurado31.setBorder(0);
    pTablePrincipalSegurado.addCell(cellSegurado31);
    cellSegurado32.setBorder(0);
    pTablePrincipalSegurado.addCell(cellSegurado32);
    cellSegurado41.setBorder(0);
    pTablePrincipalSegurado.addCell(cellSegurado41);
    cellSegurado42.setBorder(0);
    pTablePrincipalSegurado.addCell(cellSegurado42);
    cellSegurado51.setBorder(0);
    pTablePrincipalSegurado.addCell(cellSegurado51);
    cellSegurado52.setBorder(0);
    pTablePrincipalSegurado.addCell(cellSegurado52);
    cellSegurado61.setBorder(0);
    pTablePrincipalSegurado.addCell(cellSegurado61);
    cellSegurado62.setBorder(0);
    pTablePrincipalSegurado.addCell(cellSegurado62);
    cellSegurado72.setBorder(0);
    cellSegurado72.setColspan(2);
    pTablePrincipalSegurado.addCell(cellSegurado72);

    PdfPTable pTableOtros = new PdfPTable(1);
    pTableOtros.setWidthPercentage(92f);
    //            PdfPCell paragraphOutros = new PdfPCell(new Phrase("Outros Informaes:",fontTableSimple));
    PdfPCell paragraphNotaDebito = new PdfPCell(new Phrase(" ", fontTableNegrito));
    PdfPCell paragraphAmbitoC = new PdfPCell(
            new Phrase("mbito de Cobertura/Condies Particulares:", fontTableSimple));

    //            paragraphOutros.setBorder(0);
    //            pTableOtros.addCell(paragraphOutros);
    paragraphNotaDebito.setBorder(0);
    pTableOtros.addCell(paragraphNotaDebito);
    paragraphAmbitoC.setBorder(0);
    paragraphAmbitoC.setPaddingBottom(5f);
    pTableOtros.addCell(paragraphAmbitoC);

    PdfPTable pTableCobertura = new PdfPTable(new float[] { 70, 30 });
    pTableCobertura.setWidthPercentage(92);
    PdfPCell cellTable11 = new PdfPCell(new Phrase("COBERTURA", fontTableNegrito));
    PdfPCell cellTable12 = new PdfPCell(new Phrase("Limites de Indemnizao", fontTableNegrito));
    PdfPCell cellTable21 = new PdfPCell(
            new Phrase("Depesas mdicas, Cirgias, Farmacutica e de Hospitalizao no Estrangeiro",
                    fontTableSimpleMenor));
    PdfPCell cellTable22 = new PdfPCell(new Phrase("Euros 30.000 Franquia: 80 Euros", fontTableSimpleMenor));
    PdfPCell cellTable31 = new PdfPCell(
            new Phrase("Acompanhamento da pessoa segura hospitalizada", fontTableSimpleMenor));
    PdfPCell cellTable32 = new PdfPCell(new Phrase("Dia: Euros 70/ Mximo:Euros 700", fontTableSimpleMenor));
    PdfPCell cellTable41 = new PdfPCell(
            new Phrase("Transporte de ida e volta de familiar e estadia", fontTableSimpleMenor));
    PdfPCell cellTable42 = new PdfPCell(new Phrase("Dia: Euros 70/ Mximo: Euros 700", fontTableSimpleMenor));
    PdfPCell cellTable51 = new PdfPCell(new Phrase("Prolongamento de estadia no Hotel", fontTableSimpleMenor));
    PdfPCell cellTable52 = new PdfPCell(new Phrase("Dia: Euros 40/ Mximo: Euros 400", fontTableSimpleMenor));
    PdfPCell cellTable61 = new PdfPCell(
            new Phrase("Repatriamento / Transporte sanitrio de feridos e doentes", fontTableSimpleMenor));
    PdfPCell cellTable62 = new PdfPCell(new Phrase("Ilimitado", fontTableSimpleMenor));
    PdfPCell cellTable71 = new PdfPCell(
            new Phrase("Repatriamento / Transporte aps a morte", fontTableSimpleMenor));
    PdfPCell cellTable72 = new PdfPCell(new Phrase("Ilimitado", fontTableSimpleMenor));
    PdfPCell cellTable81 = new PdfPCell(
            new Phrase("Transporte ou Repatriamento das restantes pessoas seguras", fontTableSimpleMenor));
    PdfPCell cellTable82 = new PdfPCell(new Phrase("Ilimitado", fontTableSimpleMenor));
    PdfPCell cellTable91 = new PdfPCell(
            new Phrase("Superviso de crianas no estrangeiro", fontTableSimpleMenor));
    PdfPCell cellTable92 = new PdfPCell(new Phrase("Ilimitado", fontTableSimpleMenor));
    PdfPCell cellTable101 = new PdfPCell(
            new Phrase("Regresso antecipado por falecimento de familiar", fontTableSimpleMenor));
    PdfPCell cellTable102 = new PdfPCell(new Phrase("Ilimitado", fontTableSimpleMenor));
    PdfPCell cellTable111 = new PdfPCell(
            new Phrase("Localizao e envio de medicamentos de urgncia", fontTableSimpleMenor));
    PdfPCell cellTable112 = new PdfPCell(new Phrase("Ilimitado", fontTableSimpleMenor));
    PdfPCell cellTable121 = new PdfPCell(
            new Phrase("Transporte ou repatriamento de bagagens", fontTableSimpleMenor));
    PdfPCell cellTable122 = new PdfPCell(
            new Phrase("Limite imposto pela Empresa Transportadora", fontTableSimpleMenor));
    PdfPCell cellTable131 = new PdfPCell(
            new Phrase("Adiantamento de fundos no estrangeiro", fontTableSimpleMenor));
    PdfPCell cellTable132 = new PdfPCell(new Phrase("Mximo: Euros 700", fontTableSimpleMenor));
    PdfPCell cellTable141 = new PdfPCell(new Phrase("Aconselhamento mdico", fontTableSimpleMenor));
    PdfPCell cellTable142 = new PdfPCell(new Phrase("Ilimitado", fontTableSimpleMenor));
    PdfPCell cellTable151 = new PdfPCell(
            new Phrase("Pagamento de despesas de comunicao", fontTableSimpleMenor));
    PdfPCell cellTable152 = new PdfPCell(new Phrase("Ilimitado", fontTableSimpleMenor));
    PdfPCell cellTable161 = new PdfPCell(new Phrase("Servios informativos", fontTableSimpleMenor));
    PdfPCell cellTable162 = new PdfPCell(new Phrase("Ilimitado", fontTableSimpleMenor));

    cellTable11.setHorizontalAlignment(Element.ALIGN_CENTER);
    pTableCobertura.addCell(cellTable11);
    cellTable12.setHorizontalAlignment(Element.ALIGN_CENTER);
    pTableCobertura.addCell(cellTable12);
    pTableCobertura.addCell(cellTable21);
    cellTable22.setHorizontalAlignment(Element.ALIGN_CENTER);
    pTableCobertura.addCell(cellTable22);
    pTableCobertura.addCell(cellTable31);
    cellTable32.setHorizontalAlignment(Element.ALIGN_CENTER);
    pTableCobertura.addCell(cellTable32);
    pTableCobertura.addCell(cellTable41);
    cellTable42.setHorizontalAlignment(Element.ALIGN_CENTER);
    pTableCobertura.addCell(cellTable42);
    pTableCobertura.addCell(cellTable51);
    cellTable52.setHorizontalAlignment(Element.ALIGN_CENTER);
    pTableCobertura.addCell(cellTable52);
    pTableCobertura.addCell(cellTable61);
    cellTable62.setHorizontalAlignment(Element.ALIGN_CENTER);
    pTableCobertura.addCell(cellTable62);
    pTableCobertura.addCell(cellTable71);
    cellTable72.setHorizontalAlignment(Element.ALIGN_CENTER);
    pTableCobertura.addCell(cellTable72);
    pTableCobertura.addCell(cellTable81);
    cellTable82.setHorizontalAlignment(Element.ALIGN_CENTER);
    pTableCobertura.addCell(cellTable82);
    pTableCobertura.addCell(cellTable91);
    cellTable92.setHorizontalAlignment(Element.ALIGN_CENTER);
    pTableCobertura.addCell(cellTable92);
    pTableCobertura.addCell(cellTable101);
    cellTable102.setHorizontalAlignment(Element.ALIGN_CENTER);
    pTableCobertura.addCell(cellTable102);
    pTableCobertura.addCell(cellTable111);
    cellTable112.setHorizontalAlignment(Element.ALIGN_CENTER);
    pTableCobertura.addCell(cellTable112);
    pTableCobertura.addCell(cellTable121);
    cellTable122.setHorizontalAlignment(Element.ALIGN_CENTER);
    pTableCobertura.addCell(cellTable122);
    pTableCobertura.addCell(cellTable131);
    cellTable132.setHorizontalAlignment(Element.ALIGN_CENTER);
    pTableCobertura.addCell(cellTable132);
    pTableCobertura.addCell(cellTable141);
    cellTable142.setHorizontalAlignment(Element.ALIGN_CENTER);
    pTableCobertura.addCell(cellTable142);
    pTableCobertura.addCell(cellTable151);
    cellTable152.setHorizontalAlignment(Element.ALIGN_CENTER);
    pTableCobertura.addCell(cellTable152);
    pTableCobertura.addCell(cellTable161);
    cellTable162.setHorizontalAlignment(Element.ALIGN_CENTER);
    pTableCobertura.addCell(cellTable162);

    PdfPTable pTableCausuala = new PdfPTable(1);
    pTableCausuala.setWidthPercentage(92);
    PdfPCell paragraphParaFamilha = new PdfPCell(new Phrase(
            "1. Para Famlia e/ou Grupo, fornecer uma lista anexada com outros detalhes necessrios.",
            fontTableSimpleCausulas));
    paragraphParaFamilha.setHorizontalAlignment(Element.ALIGN_JUSTIFIED);
    paragraphParaFamilha.setPaddingBottom(7f);

    PdfPCell paragraphOPresente = new PdfPCell(new Phrase(
            "2. O presente Contrato baseia-se na proposta do Segurador e  regido pelos termos referidos nas "
                    + "Condies Gerais e Especiais e de Excluses anexadas ao presente documento.",
            fontTableSimpleCausulas));
    paragraphOPresente.setHorizontalAlignment(Element.ALIGN_JUSTIFIED);
    paragraphOPresente.setPaddingBottom(7f);

    PdfPCell paragraphOPremio = new PdfPCell(new Phrase(
            "3. O Prmio pago no  reembolsvel excepto a rejeio da aplice pela Embaixada.",
            fontTableSimpleCausulas));
    paragraphOPremio.setHorizontalAlignment(Element.ALIGN_JUSTIFIED);
    paragraphOPremio.setPaddingBottom(7f);

    PdfPCell paragraphOSeguro = new PdfPCell(new Phrase(
            "4. O Segurado declara que as informaes prestadas so verdadeiras e completas e declara ter "
                    + "lido as condies Gerais e Especiais e as Excluses e concordado com as disposies nelas contidas.",
            fontTableSimpleCausulas));
    paragraphOSeguro.setHorizontalAlignment(Element.ALIGN_JUSTIFIED);
    paragraphOSeguro.setPaddingBottom(7f);

    PdfPCell paragraphSolitacao = new PdfPCell(new Phrase(
            "5. Solicitao de reembolso deve ser feita por carta dirigida a Directora Geral da NICON Seguros STP, "
                    + "3 dias antes da data de inicio do seguro, e deve ser acompanhada da aplice original e da fotocpia da carta de rejeio da Embaixada.",
            fontTableSimpleCausulas));
    paragraphSolitacao.setHorizontalAlignment(Element.ALIGN_JUSTIFIED);
    //            paragraphSolitacao.setPaddingBottom(7f);

    paragraphParaFamilha.setBorder(0);
    pTableCausuala.addCell(paragraphParaFamilha);
    paragraphOPresente.setBorder(0);
    pTableCausuala.addCell(paragraphOPresente);
    paragraphOPremio.setBorder(0);
    pTableCausuala.addCell(paragraphOPremio);
    paragraphOSeguro.setBorder(0);
    pTableCausuala.addCell(paragraphOSeguro);
    paragraphSolitacao.setBorder(0);
    pTableCausuala.addCell(paragraphSolitacao);

    PdfPTable pTableNota = new PdfPTable(1);
    pTableNota.setWidthPercentage(92);
    PdfPCell paragraphNota = new PdfPCell(new Phrase(
            " condio indispensvel para usufruir das garantias deste contrato que o Subscritor ou Pessoas Seguradas contactem de imediato:",
            fontTableItalico));
    paragraphNota.setBorder(0);
    pTableNota.addCell(paragraphNota);

    PdfPTable pTableRotape = new PdfPTable(1);
    pTableRotape.setWidthPercentage(92);
    Paragraph p = new Paragraph();
    Image imageRotape = Image.getInstance(ConfigDoc.Fontes.getDiretorio() + "/europ-assistance2.jpg");
    imageRotape.scaleToFit(90, 40);
    p.add(new Chunk(imageRotape, 1, 1, true));

    Phrase phraseRodape = new Phrase(
            ", COMPAINHA PORTUGUESA DE SEGUROS DE ASSISTNCIA, Tel. 351 21 384 80 97 Fax: 351 21 386 03 08 www.europ-assitance.pt",
            fontTableNormal);
    p.add(phraseRodape);

    PdfPCell cellRodape = new PdfPCell(p);
    cellRodape.setPaddingTop(10f);
    cellRodape.setBorder(0);
    pTableRotape.addCell(cellRodape);

    PdfPTable pTableAsinatura = new PdfPTable(2);
    pTableAsinatura.setWidthPercentage(92);
    PdfPCell cellSeguradora = new PdfPCell(new Phrase("A Seguradora", fontTableSimpleCausulas));
    cellSeguradora.setBorder(0);
    cellSeguradora.setPaddingTop(25);
    cellSeguradora.setHorizontalAlignment(Element.ALIGN_CENTER);

    PdfPCell cellSegurado = new PdfPCell(new Phrase("O Segurado", fontTableSimpleCausulas));
    cellSegurado.setPaddingTop(25);
    cellSegurado.setBorder(0);
    cellSegurado.setHorizontalAlignment(Element.ALIGN_CENTER);

    PdfPCell cellSeguradoValor = new PdfPCell(
            new Phrase("____________________________", fontTableSimpleCausulas));
    cellSeguradoValor.setBorder(0);
    cellSeguradoValor.setHorizontalAlignment(Element.ALIGN_CENTER);

    pTableAsinatura.addCell(cellSeguradora);
    pTableAsinatura.addCell(cellSegurado);
    pTableAsinatura.addCell(cellSeguradoValor);
    pTableAsinatura.addCell(cellSeguradoValor);

    //        documento.open();
    documento.add(pTableEmpresaPricipal);
    documento.add(pTableTitulo);
    documento.add(pTableNull);
    documento.add(pTablePrincipalSegurado);
    documento.add(pTableOtros);
    //            documento.add(pTableNull);
    documento.add(pTableCobertura);
    documento.add(pTableNull);
    documento.add(pTableCausuala);
    documento.add(pTableNull);
    documento.add(pTableNota);
    documento.add(pTableRotape);
    documento.add(pTableNull);
    documento.add(pTableAsinatura);

    if ((i + 1) != vb.getInfoPessoaSegurada().size())
        documento.newPage();

    //PrintPdf printPdf = new PrintPdf("Cobertura Viagem.pdf", "Cobertura Viagem.pdf", 0, 595f,842f,"Enviar Para o OneNote 2013",1);
    //            PrintPdf printPdf = new PrintPdf("Cobertura Viagem.pdf", "Cobertura Viagem.pdf", 0, 595f,842f,"Hewlett-Packard HP LaserJet P2035",1);

    //            printPdf.print();
}

From source file:fenix.planner.pdf.PDFGenerator.java

License:Open Source License

private void createAndAddEventTable() throws DocumentException {
    PdfPTable table = new PdfPTable(new float[] { 1, 7, 1.2f });
    table.setWidthPercentage(100f);//from  w  w w.j a v a 2s .co  m
    table.getDefaultCell().setUseAscender(true);
    table.getDefaultCell().setUseDescender(true);
    table.setSpacingBefore(20);
    table.setSpacingAfter(20);

    // Header row
    table.getDefaultCell().setBorderWidthLeft(0);
    table.getDefaultCell().setBorderWidthTop(0);
    table.getDefaultCell().setBorderWidthRight(0);
    table.getDefaultCell().setPadding(5);
    table.getDefaultCell().setHorizontalAlignment(Element.ALIGN_LEFT);
    table.addCell(new Phrase("Datum", headerFont));
    table.addCell(new Phrase("mne", headerFont));
    table.addCell(new Phrase("Ansvarig", headerFont));
    table.setHeaderRows(1);
    table.getDefaultCell().setBackgroundColor(null);

    // Events
    for (Event event : program.getSortedCopyOfEvents()) {
        if (event.getDate().getMonthOfYear() % 2 == 0) {
            table.getDefaultCell().setBackgroundColor(new BaseColor(0xdd, 0xdd, 0xdd));
        } else {
            table.getDefaultCell().setBackgroundColor(null);
        }

        if (!event.getType().getBackgroundColor().equals(Color.WHITE)) {
            table.getDefaultCell()
                    .setBackgroundColor(awtColorToBaseColor(event.getType().getBackgroundColor()));
        }

        final BaseColor textColor = awtColorToBaseColor(event.getType().getForegroundColor());

        PdfPCell dateCell = new PdfPCell(table.getDefaultCell());
        dateCell.addElement(
                new Phrase(event.getDate().toString("dd.MM", locale), changeColor(subjectFont, textColor)));
        table.addCell(dateCell);

        PdfPCell subjectCell = new PdfPCell(table.getDefaultCell());
        subjectCell.addElement(new Phrase(event.getSubject(), changeColor(subjectFont, textColor)));
        if (event.getDescription().length() > 0) {
            subjectCell.addElement(new Phrase(event.getDescription(), changeColor(descriptionFont, textColor)));
        }
        if (event.getOrganizer() == null) {
            subjectCell.setColspan(2);
        }
        table.addCell(subjectCell);

        if (event.getOrganizer() != null) {
            PdfPCell organizerCell = new PdfPCell(table.getDefaultCell());
            organizerCell.addElement(
                    new Phrase(event.getOrganizer().getInitials(), changeColor(subjectFont, textColor)));
            table.addCell(organizerCell);
        }
    }

    document.add(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;/*w  w  w . ja  v a 2s  .co m*/
    if (orientationIsPortrait) {
        pdfDoc = new Document(PageSize.LETTER); // portrait
    } else {
        pdfDoc = new Document(PageSize.LETTER.rotate()); // landscape
    }
    PdfWriter.getInstance(pdfDoc, out);

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

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

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

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

        titleParagraph.add(revisionChunk);
    }

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

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

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

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

        scoreSheet.addCell(head);

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

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

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

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

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

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

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

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

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

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

        scoreSheet.addCell(teamInfoCell);

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

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

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

            scoreSheet.addCell(copyrightC);
        }

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

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

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

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

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

    pdfDoc.close();
}

From source file:Forms.AddCustomers.java

private void cardBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cardBtnActionPerformed
    String name = fNameTxt.getText() + " " + lNameTxt.getText();
    String cid = cusIdTxt.getText();
    Document document = new Document();
    Rectangle test = new Rectangle(350, 200);
    BaseColor color = new BaseColor(63, 72, 204);
    test.setBackgroundColor(color);/*from  w  w  w. ja  va 2  s .  c o m*/
    document.setPageSize(test);

    File theDir = new File("E:\\CustomerCard");

    // if the directory does not exist, create it
    if (!theDir.exists()) {
        //System.out.println("creating directory: " + directoryName);
        boolean result = false;

        try {
            theDir.mkdir();
            result = true;
        } catch (SecurityException se) {
            System.out.println(se.getMessage());
        }
    }

    try {
        PdfWriter.getInstance(document, new FileOutputStream("E:\\CustomerCard\\card(" + cid + ").pdf"));

        document.open();
        //Image image;

        //image = Image.getInstance("api.png");

        //document.add(image);

        document.add(new Paragraph("           Customer Discount Card",
                FontFactory.getFont(FontFactory.TIMES_BOLD, 16, Font.BOLD, BaseColor.GRAY)));
        document.add(new Paragraph("     "));
        document.add(new Paragraph("              Name : " + name,
                FontFactory.getFont(FontFactory.TIMES_ROMAN, 12, Font.NORMAL, BaseColor.BLACK)));
        document.add(new Paragraph("     "));
        document.add(new Paragraph("              Card ID: " + cid,
                FontFactory.getFont(FontFactory.TIMES_ROMAN, 12, Font.NORMAL, BaseColor.BLACK)));
        document.close();

        try {
            //Runtime.getRuntime().exec("rundll32 url.dll,FileProtocolHandler "+"E:\\CustomerCard\\card("+cid+").pdf");
            Runtime.getRuntime().exec("rundll32 url.dll,FileProtocolHandler "
                    + "C:\\Users\\Vidu\\Desktop\\CustomerIDCard\\card(" + cid + ").pdf");
        } catch (Exception ex) {
            Logger.getLogger(SellPage.class.getName()).log(Level.SEVERE, null, ex);
        }
        //document.add(new Paragraph(date,FontFactory.getFont(FontFactory.TIMES_ROMAN, 12, Font.NORMAL,BaseColor.BLACK)));
        fNameTxt.setText("");
        lNameTxt.setText("");
        cusIdTxt.setText("");
    } catch (Exception ex) {
        ex.printStackTrace();
    }
}

From source file:frames.main.java

private void jButton5ActionPerformed(java.awt.event.ActionEvent evt) {
    try {//from  w  w w  . j a  v  a  2 s .c o m

        BaseFont unicode = BaseFont.createFont("c:/windows/fonts/ALGER.ttf", BaseFont.IDENTITY_H,
                BaseFont.EMBEDDED);
        Font font1003 = new Font(unicode, 18, Font.ITALIC, new BaseColor(139, 0, 0));
        Font font1008 = new Font(unicode, 20, Font.BOLD, new BaseColor(101, 67, 33));
        Font font1004 = new Font(unicode, 18, Font.BOLD, new BaseColor(139, 0, 0));
        Font font1009 = new Font(unicode, 10, Font.NORMAL, new BaseColor(139, 10, 20));
        Font font1005 = new Font(unicode, 18, Font.UNDERLINE, new BaseColor(101, 67, 33));
        Font font1006 = new Font(unicode, 9, Font.BOLDITALIC, new BaseColor(101, 67, 33));
        // Rectangle rect=new RectangleReadOnly(590, 470, 0);
        /////////////////////////////////////
        Font font100 = new Font(unicode, 10, Font.ITALIC, BaseColor.BLUE);
        Document document = new Document();
        PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("REGISTRATION-FORM.pdf"));
        document.open();
        PdfContentByte cb = writer.getDirectContent();
        Font font111 = new Font(Font.FontFamily.COURIER, 16, Font.BOLD, BaseColor.ORANGE);
        Font font110 = new Font(Font.FontFamily.COURIER, 14, Font.NORMAL, BaseColor.GREEN);
        Font font11 = new Font(Font.FontFamily.COURIER, 12, Font.NORMAL, BaseColor.GREEN);
        com.itextpdf.text.Image image2 = com.itextpdf.text.Image
                .getInstance("C:\\smart kid\\src\\frames\\logo.jpg");
        image2.scaleAbsolute(115f, 115f);
        image2.setAbsolutePosition(3, 716);
        Paragraph p = new Paragraph();
        document.add(image2);
        document.add(new Chunk("                                                  ", font1004));
        document.add(new Chunk("ADMISSION FORM", font1005));
        document.add(new Paragraph("                                   SMART KIDS CONVENT SCHOOL", font1004));
        document.add(new Paragraph(
                "                                              Managed By:The Smart Kids Educational Society,"));
        document.add(new Paragraph(
                "                                                                           Reg.No:-00169"));
        document.add(new Paragraph(
                "                                                        413A/23,HEERA NAGAR,GURGAON"));
        document.add(new Paragraph(
                "                                                           MOB:-9911752900  ,  9891929835"));
        document.add(new Paragraph(
                "                                                                                                                   Reg.No"
                        + "   " + Rtf8.getText()));
        document.add(new Paragraph(
                "Admission No." + "                                                                  "
                        + new Date().toString()));
        document.add(new Paragraph("  "));
        Paragraph p1 = new Paragraph();
        p1.add(new Chunk("Certified that                 " + "Son/Daughter of:",
                FontFactory.getFont(FontFactory.COURIER, 11, Font.ITALIC, BaseColor.BLACK)));
        p1.add(new Chunk(Rtf1.getText(), font11));
        document.add(p1);

        document.add(new Paragraph("  "));
        Paragraph p2 = new Paragraph();
        p2.add(new Chunk("Father's Name  :" + Rtf2.getText() + "Mob:-",
                FontFactory.getFont(FontFactory.COURIER, 11, Font.ITALIC, BaseColor.BLACK)));
        p2.add(new Chunk(Rtf2.getText(), font11));
        document.add(p2);

        document.add(new Paragraph("  "));
        Paragraph p3 = new Paragraph();
        p3.add(new Chunk("Mother's Name  :" + Rtf2.getText() + "Mob:-",
                FontFactory.getFont(FontFactory.COURIER, 11, Font.ITALIC, BaseColor.BLACK)));
        p3.add(new Chunk(Rtf2.getText(), font11));
        document.add(p3);
        document.add(new Paragraph("  "));

        Paragraph p4 = new Paragraph();
        p4.add(new Chunk("His/Her Date of birth :" + Rtf2.getText() + "Age",
                FontFactory.getFont(FontFactory.COURIER, 11, Font.ITALIC, BaseColor.BLACK)));
        p4.add(new Chunk(Rtf2.getText(), font11));
        document.add(p4);
        document.add(new Paragraph("  "));

        Paragraph p5 = new Paragraph();
        p5.add(new Chunk("Corrosponding Address                  :",
                FontFactory.getFont(FontFactory.COURIER, 11, Font.ITALIC, BaseColor.BLACK)));
        p5.add(new Chunk("", font11));
        document.add(p5);
        document.add(new Paragraph("  "));

        Paragraph p6 = new Paragraph();
        p6.add(new Chunk("Parmanent Address                  :",
                FontFactory.getFont(FontFactory.COURIER, 11, Font.ITALIC, BaseColor.BLACK)));
        p6.add(new Chunk("", font11));
        document.add(p6);
        document.add(new Paragraph("  "));

        Paragraph p7 = new Paragraph();
        p7.add(new Chunk("Previous School & result                   :",
                FontFactory.getFont(FontFactory.COURIER, 11, Font.ITALIC, BaseColor.BLACK)));
        p7.add(new Chunk("He/She Wants Admmisiion in",
                FontFactory.getFont(FontFactory.COURIER, 11, Font.ITALIC, BaseColor.BLACK)));
        document.add(p7);
        document.add(new Paragraph("  "));
        Paragraph p8 = new Paragraph();
        p8.add(new Chunk("Smart Kids Convent School in                :",
                FontFactory.getFont(FontFactory.COURIER, 11, Font.ITALIC, BaseColor.BLACK)));
        p8.add(new Chunk("Class.He/She will always be regular and punctual to school.",
                FontFactory.getFont(FontFactory.COURIER, 11, Font.ITALIC, BaseColor.BLACK)));
        document.add(p8);
        document.add(new Paragraph("  "));
        Paragraph p9 = new Paragraph();
        p9.add(new Chunk("Please admit him/her              :" + "Signature",
                FontFactory.getFont(FontFactory.COURIER, 11, Font.ITALIC, BaseColor.BLACK)));
        p9.add(new Chunk(
                "                                                                              in" + "Class"
                        + "Parents/Guardian",
                FontFactory.getFont(FontFactory.COURIER, 11, Font.ITALIC, BaseColor.BLACK)));
        document.add(p9);
        document.add(new Paragraph("  "));
        document.add(new Paragraph("  "));
        document.add(new Paragraph("  "));
        document.add(new Paragraph("  "));
        document.add(new Paragraph(
                " Principal(Signature)                                                 Permission of Director",
                FontFactory.getFont(FontFactory.COURIER, 11, Font.ITALIC, BaseColor.BLACK)));
        document.add(new Paragraph("  "));
        document.add(new Paragraph("  "));
        document.add(new Paragraph("  "));
        document.add(new Paragraph("  "));
        document.add(new Paragraph("  "));
        document.add(new Paragraph("NOTE:- FEES WILL NOT BE REFUNDED AFTER ADMISSION."));
        cb.saveState();
        cb.setColorStroke(BaseColor.BLACK);
        cb.rectangle(2, 2, 588, 826);
        cb.stroke();
        cb.restoreState();
        JOptionPane.showMessageDialog(this, "receipt printed..");

        document.close();
        ;
    } catch (Exception ee) {
        JOptionPane.showMessageDialog(this, ee);
    }
}

From source file:frames.main.java

private void jButton7ActionPerformed(java.awt.event.ActionEvent evt) {
    if (PRINTMODE.getSelectedIndex() == 0) {
        try {/*www  . j  a va  2 s  .c  o  m*/

            //mrpno=Integer.parseInt(DTFrpno.getText());
            BaseFont unicode = BaseFont.createFont("c:/windows/fonts/ALGER.ttf", BaseFont.IDENTITY_H,
                    BaseFont.EMBEDDED);
            Font font1003 = new Font(unicode, 18, Font.ITALIC, new BaseColor(139, 0, 0));
            Font font1008 = new Font(unicode, 20, Font.BOLD, new BaseColor(101, 67, 33));
            Font font1004 = new Font(unicode, 14, Font.BOLD, new BaseColor(139, 0, 0));
            Font font1005 = new Font(unicode, 12, Font.UNDERLINE, new BaseColor(255, 0, 0));
            Font font1006 = new Font(unicode, 9, Font.BOLDITALIC, new BaseColor(101, 67, 33));
            Rectangle rect = new RectangleReadOnly(590, 470, 0);
            /////////////////////////////////////
            Font font100 = new Font(unicode, 10, Font.ITALIC, BaseColor.BLUE);
            Document document = new Document();
            PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("REGISTRATION.pdf"));
            document.setPageSize(rect);
            document.open();
            // PdfContentByte cb = writer.getDirectContent();
            Font font111 = new Font(Font.FontFamily.COURIER, 16, Font.BOLD, BaseColor.ORANGE);
            com.itextpdf.text.Image image2 = com.itextpdf.text.Image
                    .getInstance("C:\\smart kid\\src\\frames\\logo.jpg");
            image2.scaleAbsolute(115f, 115f);
            image2.setAbsolutePosition(2, 350);
            document.add(image2);
            document.add(new Chunk(
                    "                                                                                         ",
                    font100));
            document.add(new Chunk("RECEIPT", font1005));
            //document.add(p);
            // document.add(new Paragraph( ));
            document.add(new Paragraph(
                    "                                  SMART KID CONVENT SCHOOL                 ", font1003));
            // document.add(new Chunk("                          SMART KID CONVENT SCHOOL                 ",font1003));
            // document.add(new Chunk("                                                              413A/23,HEERA NAGAR GURGAON.                        ",font100));
            document.add(new Paragraph(
                    "                                                                  413A/23,HEERA NAGAR GURGAON.                        ",
                    font100));
            // document.add(new Chunk("                                                                                            ph:9911752900,9891929835                 ",font100));
            document.add(new Paragraph(
                    "                                                                     ph:9911752900,9891929835                 ",
                    font100));
            // document.add(new Chunk("                                                          E-mail:info.smartkids@gmail.com",FontFactory.getFont(FontFactory.COURIER,9,Font.BOLDITALIC,BaseColor.DARK_GRAY)));
            document.add(new Paragraph("                                  E-mail:info.smartkids@gmail.com",
                    FontFactory.getFont(FontFactory.COURIER, 9, Font.BOLDITALIC, BaseColor.DARK_GRAY)));

            document.add(new Paragraph("  "));
            PdfPTable table1 = new PdfPTable(4);
            PdfPCell c = new PdfPCell(new Paragraph("STUDENT PARTICULARS"));
            c.setColspan(4);
            c.setBackgroundColor(BaseColor.GREEN);
            c.setHorizontalAlignment(Element.ALIGN_CENTER);
            table1.addCell(c);
            table1.addCell("Student Name:");
            table1.addCell(new PdfPCell(new Paragraph(Dtf2.getText(),
                    FontFactory.getFont(FontFactory.COURIER, 12, Font.BOLDITALIC, BaseColor.GREEN))));

            table1.addCell("Class:");
            table1.addCell(new Paragraph((String) Dtf5.getText(),
                    FontFactory.getFont(FontFactory.COURIER, 12, Font.BOLDITALIC, BaseColor.GREEN)));
            table1.addCell("Section:");
            table1.addCell(new Paragraph((String) Dtf22.getText() + "     " + "Phone.:" + Dtf20.getText(),
                    FontFactory.getFont(FontFactory.COURIER, 12, Font.BOLDITALIC, BaseColor.GREEN)));
            table1.addCell("Registration No:");
            table1.addCell(new PdfPCell(new Paragraph(Dtf1.getText(),
                    FontFactory.getFont(FontFactory.COURIER, 12, Font.BOLDITALIC, BaseColor.GREEN))));
            table1.addCell("Session:");
            table1.addCell(new Paragraph("NA",
                    FontFactory.getFont(FontFactory.COURIER, 12, Font.BOLDITALIC, BaseColor.GREEN)));
            table1.addCell("Month:");
            table1.addCell(new Paragraph((String) Djc1.getSelectedItem(),
                    FontFactory.getFont(FontFactory.COURIER, 12, Font.BOLDITALIC, BaseColor.GREEN)));
            float[] ColumnWidths1 = new float[] { 12f, 19f, 10f, 24f };
            table1.setWidths(ColumnWidths1);
            table1.setWidthPercentage(113);
            document.add(table1);

            // document.add(new Paragraph("  "));

            PdfPTable table = new PdfPTable(5);
            PdfPCell cc = new PdfPCell(new Paragraph("FEE INFORMATION"));
            cc.setBackgroundColor(BaseColor.GREEN);
            cc.setHorizontalAlignment(Element.ALIGN_CENTER);
            cc.setColspan(5);
            table.addCell(cc);
            PdfPCell cell99 = new PdfPCell(new Paragraph("Sl No",
                    FontFactory.getFont(FontFactory.COURIER, 10, Font.NORMAL, BaseColor.BLACK)));
            PdfPCell cell90 = new PdfPCell(new Paragraph("Particulars",
                    FontFactory.getFont(FontFactory.COURIER, 10, Font.NORMAL, BaseColor.BLACK)));
            PdfPCell cell91 = new PdfPCell(new Paragraph("Cash",
                    FontFactory.getFont(FontFactory.COURIER, 10, Font.NORMAL, BaseColor.BLACK)));
            PdfPCell cell92 = new PdfPCell(new Paragraph("Cheque",
                    FontFactory.getFont(FontFactory.COURIER, 10, Font.NORMAL, BaseColor.BLACK)));
            PdfPCell cell93 = new PdfPCell(new Paragraph("Total",
                    FontFactory.getFont(FontFactory.COURIER, 10, Font.NORMAL, BaseColor.BLACK)));
            table.addCell(cell99);
            table.addCell(cell90);
            table.addCell(cell91);
            table.addCell(cell92);
            table.addCell(cell93);
            table.addCell("1");
            PdfPCell cell1 = new PdfPCell(new Paragraph("Registration Fee",
                    FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK)));
            table.addCell(cell1);
            table.addCell(Dtf11.getText());
            table.addCell(" ");
            table.addCell(" ");
            table.addCell("2");
            PdfPCell cell2 = new PdfPCell(new Paragraph("Admission/Re admission fee",
                    FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK)));
            table.addCell(cell2);
            table.addCell(Dtf12.getText());
            table.addCell("  ");
            table.addCell(" ");
            table.addCell("3");
            PdfPCell cell3 = new PdfPCell(new Paragraph("Building fee",
                    FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK)));
            table.addCell(cell3);
            table.addCell(Dtf13.getText());
            table.addCell(" ");
            table.addCell(" ");
            table.addCell("4");
            PdfPCell cell4 = new PdfPCell(new Paragraph("Annual Charge",
                    FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK)));
            table.addCell(cell4);
            table.addCell(Dtf14.getText());
            table.addCell(" ");
            table.addCell(" ");
            table.addCell("5");
            PdfPCell cell14 = new PdfPCell(new Paragraph("Security (Refundable)",
                    FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK)));
            table.addCell(cell14);
            table.addCell(Dtf17.getText());
            table.addCell(" ");
            table.addCell(" ");
            table.addCell("6");
            PdfPCell cell5 = new PdfPCell(new Paragraph("Tution",
                    FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK)));
            table.addCell(cell5);
            table.addCell(Dtf6.getText());
            table.addCell(" ");
            table.addCell(" ");
            table.addCell("7");
            PdfPCell cell6 = new PdfPCell(new Paragraph("Total pupils fund",
                    FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK)));
            table.addCell(cell6);
            table.addCell(Dtf16.getText());
            table.addCell(" ");
            table.addCell(" ");
            table.addCell("8");
            PdfPCell cell7 = new PdfPCell(new Paragraph("Computer Fee",
                    FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK)));
            table.addCell(cell7);
            table.addCell(Dtf7.getText());
            table.addCell(" ");
            table.addCell(" ");
            table.addCell("9");
            PdfPCell cell8 = new PdfPCell(new Paragraph("Sports Fee",
                    FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK)));
            table.addCell(cell8);
            table.addCell(Dtf15.getText());
            table.addCell(" ");
            table.addCell(" ");
            table.addCell("10");
            PdfPCell cell9 = new PdfPCell(new Paragraph("House exam Fee",
                    FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK)));
            table.addCell(cell9);
            table.addCell(Dtf8.getText());
            table.addCell(" ");
            table.addCell(" ");
            table.addCell("11");
            PdfPCell cell10 = new PdfPCell(new Paragraph("Conveyance Charge",
                    FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK)));
            table.addCell(cell10);
            table.addCell(Dtf18.getText());
            table.addCell(" ");
            //table.addCell(" ");
            table.addCell("");
            PdfPCell cell12 = new PdfPCell(new Paragraph("12",
                    FontFactory.getFont(FontFactory.COURIER, 9, Font.BOLD, BaseColor.BLACK)));
            PdfPCell cell13 = new PdfPCell(new Paragraph("Grand Total",
                    FontFactory.getFont(FontFactory.COURIER, 9, Font.BOLD, BaseColor.BLACK)));

            table.addCell(cell12);
            table.addCell(cell13);

            table.addCell(
                    String.valueOf((Integer.parseInt(Dtf11.getText())) + (Integer.parseInt(Dtf12.getText()))
                            + (Integer.parseInt(Dtf13.getText())) + (Integer.parseInt(Dtf14.getText()))
                            + (Integer.parseInt(Dtf17.getText())) + (Integer.parseInt(Dtf6.getText()))
                            + (Integer.parseInt(Dtf16.getText())) + (Integer.parseInt(Dtf7.getText()))
                            + (Integer.parseInt(Dtf15.getText())) + (Integer.parseInt(Dtf8.getText()))
                            + (Integer.parseInt(Dtf18.getText())) + (Integer.parseInt(Dtf9.getText()))));

            float[] ColumnWidths = new float[] { 8f, 25f, 11f, 10f, 10f };
            table.setWidths(ColumnWidths);
            table.setWidthPercentage(113);
            table.completeRow();
            document.add(table);
            document.add(new Chunk(
                    "# Fee once paid is not refundable .                      For Smart kid convent school     Signature    "));
            //document.add(new Chunk("# The monthly fee has to be deposited before 10th of every month                            Signature "));
            JOptionPane.showMessageDialog(this, "receipt printed..");

            Dtf21.setText(String.valueOf(Integer.parseInt(Dtf21.getText()) + 1));
            document.close();
            ;
        } catch (Exception ee) {
            JOptionPane.showMessageDialog(this, ee);
        }
    } else if (PRINTMODE.getSelectedIndex() == 1) {
        try {

            //mrpno=Integer.parseInt(DTFrpno.getText());
            BaseFont unicode = BaseFont.createFont("c:/windows/fonts/ALGER.ttf", BaseFont.IDENTITY_H,
                    BaseFont.EMBEDDED);
            Font font1003 = new Font(unicode, 18, Font.ITALIC, new BaseColor(139, 0, 0));
            Font font1008 = new Font(unicode, 20, Font.BOLD, new BaseColor(101, 67, 33));
            Font font1004 = new Font(unicode, 14, Font.BOLD, new BaseColor(139, 0, 0));
            Font font1005 = new Font(unicode, 12, Font.UNDERLINE, new BaseColor(255, 0, 0));
            Font font1006 = new Font(unicode, 9, Font.BOLDITALIC, new BaseColor(101, 67, 33));
            Rectangle rect = new RectangleReadOnly(590, 460, 0);
            /////////////////////////////////////
            Font font100 = new Font(unicode, 10, Font.ITALIC, BaseColor.BLUE);
            Document document = new Document();
            PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("Feeslipp(MONTHLY).pdf"));
            document.setPageSize(rect);
            document.open();
            // PdfContentByte cb = writer.getDirectContent();
            Font font111 = new Font(Font.FontFamily.COURIER, 16, Font.BOLD, BaseColor.ORANGE);
            com.itextpdf.text.Image image2 = com.itextpdf.text.Image
                    .getInstance("C:\\smart kid\\src\\frames\\logo.jpg");
            image2.scaleAbsolute(115f, 115f);
            image2.setAbsolutePosition(2, 350);
            document.add(image2);
            Paragraph p = new Paragraph();
            p.add(new Chunk("                                                                      "));
            //p.add(new Chunk("RECEIPT",font1005));
            //document.add(p);
            document.add(new Chunk("                  RECEIPT", font1003));
            document.add(new Paragraph("                             SMART KID CONVENT SCHOOL                 ",
                    font1003));
            // document.add(new Chunk("                          SMART KID CONVENT SCHOOL                 ",font1003));
            // document.add(new Chunk("                                                              413A/23,HEERA NAGAR GURGAON.                        ",font100));
            document.add(new Paragraph(
                    "                                                              413A/23,HEERA NAGAR GURGAON.                        ",
                    font100));
            // document.add(new Chunk("                                                                                            ph:9911752900,9891929835                 ",font100));
            document.add(new Paragraph(
                    "                                                                  ph:9911752900,9891929835                 ",
                    font100));
            // document.add(new Chunk("                                                          E-mail:info.smartkids@gmail.com",FontFactory.getFont(FontFactory.COURIER,9,Font.BOLDITALIC,BaseColor.DARK_GRAY)));
            document.add(new Paragraph("                                 E-mail:info.smartkids@gmail.com",
                    FontFactory.getFont(FontFactory.COURIER, 9, Font.BOLDITALIC, BaseColor.DARK_GRAY)));
            document.add(new Paragraph("  "));
            PdfPTable table1 = new PdfPTable(4);
            PdfPCell c = new PdfPCell(new Paragraph("STUDENT PARTICULARS"));
            c.setColspan(4);
            c.setBackgroundColor(BaseColor.GREEN);
            c.setHorizontalAlignment(Element.ALIGN_CENTER);
            table1.addCell(c);
            table1.addCell("Student Name:");
            table1.addCell(new PdfPCell(new Paragraph(Dtf2.getText(),
                    FontFactory.getFont(FontFactory.COURIER, 12, Font.BOLDITALIC, BaseColor.GREEN))));
            table1.addCell("Class:");
            table1.addCell(new Paragraph(Dtf5.getText(),
                    FontFactory.getFont(FontFactory.COURIER, 12, Font.BOLDITALIC, BaseColor.GREEN)));
            table1.addCell("Section:");
            table1.addCell(new Paragraph(Dtf21.getText() + "     " + "Phone.:" + Dtf20.getText(),
                    FontFactory.getFont(FontFactory.COURIER, 12, Font.BOLDITALIC, BaseColor.GREEN)));
            table1.addCell("Registration No:");
            table1.addCell(new PdfPCell(new Paragraph(Dtf1.getText(),
                    FontFactory.getFont(FontFactory.COURIER, 12, Font.BOLDITALIC, BaseColor.GREEN))));
            table1.addCell("Month:");
            table1.addCell(new Paragraph((String) Djc1.getSelectedItem(),
                    FontFactory.getFont(FontFactory.COURIER, 12, Font.BOLDITALIC, BaseColor.GREEN)));
            float[] ColumnWidths1 = new float[] { 12f, 19f, 10f, 24f };
            table1.setWidths(ColumnWidths1);
            table1.setWidthPercentage(113);
            document.add(table1);

            document.add(new Paragraph("  "));
            PdfPTable table = new PdfPTable(5);
            PdfPCell cc = new PdfPCell(new Paragraph("FEE INFORMATION"));
            cc.setBackgroundColor(BaseColor.GREEN);
            cc.setHorizontalAlignment(Element.ALIGN_CENTER);
            cc.setColspan(5);
            table.addCell(cc);
            PdfPCell cell99 = new PdfPCell(new Paragraph("Sl No",
                    FontFactory.getFont(FontFactory.COURIER, 10, Font.NORMAL, BaseColor.BLACK)));
            PdfPCell cell90 = new PdfPCell(new Paragraph("Particulars",
                    FontFactory.getFont(FontFactory.COURIER, 10, Font.NORMAL, BaseColor.BLACK)));
            PdfPCell cell91 = new PdfPCell(new Paragraph("Cash",
                    FontFactory.getFont(FontFactory.COURIER, 10, Font.NORMAL, BaseColor.BLACK)));
            PdfPCell cell92 = new PdfPCell(new Paragraph("Cheque",
                    FontFactory.getFont(FontFactory.COURIER, 10, Font.NORMAL, BaseColor.BLACK)));
            PdfPCell cell93 = new PdfPCell(new Paragraph("Total",
                    FontFactory.getFont(FontFactory.COURIER, 10, Font.NORMAL, BaseColor.BLACK)));
            table.addCell(cell99);
            table.addCell(cell90);
            table.addCell(cell91);
            table.addCell(cell92);
            table.addCell(cell93);
            table.addCell("1");
            PdfPCell cell1 = new PdfPCell(new Paragraph("TUITION FEE",
                    FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK)));
            table.addCell(cell1);
            table.addCell(Dtf6.getText());
            table.addCell(" ");
            table.addCell(" ");
            table.addCell("2");
            PdfPCell cell2 = new PdfPCell(new Paragraph("COMPUTER FEE",
                    FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK)));
            table.addCell(cell2);
            table.addCell(Dtf7.getText());
            table.addCell("  ");
            table.addCell(" ");
            table.addCell("3");
            PdfPCell cell5 = new PdfPCell(new Paragraph("HOUSE EXAM FEE",
                    FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK)));
            table.addCell(cell5);
            table.addCell(Dtf8.getText());
            table.addCell(" ");
            table.addCell(" ");
            table.addCell("4");
            PdfPCell cell6 = new PdfPCell(new Paragraph("FINES",
                    FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK)));
            table.addCell(cell6);
            table.addCell(Dtf9.getText());
            table.addCell(" ");
            table.addCell(" ");
            table.addCell("5");
            PdfPCell cell7 = new PdfPCell(new Paragraph("OTHERS",
                    FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK)));
            table.addCell(cell7);
            table.addCell(Dtf10.getText());
            table.addCell(" ");

            table.addCell("");

            PdfPCell cell9 = new PdfPCell(new Paragraph("6",
                    FontFactory.getFont(FontFactory.COURIER, 9, Font.BOLD, BaseColor.BLACK)));
            PdfPCell cell8 = new PdfPCell(new Paragraph("Grand Total",
                    FontFactory.getFont(FontFactory.COURIER, 9, Font.BOLD, BaseColor.BLACK)));

            table.addCell(cell7);
            table.addCell(cell8);
            table.addCell(String.valueOf((Integer.parseInt(Dtf6.getText())) + (Integer.parseInt(Dtf7.getText()))
                    + (Integer.parseInt(Dtf8.getText())) + (Integer.parseInt(Dtf9.getText()))
                    + (Integer.parseInt(Dtf10.getText()))));

            float[] ColumnWidths = new float[] { 8f, 25f, 11f, 10f, 10f };
            table.setWidths(ColumnWidths);
            table.setWidthPercentage(113);
            table.completeRow();
            document.add(table);
            document.add(new Chunk(
                    "# Fee once paid is not refundable .                                                   For smart kid convent School     "));
            document.add(new Chunk(
                    "# The monthly fee has to be deposited before 10th of every month                            Signature "));
            JOptionPane.showMessageDialog(this, "receipt printed..");

            Dtf21.setText(String.valueOf(Integer.parseInt(Dtf21.getText()) + 1));
            document.close();
            ;
        } catch (Exception ee) {
            JOptionPane.showMessageDialog(this, ee);
        }
    } // TODO add your handling code here:
}

From source file:frames.main.java

private void jButton13ActionPerformed(java.awt.event.ActionEvent evt) {
    try {//  www  .  ja v a 2 s.c o m

        BaseFont unicode = BaseFont.createFont("c:/windows/fonts/ALGER.ttf", BaseFont.IDENTITY_H,
                BaseFont.EMBEDDED);

        // Font font11113 = new Font(unicode, 16, Font.BOLD,BaseColor(2,2,2));
        ///////////////////////////////////////////////dark brown//////////////////////////////////////////////////////
        Font font1003 = new Font(unicode, 16, Font.BOLD, new BaseColor(101, 67, 33));
        Font font1008 = new Font(unicode, 20, Font.BOLD, new BaseColor(101, 67, 33));
        /////////////////////////////////////
        ///////////////////////////////////////////////dark red//////////////////////////////////////////////////////
        Font font1004 = new Font(unicode, 14, Font.BOLD, new BaseColor(139, 0, 0));
        Font font1005 = new Font(unicode, 14, Font.BOLD, new BaseColor(255, 0, 0));

        /////////////////////////////////////
        Font font100 = new Font(unicode, 8, Font.ITALIC, BaseColor.BLUE);
        Document document = new Document();
        PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("SMART-TC.pdf"));
        document.open();
        PdfContentByte cb = writer.getDirectContent();
        Font font111 = new Font(Font.FontFamily.COURIER, 16, Font.BOLD, BaseColor.ORANGE);
        com.itextpdf.text.Image image2 = com.itextpdf.text.Image
                .getInstance("C:\\smart kid\\src\\frames\\logo.jpg");
        image2.scaleAbsolute(125f, 125f);
        image2.setAbsolutePosition(31, 700);
        document.add(image2);
        com.itextpdf.text.Image ing = com.itextpdf.text.Image.getInstance("C:\\smart kid\\src\\frames\\BC.jpg");
        ing.setAbsolutePosition(1, 200);
        document.add(ing);
        Font font1111 = new Font(unicode, 16, Font.BOLD, BaseColor.ORANGE);
        Font font11111 = new Font(unicode, 14, Font.BOLD, BaseColor.ORANGE);
        java.awt.Font awtPlainFont = new java.awt.Font("ALGERIAN", java.awt.Font.PLAIN, 10);
        document.add(new Paragraph("                                    SMART KIDS CONVENT SCHOOL", font1008));
        document.add(new Paragraph(
                "                                                   HEERA NAGAR (GURGAON)         ", font1003));
        document.add(
                new Chunk("                                       SCHOLOR'S REGISTER AND TRANSFER CERTIFICATE",
                        font1005));
        document.add(new Paragraph("                                    "));
        document.add(new Paragraph(
                "----------------------------------------------------------------------------------------------------------------------------------"));
        document.add(new Paragraph("                            ", font111));
        Font font41 = new Font(Font.FontFamily.HELVETICA, 9, Font.BOLD, new BaseColor(0, 0, 0));
        Font font23 = new Font(Font.FontFamily.HELVETICA, 12, Font.BOLD, new BaseColor(92, 64, 51));
        Font font1 = new Font(Font.FontFamily.HELVETICA, 10, Font.BOLD, new BaseColor(0, 0, 0));
        Font font11 = new Font(Font.FontFamily.HELVETICA, 12, Font.ITALIC, new BaseColor(148, 0, 211));
        Font font31 = new Font(Font.FontFamily.HELVETICA, 10, Font.BOLD, new BaseColor(990000));
        Font font2 = new Font(Font.FontFamily.COURIER, 18, Font.ITALIC | Font.UNDERLINE);
        Font font3 = new Font(Font.FontFamily.HELVETICA, 10, Font.BOLD, new BaseColor(255, 255, 200));

        document.add(new Paragraph(
                "Ref No:  " + TC16.getText() + "                         " + new java.util.Date().toString(),
                FontFactory.getFont(FontFactory.COURIER, 12, Font.NORMAL, BaseColor.BLACK)));
        document.add(new Paragraph("    "));
        String ho4 = TC1.getText();
        Paragraph p1 = new Paragraph();
        p1.add(new Chunk("NAME OF STUDENT        :",
                FontFactory.getFont(FontFactory.COURIER, 12, Font.NORMAL, BaseColor.BLACK)));
        p1.add(new Chunk(ho4, font11));
        document.add(p1);

        String ho5 = TC2.getText();
        Paragraph p2 = new Paragraph();
        p2.add(new Chunk("FATHER'S NAME          :",
                FontFactory.getFont(FontFactory.COURIER, 12, Font.NORMAL, BaseColor.BLACK)));
        p2.add(new Chunk(ho5, font11));
        document.add(p2);

        String ho6 = TC3.getText();
        Paragraph p93 = new Paragraph();
        p93.add(new Chunk("MOTHER'S NAME          :",
                FontFactory.getFont(FontFactory.COURIER, 12, Font.NORMAL, BaseColor.BLACK)));
        p93.add(new Chunk(ho6, font11));
        document.add(p93);

        Font font15 = new Font(Font.FontFamily.HELVETICA, 10, Font.BOLD, new BaseColor(0, 0, 0));
        String ho8 = TC1.getText();
        String tt = TC4.getText();
        Paragraph p4 = new Paragraph();

        p4.add(new Chunk("RELIGION               :",
                FontFactory.getFont(FontFactory.COURIER, 12, Font.NORMAL, BaseColor.BLACK)));
        p4.add(new Chunk(tt, font11));

        document.add(p4);
        // document.add(new Paragraph("                                            ",font1003));
        String kk = TC5.getText();
        Paragraph p5 = new Paragraph();
        p5.add(new Chunk("CASTE OF SCHOLOR       :",
                FontFactory.getFont(FontFactory.COURIER, 12, Font.NORMAL, BaseColor.BLACK)));
        p5.add(new Chunk(kk, font11));
        document.add(p5);

        String ho10 = TC10.getText();
        Paragraph p6 = new Paragraph();
        p6.add(new Chunk("ADDRESS                :",
                FontFactory.getFont(FontFactory.COURIER, 12, Font.NORMAL, BaseColor.BLACK)));
        p6.add(new Chunk(ho10, font11));
        document.add(p6);

        Paragraph p8 = new Paragraph();
        p8.add(new Chunk("DATE OF BIRTH          :",
                FontFactory.getFont(FontFactory.COURIER, 12, Font.NORMAL, BaseColor.BLACK)));
        p8.add(new Chunk(TC9.getText(), font11));
        document.add(p8);
        Paragraph p9 = new Paragraph();
        p9.add(new Chunk("SECTION                :",
                FontFactory.getFont(FontFactory.COURIER, 12, Font.NORMAL, BaseColor.BLACK)));
        p9.add(new Chunk(TC7.getText(), font11));
        document.add(p9);
        Paragraph p10 = new Paragraph();
        p10.add(new Chunk("REGISTRATION NO:       :",
                FontFactory.getFont(FontFactory.COURIER, 12, Font.NORMAL, BaseColor.BLACK)));
        p10.add(new Chunk(TC8.getText(), font11));
        document.add(p10);
        document.add(new Paragraph("                                       "));

        PdfPTable table = new PdfPTable(8);
        String vacume = "";
        table.addCell("Class");
        table.addCell("Date of Admission");
        table.addCell("Date of Promotion");
        table.addCell("Date of Removal");
        table.addCell("Cause of Removal");
        table.addCell("Year");
        table.addCell("Conduct and Work");
        table.addCell("Sign");

        PdfPCell cell10 = new PdfPCell(new Paragraph("NURSERY", font100));
        table.addCell(cell10);
        if (TC6.getSelectedIndex() == 0) {
            PdfPCell cell11 = new PdfPCell(new Paragraph(TC11.getText(), font100));
            PdfPCell cell12 = new PdfPCell(
                    new Paragraph(((JTextField) TC12.getDateEditor().getUiComponent()).getText(), font100));
            PdfPCell cell13 = new PdfPCell(
                    new Paragraph(((JTextField) TC13.getDateEditor().getUiComponent()).getText(), font100));
            ;
            PdfPCell cell14 = new PdfPCell(new Paragraph(TC14.getText(), font100));
            PdfPCell cell15 = new PdfPCell(new Paragraph((String) TC15.getSelectedItem(), font100));
            PdfPCell cell16 = new PdfPCell(new Paragraph(TC17.getText(), font100));
            table.addCell(cell11);
            table.addCell(cell12);
            table.addCell(cell13);
            table.addCell(cell14);
            table.addCell(cell15);
            table.addCell(cell16);
            table.addCell("");
        } else {
            for (int i = 0; i < 7; i++)
                table.addCell(vacume);
        }

        PdfPCell cell111 = new PdfPCell(new Paragraph("LKG", font100));
        table.addCell(cell111);
        if (TC6.getSelectedIndex() == 1) {
            PdfPCell cell11 = new PdfPCell(new Paragraph(TC11.getText(), font100));
            PdfPCell cell12 = new PdfPCell(
                    new Paragraph(((JTextField) TC12.getDateEditor().getUiComponent()).getText(), font100));
            PdfPCell cell13 = new PdfPCell(
                    new Paragraph(((JTextField) TC13.getDateEditor().getUiComponent()).getText(), font100));
            ;
            PdfPCell cell14 = new PdfPCell(new Paragraph(TC14.getText(), font100));
            PdfPCell cell15 = new PdfPCell(new Paragraph((String) TC15.getSelectedItem(), font100));
            PdfPCell cell16 = new PdfPCell(new Paragraph(TC17.getText(), font100));
            table.addCell(cell11);
            table.addCell(cell12);
            table.addCell(cell13);
            table.addCell(cell14);
            table.addCell(cell15);
            table.addCell(cell16);
            table.addCell("");
        } else {
            for (int i = 0; i < 7; i++)
                table.addCell(vacume);
        }

        PdfPCell cell1 = new PdfPCell(new Paragraph("UKG", font100));
        table.addCell(cell1);
        if (TC6.getSelectedIndex() == 2) {
            PdfPCell cell11 = new PdfPCell(new Paragraph(TC11.getText(), font100));
            PdfPCell cell12 = new PdfPCell(
                    new Paragraph(((JTextField) TC12.getDateEditor().getUiComponent()).getText(), font100));
            PdfPCell cell13 = new PdfPCell(
                    new Paragraph(((JTextField) TC13.getDateEditor().getUiComponent()).getText(), font100));
            ;
            PdfPCell cell14 = new PdfPCell(new Paragraph(TC14.getText(), font100));
            PdfPCell cell15 = new PdfPCell(new Paragraph((String) TC15.getSelectedItem(), font100));
            PdfPCell cell16 = new PdfPCell(new Paragraph(TC17.getText(), font100));
            table.addCell(cell11);
            table.addCell(cell12);
            table.addCell(cell13);
            table.addCell(cell14);
            table.addCell(cell15);
            table.addCell(cell16);
            table.addCell("");
        } else {
            for (int i = 0; i < 7; i++)
                table.addCell(vacume);
        }
        PdfPCell cell2 = new PdfPCell(new Paragraph("STD-1", font100));
        table.addCell(cell2);
        if (TC6.getSelectedIndex() == 3) {
            PdfPCell cell11 = new PdfPCell(new Paragraph(TC11.getText(), font100));
            PdfPCell cell12 = new PdfPCell(
                    new Paragraph(((JTextField) TC12.getDateEditor().getUiComponent()).getText(), font100));
            PdfPCell cell13 = new PdfPCell(
                    new Paragraph(((JTextField) TC13.getDateEditor().getUiComponent()).getText(), font100));
            ;
            PdfPCell cell14 = new PdfPCell(new Paragraph(TC14.getText(), font100));
            PdfPCell cell15 = new PdfPCell(new Paragraph((String) TC15.getSelectedItem(), font100));
            PdfPCell cell16 = new PdfPCell(new Paragraph(TC17.getText(), font100));
            table.addCell(cell11);
            table.addCell(cell12);
            table.addCell(cell13);
            table.addCell(cell14);
            table.addCell(cell15);
            table.addCell(cell16);
            table.addCell("");
        } else {
            for (int i = 0; i < 7; i++)
                table.addCell(vacume);
        }

        PdfPCell cell3 = new PdfPCell(new Paragraph("STD-2", font100));
        table.addCell(cell3);
        if (TC6.getSelectedIndex() == 4) {
            PdfPCell cell11 = new PdfPCell(new Paragraph(TC11.getText(), font100));
            PdfPCell cell12 = new PdfPCell(
                    new Paragraph(((JTextField) TC12.getDateEditor().getUiComponent()).getText(), font100));
            PdfPCell cell13 = new PdfPCell(
                    new Paragraph(((JTextField) TC13.getDateEditor().getUiComponent()).getText(), font100));
            ;
            PdfPCell cell14 = new PdfPCell(new Paragraph(TC14.getText(), font100));
            PdfPCell cell15 = new PdfPCell(new Paragraph((String) TC15.getSelectedItem(), font100));
            PdfPCell cell16 = new PdfPCell(new Paragraph(TC17.getText(), font100));
            table.addCell(cell11);
            table.addCell(cell12);
            table.addCell(cell13);
            table.addCell(cell14);
            table.addCell(cell15);
            table.addCell(cell16);
            table.addCell("");
        } else {
            for (int i = 0; i < 7; i++)
                table.addCell(vacume);
        }

        PdfPCell cell4 = new PdfPCell(new Paragraph("STD-3", font100));
        table.addCell(cell4);
        if (TC6.getSelectedIndex() == 5) {
            PdfPCell cell11 = new PdfPCell(new Paragraph(TC11.getText(), font100));
            PdfPCell cell12 = new PdfPCell(
                    new Paragraph(((JTextField) TC12.getDateEditor().getUiComponent()).getText(), font100));
            PdfPCell cell13 = new PdfPCell(
                    new Paragraph(((JTextField) TC13.getDateEditor().getUiComponent()).getText(), font100));
            ;
            PdfPCell cell14 = new PdfPCell(new Paragraph(TC14.getText(), font100));
            PdfPCell cell15 = new PdfPCell(new Paragraph((String) TC15.getSelectedItem(), font100));
            PdfPCell cell16 = new PdfPCell(new Paragraph(TC17.getText(), font100));
            table.addCell(cell11);
            table.addCell(cell12);
            table.addCell(cell13);
            table.addCell(cell14);
            table.addCell(cell15);
            table.addCell(cell16);
            table.addCell("");
        } else {
            for (int i = 0; i < 7; i++)
                table.addCell(vacume);
        }

        PdfPCell cell5 = new PdfPCell(new Paragraph("STD-4", font100));
        table.addCell(cell5);
        if (TC6.getSelectedIndex() == 6) {
            PdfPCell cell11 = new PdfPCell(new Paragraph(TC11.getText(), font100));
            PdfPCell cell12 = new PdfPCell(
                    new Paragraph(((JTextField) TC12.getDateEditor().getUiComponent()).getText(), font100));
            PdfPCell cell13 = new PdfPCell(
                    new Paragraph(((JTextField) TC13.getDateEditor().getUiComponent()).getText(), font100));
            ;
            PdfPCell cell14 = new PdfPCell(new Paragraph(TC14.getText(), font100));
            PdfPCell cell15 = new PdfPCell(new Paragraph((String) TC15.getSelectedItem(), font100));
            PdfPCell cell16 = new PdfPCell(new Paragraph(TC17.getText(), font100));
            table.addCell(cell11);
            table.addCell(cell12);
            table.addCell(cell13);
            table.addCell(cell14);
            table.addCell(cell15);
            table.addCell(cell16);
            table.addCell("");
        } else {
            for (int i = 0; i < 7; i++)
                table.addCell(vacume);
        }
        PdfPCell cell6 = new PdfPCell(new Paragraph("STD-5", font100));
        table.addCell(cell6);
        if (TC6.getSelectedIndex() == 7) {
            PdfPCell cell11 = new PdfPCell(new Paragraph(TC11.getText(), font100));
            PdfPCell cell12 = new PdfPCell(
                    new Paragraph(((JTextField) TC12.getDateEditor().getUiComponent()).getText(), font100));
            PdfPCell cell13 = new PdfPCell(
                    new Paragraph(((JTextField) TC13.getDateEditor().getUiComponent()).getText(), font100));
            ;
            PdfPCell cell14 = new PdfPCell(new Paragraph(TC14.getText(), font100));
            PdfPCell cell15 = new PdfPCell(new Paragraph((String) TC15.getSelectedItem(), font100));
            PdfPCell cell16 = new PdfPCell(new Paragraph(TC17.getText(), font100));
            table.addCell(cell11);
            table.addCell(cell12);
            table.addCell(cell13);
            table.addCell(cell14);
            table.addCell(cell15);
            table.addCell(cell16);
            table.addCell("");
        } else {
            for (int i = 0; i < 7; i++)
                table.addCell(vacume);
        }
        PdfPCell cell8 = new PdfPCell(new Paragraph("STD-6", font100));
        table.addCell(cell8);
        if (TC6.getSelectedIndex() == 8) {
            PdfPCell cell11 = new PdfPCell(new Paragraph(TC11.getText(), font100));
            PdfPCell cell12 = new PdfPCell(
                    new Paragraph(((JTextField) TC12.getDateEditor().getUiComponent()).getText(), font100));
            PdfPCell cell13 = new PdfPCell(
                    new Paragraph(((JTextField) TC13.getDateEditor().getUiComponent()).getText(), font100));
            ;
            PdfPCell cell14 = new PdfPCell(new Paragraph(TC14.getText(), font100));
            PdfPCell cell15 = new PdfPCell(new Paragraph((String) TC15.getSelectedItem(), font100));
            PdfPCell cell16 = new PdfPCell(new Paragraph(TC17.getText(), font100));
            table.addCell(cell11);
            table.addCell(cell12);
            table.addCell(cell13);
            table.addCell(cell14);
            table.addCell(cell15);
            table.addCell(cell16);
            table.addCell("");
        } else {
            for (int i = 0; i < 7; i++)
                table.addCell(vacume);
        }

        PdfPCell cell9 = new PdfPCell(new Paragraph("STD-7", font100));
        table.addCell(cell9);
        if (TC6.getSelectedIndex() == 9) {
            PdfPCell cell11 = new PdfPCell(new Paragraph(TC11.getText(), font100));
            PdfPCell cell12 = new PdfPCell(
                    new Paragraph(((JTextField) TC12.getDateEditor().getUiComponent()).getText(), font100));
            PdfPCell cell13 = new PdfPCell(
                    new Paragraph(((JTextField) TC13.getDateEditor().getUiComponent()).getText(), font100));
            ;
            PdfPCell cell14 = new PdfPCell(new Paragraph(TC14.getText(), font100));
            PdfPCell cell15 = new PdfPCell(new Paragraph((String) TC15.getSelectedItem(), font100));
            PdfPCell cell16 = new PdfPCell(new Paragraph(TC17.getText(), font100));
            table.addCell(cell11);
            table.addCell(cell12);
            table.addCell(cell13);
            table.addCell(cell14);
            table.addCell(cell15);
            table.addCell(cell16);
            table.addCell("");
        } else {
            for (int i = 0; i < 7; i++)
                table.addCell(vacume);
        }

        PdfPCell cell18 = new PdfPCell(new Paragraph("STD-8", font100));
        table.addCell(cell18);
        if (TC6.getSelectedIndex() == 2) {
            PdfPCell cell11 = new PdfPCell(new Paragraph(TC11.getText(), font100));
            PdfPCell cell12 = new PdfPCell(
                    new Paragraph(((JTextField) TC12.getDateEditor().getUiComponent()).getText(), font100));
            PdfPCell cell13 = new PdfPCell(
                    new Paragraph(((JTextField) TC13.getDateEditor().getUiComponent()).getText(), font100));
            ;
            PdfPCell cell14 = new PdfPCell(new Paragraph(TC14.getText(), font100));
            PdfPCell cell15 = new PdfPCell(new Paragraph((String) TC15.getSelectedItem(), font100));
            PdfPCell cell16 = new PdfPCell(new Paragraph(TC17.getText(), font100));
            table.addCell(cell11);
            table.addCell(cell12);
            table.addCell(cell13);
            table.addCell(cell14);
            table.addCell(cell15);
            table.addCell(cell16);
            table.addCell("");
        } else {
            for (int i = 0; i < 7; i++)
                table.addCell(vacume);
        }

        float[] ColumnWidths = new float[] { 8f, 12f, 12f, 12f, 22f, 8f, 15f, 7f };
        table.setWidths(ColumnWidths);
        table.setWidthPercentage(106);
        table.setHorizontalAlignment(Element.ALIGN_LEFT);
        document.add(table);

        document.add(new Paragraph("                                       "));
        document.add(new Paragraph("                                       "));
        document.add(new Paragraph(
                "1. I certified that the entries as regard details of the student have been duly checked from the 'Admission form' and that they are complete.",
                FontFactory.getFont(FontFactory.TIMES_ROMAN, 10, Font.NORMAL, BaseColor.BLACK)));
        // document.add(new Paragraph("                                                                                                        "));

        document.add(new Paragraph("                                       "));
        document.add(new Paragraph(
                "2. Certified that the above Students register have been posted up-to date of students leaving as required by the departmental rules.",
                FontFactory.getFont(FontFactory.TIMES_ROMAN, 10, Font.NORMAL, BaseColor.BLACK)));
        document.add(new Paragraph("                                       "));
        document.add(new Paragraph("                                       "));
        document.add(new Paragraph(
                "Prepared by:-" + "                                " + "Date:-" + " "
                        + new java.util.Date().toString() + "                      " + "Principal's Sign:-",
                FontFactory.getFont(FontFactory.TIMES_BOLD, 12, Font.NORMAL, BaseColor.BLACK)));

        document.add(new Paragraph("                                       "));
        document.add(new Paragraph(
                "----------------------------------------------------------------------------------------------------------------------------------"));
        document.add(new Paragraph("An ISO 9001:2008 Certified School(Certificate Number:NOR/0712M/1505)",
                FontFactory.getFont(FontFactory.COURIER, 12, Font.NORMAL, BaseColor.BLUE)));
        document.add(new Paragraph("(Run By:Smart Educational Society)Regd.No.(DR/GGN/285)",
                FontFactory.getFont(FontFactory.COURIER, 12, Font.NORMAL, BaseColor.BLUE)));
        document.add(new Paragraph(
                "413A/23,Gali No:-2,Heera Nagar,Near Rajendra Hospital,Khandsa Road,Gurgaon(Haryana)",
                FontFactory.getFont(FontFactory.COURIER, 10, Font.NORMAL, BaseColor.BLUE)));
        cb.saveState();
        cb.setColorStroke(BaseColor.BLACK);
        cb.rectangle(2, 2, 588, 828);
        cb.stroke();
        cb.restoreState();
        JOptionPane.showMessageDialog(this, "it is saved");
        document.close();
    } catch (Exception ee) {
        JOptionPane.showMessageDialog(this, ee);
    } // TODO add your handling code here:
}