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

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

Introduction

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

Prototype

public void setWidths(final int relativeWidths[]) throws DocumentException 

Source Link

Document

Sets the relative widths of the table.

Usage

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

License:Open Source License

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

    // This creates our new PDF document and declares its orientation
    Document pdfDoc;/*from  ww w  . j a 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:FormatoPDF.ClasesPDF.PDF1.java

public void CrearPDF1(String[][] tabla, String txt1, String txt2, String txt3, String txt4, String txt5,
            String txt6, JTable tabla2) {
        String[][] tabla1 = tabla;
        float[] medidas1 = { 8.5f, 9.0f, 7.5f, 3.5f, 4.5f, 4.0f };
        float[] medidas2 = { 7.5f, 3.5f, 7.0f, 5.5f, 4.5f, 4.5f, 4.5f };
        float[] medidas3 = { 6.5f, 20.5f };
        JFileChooser dlg = new JFileChooser();
        int option = dlg.showSaveDialog(dlg);
        if (option == JFileChooser.APPROVE_OPTION) {
            File f = dlg.getSelectedFile();
            String f1 = f.toString();
            try {
                BaseColor MiColor = WebColors.getRGBColor("#04B4AE");
                TablasPDF tab = new TablasPDF();
                ImagenHome img = new ImagenHome();
                Document document = new Document();
                PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(f1 + ".pdf"));
                Paragraph saltolinea = new Paragraph();
                saltolinea.add("\n");
                document.open();//from w  w  w . j av  a 2  s .  c  o m
                document.add(img.CrearImg());
                DatosEncabezado en = new DatosEncabezado();
                String[][] valores = new String[4][2];
                valores[0][0] = "Dependencia: ";
                valores[0][1] = txt1;
                valores[1][0] = "Expediente: ";
                valores[1][1] = txt2;
                valores[2][0] = "Sesin: ";
                valores[2][1] = txt3;
                valores[3][0] = "Fecha: ";
                valores[3][1] = txt4;
                en.Datos(valores, writer);

                document.add(saltolinea);
                document.add(saltolinea);
                document.add(saltolinea);
                document.add(saltolinea);
                document.add(saltolinea);
                document.add(saltolinea);
                document.add(saltolinea);
                document.add(saltolinea);
                document.add(saltolinea);
                document.add(saltolinea);
                boolean color = true;
                PdfPTable tabpdf1 = new PdfPTable(6);
                PdfPCell cell1 = new PdfPCell(
                        new Paragraph("Sesin:", FontFactory.getFont("arial", 10, Font.BOLD, BaseColor.BLACK)));
                PdfPCell cell11 = new PdfPCell(
                        new Paragraph(tabla1[0][1], FontFactory.getFont("arial", 10, Font.BOLD, BaseColor.BLACK)));
                cell1.setBackgroundColor(MiColor);
                tabpdf1.addCell(cell1);
                tabpdf1.addCell(cell11);
                PdfPCell cell2 = new PdfPCell(
                        new Paragraph("Fecha:", FontFactory.getFont("arial", 10, Font.BOLD, BaseColor.BLACK)));
                PdfPCell cell22 = new PdfPCell(
                        new Paragraph(tabla1[0][3], FontFactory.getFont("arial", 10, Font.BOLD, BaseColor.BLACK)));
                cell2.setBackgroundColor(MiColor);
                tabpdf1.addCell(cell2);
                tabpdf1.addCell(cell22);
                PdfPCell cell3 = new PdfPCell(
                        new Paragraph("Acuerdo:", FontFactory.getFont("arial", 10, Font.BOLD, BaseColor.BLACK)));
                PdfPCell cell33 = new PdfPCell(
                        new Paragraph(txt5, FontFactory.getFont("arial", 10, Font.BOLD, BaseColor.BLACK)));
                cell3.setBackgroundColor(MiColor);
                tabpdf1.addCell(cell3);
                tabpdf1.addCell(cell33);
                document.add(tab.DibujarTablaArre1(6, 6, tabla1, medidas1, color, tabpdf1, 1, ""));

                document.add(saltolinea);
                document.add(saltolinea);
                document.add(saltolinea);
                document.add(saltolinea);

                PdfPTable tabpdf2 = new PdfPTable(7);
                PdfPCell cell1tab2 = new PdfPCell(new Phrase("ESTUDIO DE MERCADO",
                        FontFactory.getFont("arial", 10, Font.BOLD, BaseColor.BLACK)));
                cell1tab2.setBackgroundColor(MiColor);
                cell1tab2.setMinimumHeight(30);
                cell1tab2.setHorizontalAlignment(Element.ALIGN_CENTER);
                cell1tab2.setColspan(7);
                cell1tab2.setRowspan(1);
                cell1tab2.setVerticalAlignment(Element.ALIGN_MIDDLE);
                tabpdf2.addCell(cell1tab2);

                PdfPCell cell2tab2 = new PdfPCell(new Phrase("Datos de la empresa ",
                        FontFactory.getFont("arial", 10, Font.BOLD, BaseColor.BLACK)));
                cell2tab2.setBackgroundColor(MiColor);
                cell2tab2.setHorizontalAlignment(Element.ALIGN_CENTER);
                cell2tab2.setColspan(4);
                cell2tab2.setRowspan(1);
                cell2tab2.setVerticalAlignment(Element.ALIGN_MIDDLE);
                tabpdf2.addCell(cell2tab2);

                PdfPCell cell3tab2 = new PdfPCell(new Phrase("Datos de cotizacin ",
                        FontFactory.getFont("arial", 10, Font.BOLD, BaseColor.BLACK)));
                cell3tab2.setBackgroundColor(MiColor);
                cell3tab2.setHorizontalAlignment(Element.ALIGN_CENTER);
                cell3tab2.setColspan(3);
                cell3tab2.setRowspan(1);
                cell3tab2.setVerticalAlignment(Element.ALIGN_MIDDLE);
                tabpdf2.addCell(cell3tab2);

                PdfPCell cell4tab2 = new PdfPCell(new Paragraph("Nombre, Denominacin o Razn Social",
                        FontFactory.getFont("arial", 10, Font.BOLD, BaseColor.BLACK)));
                cell4tab2.setBackgroundColor(MiColor);
                cell4tab2.setHorizontalAlignment(Element.ALIGN_CENTER);
                tabpdf2.addCell(cell4tab2);
                PdfPCell cell5tab2 = new PdfPCell(
                        new Paragraph("RFC", FontFactory.getFont("arial", 10, Font.BOLD, BaseColor.BLACK)));
                cell5tab2.setBackgroundColor(MiColor);
                cell5tab2.setHorizontalAlignment(Element.ALIGN_CENTER);
                tabpdf2.addCell(cell5tab2);
                PdfPCell cell6tab2 = new PdfPCell(new Paragraph("Representante Legal",
                        FontFactory.getFont("arial", 10, Font.BOLD, BaseColor.BLACK)));
                cell6tab2.setBackgroundColor(MiColor);
                cell6tab2.setHorizontalAlignment(Element.ALIGN_CENTER);
                tabpdf2.addCell(cell6tab2);
                PdfPCell cell7tab2 = new PdfPCell(new Paragraph("Domicilio Fiscal",
                        FontFactory.getFont("arial", 10, Font.BOLD, BaseColor.BLACK)));
                cell7tab2.setBackgroundColor(MiColor);
                cell7tab2.setHorizontalAlignment(Element.ALIGN_CENTER);
                tabpdf2.addCell(cell7tab2);
                PdfPCell cell8tab2 = new PdfPCell(
                        new Paragraph("Subtotal", FontFactory.getFont("arial", 10, Font.BOLD, BaseColor.BLACK)));
                cell8tab2.setBackgroundColor(MiColor);
                cell8tab2.setHorizontalAlignment(Element.ALIGN_CENTER);
                tabpdf2.addCell(cell8tab2);
                PdfPCell cell9tab2 = new PdfPCell(
                        new Paragraph("IVA", FontFactory.getFont("arial", 10, Font.BOLD, BaseColor.BLACK)));
                cell9tab2.setBackgroundColor(MiColor);
                cell9tab2.setHorizontalAlignment(Element.ALIGN_CENTER);
                tabpdf2.addCell(cell9tab2);
                PdfPCell cell10tab2 = new PdfPCell(
                        new Paragraph("TOTAL", FontFactory.getFont("arial", 10, Font.BOLD, BaseColor.BLACK)));
                cell10tab2.setBackgroundColor(MiColor);
                cell10tab2.setHorizontalAlignment(Element.ALIGN_CENTER);
                tabpdf2.addCell(cell10tab2);

                document.add(tab.DibujarTabla(7, 5, tabla2, medidas2, tabpdf2));
                document.add(saltolinea);
                document.add(saltolinea);
                document.add(saltolinea);
                document.add(saltolinea);

                PdfPTable tabpdf3 = new PdfPTable(2);
                PdfPCell cell1tab3 = new PdfPCell(
                        new Phrase("Observaciones:", FontFactory.getFont("arial", 10, Font.BOLD, BaseColor.BLACK)));
                cell1tab3.setBackgroundColor(MiColor);
                cell1tab3.setMinimumHeight(60);
                cell1tab3.setHorizontalAlignment(Element.ALIGN_CENTER);
                cell1tab3.setVerticalAlignment(Element.ALIGN_MIDDLE);
                tabpdf3.addCell(cell1tab3);

                PdfPCell cell2tab3 = new PdfPCell(
                        new Phrase(txt6, FontFactory.getFont("arial", 10, Font.BOLD, BaseColor.BLACK)));
                cell2tab3.setMinimumHeight(60);
                cell2tab3.setHorizontalAlignment(Element.ALIGN_CENTER);
                cell2tab3.setVerticalAlignment(Element.ALIGN_MIDDLE);
                tabpdf3.addCell(cell2tab3);
                tabpdf3.setWidths(medidas3);
                document.add(tabpdf3);

                document.close();
                JOptionPane.showMessageDialog(null, "El archivo se ha guardado", "Exito",
                        JOptionPane.INFORMATION_MESSAGE);

                File path = new File(f1 + ".pdf");
                Desktop.getDesktop().open(path);
            } catch (Exception e) {
                JOptionPane.showMessageDialog(null, "Error " + e, "Error", JOptionPane.ERROR_MESSAGE);
            }
        }
    }

From source file:FormatoPDF.ClasesPDF.PDF2.java

public void CrearPDF2(String[][] tabla, String txt1, String txt2, String txt3, String txt4, String txt5,
            String txt6, String txt7, JTable tabla2, String txt8, String txt9, JTable tabla3, String txt10) {
        String[][] tabla1 = tabla;
        float[] medidas1 = { 8.5f, 9.0f, 7.5f, 3.5f, 4.5f, 4.0f };
        float[] medidas2 = { 6.5f, 4.5f, 6.0f, 5.5f, 5.5f, 5.5f, 3.0f, 3.0f };
        float[] medidas3 = { 6.5f, 3.5f, 3.5f, 3.5f, 2.5f, 3.5f, 6.0f, 4.0f, 4.0f };
        float[] medidas4 = { 6.5f, 20.5f };
        JFileChooser dlg = new JFileChooser();
        int option = dlg.showSaveDialog(dlg);
        if (option == JFileChooser.APPROVE_OPTION) {
            File f = dlg.getSelectedFile();
            String f1 = f.toString();
            try {
                BaseColor MiColor = WebColors.getRGBColor("#04B4AE");
                TablasPDF tab = new TablasPDF();
                ImagenHome img = new ImagenHome();
                Document document = new Document();
                PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(f1 + ".pdf"));
                Paragraph saltolinea = new Paragraph();
                saltolinea.add("\n");
                document.open();/*  w  ww .  j  av  a  2 s  .c om*/
                document.add(img.CrearImg());
                DatosEncabezado en = new DatosEncabezado();
                String[][] valores = new String[4][2];
                valores[0][0] = "Dependencia: ";
                valores[0][1] = txt1;
                valores[1][0] = "Expediente: ";
                valores[1][1] = txt2;
                valores[2][0] = "Sesin: ";
                valores[2][1] = txt3;
                valores[3][0] = "Fecha: ";
                valores[3][1] = txt4;
                en.Datos(valores, writer);

                document.add(saltolinea);
                document.add(saltolinea);
                document.add(saltolinea);
                document.add(saltolinea);
                document.add(saltolinea);
                document.add(saltolinea);
                document.add(saltolinea);
                document.add(saltolinea);
                document.add(saltolinea);
                document.add(saltolinea);
                boolean color = true;
                PdfPTable tabpdf1 = new PdfPTable(6);
                PdfPCell cell1 = new PdfPCell(
                        new Paragraph("Sesin:", FontFactory.getFont("arial", 10, Font.BOLD, BaseColor.BLACK)));
                PdfPCell cell11 = new PdfPCell(
                        new Paragraph(tabla1[0][1], FontFactory.getFont("arial", 10, Font.BOLD, BaseColor.BLACK)));
                cell1.setBackgroundColor(MiColor);
                tabpdf1.addCell(cell1);
                tabpdf1.addCell(cell11);
                PdfPCell cell2 = new PdfPCell(
                        new Paragraph("Fecha:", FontFactory.getFont("arial", 10, Font.BOLD, BaseColor.BLACK)));
                PdfPCell cell22 = new PdfPCell(
                        new Paragraph(tabla1[0][3], FontFactory.getFont("arial", 10, Font.BOLD, BaseColor.BLACK)));
                cell2.setBackgroundColor(MiColor);
                tabpdf1.addCell(cell2);
                tabpdf1.addCell(cell22);
                PdfPCell cell3 = new PdfPCell(
                        new Paragraph("Acuerdo:", FontFactory.getFont("arial", 10, Font.BOLD, BaseColor.BLACK)));
                PdfPCell cell33 = new PdfPCell(
                        new Paragraph(txt5, FontFactory.getFont("arial", 10, Font.BOLD, BaseColor.BLACK)));
                cell3.setBackgroundColor(MiColor);
                tabpdf1.addCell(cell3);
                tabpdf1.addCell(cell33);
                document.add(tab.DibujarTablaArre1(6, 6, tabla1, medidas1, color, tabpdf1, 2, txt6));

                document.add(saltolinea);
                document.add(saltolinea);
                document.add(saltolinea);

                PdfPTable tabpdf2 = new PdfPTable(8);
                tabpdf2.setWidths(medidas2);
                PdfPCell cell1tab2 = new PdfPCell(new Phrase("Datos de la empresa ",
                        FontFactory.getFont("arial", 8, Font.BOLD, BaseColor.BLACK)));
                cell1tab2.setBackgroundColor(MiColor);
                cell1tab2.setHorizontalAlignment(Element.ALIGN_CENTER);
                cell1tab2.setColspan(4);
                cell1tab2.setRowspan(2);
                cell1tab2.setVerticalAlignment(Element.ALIGN_MIDDLE);
                tabpdf2.addCell(cell1tab2);

                PdfPCell cell2tab2 = new PdfPCell(
                        new Phrase("", FontFactory.getFont("arial", 8, Font.BOLD, BaseColor.BLACK)));
                cell2tab2.setBackgroundColor(MiColor);
                cell2tab2.setHorizontalAlignment(Element.ALIGN_CENTER);
                cell2tab2.setColspan(2);
                cell2tab2.setRowspan(1);
                cell2tab2.setVerticalAlignment(Element.ALIGN_MIDDLE);
                tabpdf2.addCell(cell2tab2);

                PdfPCell cell3tab2 = new PdfPCell(new Phrase("Junta de Aclaraciones",
                        FontFactory.getFont("arial", 8, Font.BOLD, BaseColor.BLACK)));
                cell3tab2.setBackgroundColor(MiColor);
                cell3tab2.setHorizontalAlignment(Element.ALIGN_CENTER);
                cell3tab2.setColspan(2);
                cell3tab2.setRowspan(1);
                cell3tab2.setVerticalAlignment(Element.ALIGN_MIDDLE);
                tabpdf2.addCell(cell3tab2);

                PdfPCell cell4tab2 = new PdfPCell(
                        new Phrase("Fecha:", FontFactory.getFont("arial", 8, Font.BOLD, BaseColor.BLACK)));
                cell4tab2.setHorizontalAlignment(Element.ALIGN_CENTER);
                cell4tab2.setBackgroundColor(MiColor);
                cell4tab2.setColspan(1);
                cell4tab2.setRowspan(1);
                cell4tab2.setVerticalAlignment(Element.ALIGN_MIDDLE);
                tabpdf2.addCell(cell4tab2);

                PdfPCell cell5tab2 = new PdfPCell(
                        new Phrase(txt7, FontFactory.getFont("arial", 8, Font.BOLD, BaseColor.BLACK)));
                cell5tab2.setHorizontalAlignment(Element.ALIGN_CENTER);
                cell5tab2.setColspan(1);
                cell5tab2.setRowspan(1);
                cell5tab2.setVerticalAlignment(Element.ALIGN_MIDDLE);
                tabpdf2.addCell(cell5tab2);///////////

                PdfPTable tabpdf3 = new PdfPTable(8);
                document.add(tabpdf2);

                PdfPCell cell1tab3 = new PdfPCell(new Phrase("Nombre, Denominacin o Razn Social",
                        FontFactory.getFont("arial", 8, Font.BOLD, BaseColor.BLACK)));
                cell1tab3.setBackgroundColor(MiColor);
                cell1tab3.setHorizontalAlignment(Element.ALIGN_CENTER);
                cell1tab3.setVerticalAlignment(Element.ALIGN_MIDDLE);
                tabpdf3.addCell(cell1tab3);

                PdfPCell cell2tab3 = new PdfPCell(
                        new Phrase("RFC", FontFactory.getFont("arial", 8, Font.BOLD, BaseColor.BLACK)));
                cell2tab3.setBackgroundColor(MiColor);
                cell2tab3.setHorizontalAlignment(Element.ALIGN_CENTER);
                cell2tab3.setVerticalAlignment(Element.ALIGN_MIDDLE);
                tabpdf3.addCell(cell2tab3);

                PdfPCell cell3tab3 = new PdfPCell(new Phrase("Representante Legal",
                        FontFactory.getFont("arial", 8, Font.BOLD, BaseColor.BLACK)));
                cell3tab3.setBackgroundColor(MiColor);
                cell3tab3.setHorizontalAlignment(Element.ALIGN_CENTER);
                cell3tab3.setVerticalAlignment(Element.ALIGN_MIDDLE);
                tabpdf3.addCell(cell3tab3);

                PdfPCell cell4tab3 = new PdfPCell(new Phrase("Domicilio Fiscal",
                        FontFactory.getFont("arial", 8, Font.BOLD, BaseColor.BLACK)));
                cell4tab3.setBackgroundColor(MiColor);
                cell4tab3.setHorizontalAlignment(Element.ALIGN_CENTER);
                cell4tab3.setVerticalAlignment(Element.ALIGN_MIDDLE);
                tabpdf3.addCell(cell4tab3);

                PdfPCell cell5tab3 = new PdfPCell(new Phrase("Proveedores sancionados",
                        FontFactory.getFont("arial", 8, Font.BOLD, BaseColor.BLACK)));
                cell5tab3.setBackgroundColor(MiColor);
                cell5tab3.setHorizontalAlignment(Element.ALIGN_CENTER);
                cell5tab3.setVerticalAlignment(Element.ALIGN_MIDDLE);
                tabpdf3.addCell(cell5tab3);

                PdfPCell cell6tab3 = new PdfPCell(
                        new Phrase("Pgina web", FontFactory.getFont("arial", 8, Font.BOLD, BaseColor.BLACK)));
                cell6tab3.setBackgroundColor(MiColor);
                cell6tab3.setHorizontalAlignment(Element.ALIGN_CENTER);
                cell6tab3.setVerticalAlignment(Element.ALIGN_MIDDLE);
                tabpdf3.addCell(cell6tab3);

                PdfPCell cell7tab3 = new PdfPCell(
                        new Phrase("Asisti", FontFactory.getFont("arial", 8, Font.BOLD, BaseColor.BLACK)));
                cell7tab3.setBackgroundColor(MiColor);
                cell7tab3.setHorizontalAlignment(Element.ALIGN_CENTER);
                cell7tab3.setVerticalAlignment(Element.ALIGN_MIDDLE);
                tabpdf3.addCell(cell7tab3);

                PdfPCell cell8tab3 = new PdfPCell(
                        new Phrase("No asisti", FontFactory.getFont("arial", 8, Font.BOLD, BaseColor.BLACK)));
                cell8tab3.setBackgroundColor(MiColor);
                cell8tab3.setHorizontalAlignment(Element.ALIGN_CENTER);
                cell8tab3.setVerticalAlignment(Element.ALIGN_MIDDLE);
                tabpdf3.addCell(cell8tab3);

                document.add(tab.DibujarTabla(8, 4, tabla2, medidas2, tabpdf3));
                document.add(saltolinea);
                document.add(saltolinea);
                document.add(saltolinea);
                ///////////////////////
                PdfPTable tabpdf4 = new PdfPTable(9);
                PdfPCell cell1tab4 = new PdfPCell(new Phrase("Nombre, Denominacin o Razn Social",
                        FontFactory.getFont("arial", 8, Font.BOLD, BaseColor.BLACK)));
                cell1tab4.setBackgroundColor(MiColor);
                cell1tab4.setHorizontalAlignment(Element.ALIGN_CENTER);
                cell1tab4.setColspan(1);
                cell1tab4.setRowspan(4);
                cell1tab4.setVerticalAlignment(Element.ALIGN_MIDDLE);
                tabpdf4.addCell(cell1tab4);

                PdfPCell cell2tab4 = new PdfPCell(new Phrase("Apertura de Propuestas",
                        FontFactory.getFont("arial", 8, Font.BOLD, BaseColor.BLACK)));
                cell2tab4.setBackgroundColor(MiColor);
                cell2tab4.setHorizontalAlignment(Element.ALIGN_CENTER);
                cell2tab4.setColspan(5);
                cell2tab4.setRowspan(1);
                cell2tab4.setVerticalAlignment(Element.ALIGN_MIDDLE);
                tabpdf4.addCell(cell2tab4);

                PdfPCell cell3tab4 = new PdfPCell(new Phrase("Notificacin y Lectura de Fallo",
                        FontFactory.getFont("arial", 8, Font.BOLD, BaseColor.BLACK)));
                cell3tab4.setBackgroundColor(MiColor);
                cell3tab4.setHorizontalAlignment(Element.ALIGN_CENTER);
                cell3tab4.setColspan(3);
                cell3tab4.setRowspan(1);
                cell3tab4.setVerticalAlignment(Element.ALIGN_MIDDLE);
                tabpdf4.addCell(cell3tab4);

                PdfPCell cell4tab4 = new PdfPCell(
                        new Phrase("Fecha:", FontFactory.getFont("arial", 8, Font.BOLD, BaseColor.BLACK)));
                cell4tab4.setHorizontalAlignment(Element.ALIGN_CENTER);
                cell4tab4.setBackgroundColor(MiColor);
                cell4tab4.setColspan(2);
                cell4tab4.setRowspan(1);
                cell4tab4.setVerticalAlignment(Element.ALIGN_MIDDLE);
                tabpdf4.addCell(cell4tab4);

                PdfPCell cell5tab4 = new PdfPCell(
                        new Phrase(txt8, FontFactory.getFont("arial", 8, Font.BOLD, BaseColor.BLACK)));
                cell5tab4.setHorizontalAlignment(Element.ALIGN_CENTER);
                cell5tab4.setColspan(3);
                cell5tab4.setRowspan(1);
                cell5tab4.setVerticalAlignment(Element.ALIGN_MIDDLE);
                tabpdf4.addCell(cell5tab4);

                PdfPCell cell6tab4 = new PdfPCell(
                        new Phrase("Fecha:", FontFactory.getFont("arial", 8, Font.BOLD, BaseColor.BLACK)));
                cell6tab4.setHorizontalAlignment(Element.ALIGN_CENTER);
                cell6tab4.setBackgroundColor(MiColor);
                cell6tab4.setColspan(1);
                cell6tab4.setRowspan(1);
                cell6tab4.setVerticalAlignment(Element.ALIGN_MIDDLE);
                tabpdf4.addCell(cell6tab4);

                PdfPCell cell7tab4 = new PdfPCell(
                        new Phrase(txt9, FontFactory.getFont("arial", 8, Font.BOLD, BaseColor.BLACK)));
                cell7tab4.setHorizontalAlignment(Element.ALIGN_CENTER);
                cell7tab4.setColspan(2);
                cell7tab4.setRowspan(1);
                cell7tab4.setVerticalAlignment(Element.ALIGN_MIDDLE);
                tabpdf4.addCell(cell7tab4);

                PdfPCell cell8tab4 = new PdfPCell(
                        new Phrase("Tcnica", FontFactory.getFont("arial", 8, Font.BOLD, BaseColor.BLACK)));
                cell8tab4.setHorizontalAlignment(Element.ALIGN_CENTER);
                cell8tab4.setBackgroundColor(MiColor);
                cell8tab4.setColspan(2);
                cell8tab4.setRowspan(1);
                cell8tab4.setVerticalAlignment(Element.ALIGN_MIDDLE);
                tabpdf4.addCell(cell8tab4);

                PdfPCell cell9tab4 = new PdfPCell(
                        new Phrase("Econmica ", FontFactory.getFont("arial", 8, Font.BOLD, BaseColor.BLACK)));
                cell9tab4.setHorizontalAlignment(Element.ALIGN_CENTER);
                cell9tab4.setBackgroundColor(MiColor);
                cell9tab4.setColspan(3);
                cell9tab4.setRowspan(1);
                cell9tab4.setVerticalAlignment(Element.ALIGN_MIDDLE);
                tabpdf4.addCell(cell9tab4);

                PdfPCell cell10tab4 = new PdfPCell(new Phrase("Motivo de desechamiento",
                        FontFactory.getFont("arial", 8, Font.BOLD, BaseColor.BLACK)));
                cell10tab4.setHorizontalAlignment(Element.ALIGN_CENTER);
                cell10tab4.setBackgroundColor(MiColor);
                cell10tab4.setColspan(1);
                cell10tab4.setRowspan(2);
                cell10tab4.setVerticalAlignment(Element.ALIGN_MIDDLE);
                tabpdf4.addCell(cell10tab4);

                PdfPCell cell11tab4 = new PdfPCell(new Phrase("Empresa Adjudicada",
                        FontFactory.getFont("arial", 8, Font.BOLD, BaseColor.BLACK)));
                cell11tab4.setHorizontalAlignment(Element.ALIGN_CENTER);
                cell11tab4.setBackgroundColor(MiColor);
                cell11tab4.setColspan(1);
                cell11tab4.setRowspan(2);
                cell11tab4.setVerticalAlignment(Element.ALIGN_MIDDLE);
                tabpdf4.addCell(cell11tab4);

                PdfPCell cell12tab4 = new PdfPCell(new Phrase("Monto Adjudicado",
                        FontFactory.getFont("arial", 8, Font.BOLD, BaseColor.BLACK)));
                cell12tab4.setHorizontalAlignment(Element.ALIGN_CENTER);
                cell12tab4.setBackgroundColor(MiColor);
                cell12tab4.setColspan(1);
                cell12tab4.setRowspan(2);
                cell12tab4.setVerticalAlignment(Element.ALIGN_MIDDLE);
                tabpdf4.addCell(cell12tab4);

                PdfPCell cell13tab4 = new PdfPCell(
                        new Phrase("Presenta", FontFactory.getFont("arial", 8, Font.BOLD, BaseColor.BLACK)));
                cell13tab4.setBackgroundColor(MiColor);
                cell13tab4.setHorizontalAlignment(Element.ALIGN_CENTER);
                cell13tab4.setVerticalAlignment(Element.ALIGN_MIDDLE);
                tabpdf4.addCell(cell13tab4);

                PdfPCell cell14tab4 = new PdfPCell(
                        new Phrase("No presenta", FontFactory.getFont("arial", 8, Font.BOLD, BaseColor.BLACK)));
                cell14tab4.setBackgroundColor(MiColor);
                cell14tab4.setHorizontalAlignment(Element.ALIGN_CENTER);
                cell14tab4.setVerticalAlignment(Element.ALIGN_MIDDLE);
                tabpdf4.addCell(cell14tab4);

                PdfPCell cell15tab4 = new PdfPCell(
                        new Phrase("Subtotal ", FontFactory.getFont("arial", 8, Font.BOLD, BaseColor.BLACK)));
                cell15tab4.setBackgroundColor(MiColor);
                cell15tab4.setHorizontalAlignment(Element.ALIGN_CENTER);
                cell15tab4.setVerticalAlignment(Element.ALIGN_MIDDLE);
                tabpdf4.addCell(cell15tab4);

                PdfPCell cell16tab4 = new PdfPCell(
                        new Phrase("IVA", FontFactory.getFont("arial", 8, Font.BOLD, BaseColor.BLACK)));
                cell16tab4.setBackgroundColor(MiColor);
                cell16tab4.setHorizontalAlignment(Element.ALIGN_CENTER);
                cell16tab4.setVerticalAlignment(Element.ALIGN_MIDDLE);
                tabpdf4.addCell(cell16tab4);

                PdfPCell cell17tab4 = new PdfPCell(
                        new Phrase("Total", FontFactory.getFont("arial", 8, Font.BOLD, BaseColor.BLACK)));
                cell17tab4.setBackgroundColor(MiColor);
                cell17tab4.setHorizontalAlignment(Element.ALIGN_CENTER);
                cell17tab4.setVerticalAlignment(Element.ALIGN_MIDDLE);
                tabpdf4.addCell(cell17tab4);

                document.add(tab.DibujarTabla(9, 4, tabla3, medidas3, tabpdf4));
                document.add(saltolinea);
                document.add(saltolinea);
                document.add(saltolinea);
                document.add(saltolinea);

                PdfPTable tabpdf5 = new PdfPTable(2);
                PdfPCell cell1tab5 = new PdfPCell(
                        new Phrase("Observaciones:", FontFactory.getFont("arial", 10, Font.BOLD, BaseColor.BLACK)));
                cell1tab5.setBackgroundColor(MiColor);
                cell1tab5.setMinimumHeight(60);
                cell1tab5.setHorizontalAlignment(Element.ALIGN_CENTER);
                cell1tab5.setVerticalAlignment(Element.ALIGN_MIDDLE);
                tabpdf5.addCell(cell1tab5);

                PdfPCell cell2tab5 = new PdfPCell(
                        new Phrase(txt10, FontFactory.getFont("arial", 10, Font.BOLD, BaseColor.BLACK)));
                cell2tab5.setMinimumHeight(60);
                cell2tab5.setHorizontalAlignment(Element.ALIGN_CENTER);
                cell2tab5.setVerticalAlignment(Element.ALIGN_MIDDLE);
                tabpdf5.addCell(cell2tab5);
                tabpdf5.setWidths(medidas4);
                document.add(tabpdf5);

                document.close();
                JOptionPane.showMessageDialog(null, "El archivo se ha guardado", "Exito",
                        JOptionPane.INFORMATION_MESSAGE);

                File path = new File(f1 + ".pdf");
                Desktop.getDesktop().open(path);
            } catch (Exception e) {
                JOptionPane.showMessageDialog(null, "Error " + e, "Error", JOptionPane.ERROR_MESSAGE);
            }
        }
    }

From source file:FormatoPDF.ClasesPDF.TablasPDF.java

public PdfPTable DibujarTabla(int col, int fil, JTable tabla, float medidas[], PdfPTable tab) {
        try {/*from   w  w  w. ja  v a2 s.c  o m*/
            tab.setWidths(medidas);
            for (int i = 0; i < fil; i++) {
                if (GetDatosTablas.GetData(tabla, i, 0) == null) {
                    break;
                }
                for (int j = 0; j < col; j++) {
                    Object obj1 = GetDatosTablas.GetData(tabla, i, j);
                    String value1 = obj1.toString();
                    PdfPCell cell = new PdfPCell(
                            new Paragraph(value1, FontFactory.getFont("arial", 8, Font.BOLD, BaseColor.BLACK)));
                    tab.addCell(cell);
                }
            }
        } catch (Exception e) {
            System.out.println("Error " + e);
        }
        return tab;
    }

From source file:FormatoPDF.ClasesPDF.TablasPDF.java

public PdfPTable DibujarTablaArre1(int col, int fil, String[][] tabla, float medidas[], boolean x,
            PdfPTable tab, int pdf, String ult) {

        try {/*w w w  .  j ava2 s  .  c  o  m*/
            BaseColor MiColor = WebColors.getRGBColor("#04B4AE");
            tab.setWidths(medidas);
            if (pdf == 2) {
                fil = 7;
            }
            for (int i = 1; i < fil; i++) {
                for (int j = 0; j < col - 2; j++) {
                    if (i == 6) {
                        PdfPCell cell = new PdfPCell(new Phrase("Publicacin de bases: ",
                                FontFactory.getFont("arial", 10, Font.BOLD, BaseColor.BLACK)));
                        cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
                        cell.setBackgroundColor(MiColor);
                        tab.addCell(cell);
                        PdfPCell cell2 = new PdfPCell(
                                new Phrase(ult, FontFactory.getFont("arial", 10, Font.BOLD, BaseColor.BLACK)));
                        cell2.setVerticalAlignment(Element.ALIGN_MIDDLE);
                        cell2.setColspan(5);
                        cell2.setRowspan(1);
                        tab.addCell(cell2);
                        break;
                    } else {
                        Object obj1 = tabla[i][j];
                        String value1 = obj1.toString();
                        if (x) {
                            if (j == 0 || j == 2) {
                                PdfPCell cell = new PdfPCell(new Paragraph(value1,
                                        FontFactory.getFont("arial", 10, Font.BOLD, BaseColor.BLACK)));
                                cell.setBackgroundColor(MiColor);
                                cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
                                tab.addCell(cell);
                            } else if (j == 3) {
                                PdfPCell cell = new PdfPCell(new Phrase(value1,
                                        FontFactory.getFont("arial", 10, Font.BOLD, BaseColor.BLACK)));
                                cell.setColspan(3);
                                cell.setRowspan(1);
                                cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
                                tab.addCell(cell);
                            } else {
                                PdfPCell cell = new PdfPCell(new Phrase(value1,
                                        FontFactory.getFont("arial", 10, Font.BOLD, BaseColor.BLACK)));
                                cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
                                tab.addCell(cell);
                            }
                        } else {
                            if (j == 3) {
                                PdfPCell cell = new PdfPCell(new Phrase(value1,
                                        FontFactory.getFont("arial", 10, Font.BOLD, BaseColor.BLACK)));
                                cell.setColspan(3);
                                cell.setRowspan(1);
                                cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
                                tab.addCell(cell);
                            } else {
                                PdfPCell cell = new PdfPCell(new Phrase(value1,
                                        FontFactory.getFont("arial", 10, Font.BOLD, BaseColor.BLACK)));
                                cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
                                tab.addCell(cell);
                            }
                        }
                    }
                }
            }
        } catch (Exception e) {
            System.out.println("Error " + e);
        }
        return tab;
    }

From source file:fr.ensicaen.yousign.GenerePDF.java

public void genere() {
    try {//from   ww  w.  j a v  a  2s  .c o  m
        OutputStream file = new FileOutputStream(util.generePDFFilenameToUse());

        Document document = new Document();
        PdfWriter.getInstance(document, file);
        document.open();
        //
        // Affichage du logo, de la date et l'heure et avec ou sans frais
        //
        document.add(addEntete());
        //
        // Caractristiques du missionnaire (table: nom, prenom, courriel = 1re colonne, adresse = 2me colonne
        //
        PdfPTable tableIdentite = new PdfPTable(2);
        tableIdentite.setWidthPercentage(100);

        PdfPCell nomCell = new PdfPCell(
                new Phrase(new Chunk("Nom: " + util.getOrdreMission().getNomMissionnaire() + "\n" + "Prenom: "
                        + util.getOrdreMission().getPrenomMissionnaire() + "\n\n" + "Courriel: "
                        + util.getOrdreMission().getEmailMissionnaire(), fontItemSection)));
        nomCell.setBorder(Rectangle.NO_BORDER);
        tableIdentite.addCell(nomCell);

        Chunk adresseChunk = new Chunk("Adresse: " + "\n" + util.getOrdreMission().getRueMissionnaire() + "\n"
                + util.getOrdreMission().getCodepostalMissionnaire() + " "
                + util.getOrdreMission().getVilleMissionnaire() + "\n"
                + util.getOrdreMission().getPaysMissionnaire(), fontItemSection);
        PdfPCell adresseCell = new PdfPCell(new Phrase(adresseChunk));
        adresseCell.setBorder(Rectangle.NO_BORDER);
        tableIdentite.addCell(adresseCell);

        Paragraph identite;
        identite = new Paragraph();
        addEmptyLine(identite, 1);
        identite.add(tableIdentite);
        document.add(identite);
        //
        // Numero IBAN
        //
        Paragraph iban = new Paragraph();
        addEmptyLine(iban, 1);
        iban.add(new Chunk("Numro IBAN: " + util.getOrdreMission().getIban1() + " "
                + util.getOrdreMission().getIban2() + " " + util.getOrdreMission().getIban3() + " "
                + util.getOrdreMission().getIban4() + " " + util.getOrdreMission().getIban5() + " "
                + util.getOrdreMission().getIban6() + " " + util.getOrdreMission().getIban7(),
                fontItemSection));
        document.add(iban);
        //
        // Motif de la mission
        //
        Paragraph mission = new Paragraph();
        addEmptyLine(mission, 1);
        mission.add(
                new Chunk("Motif de la mission: " + util.getOrdreMission().getMotifMission(), fontItemSection));
        addEmptyLine(mission, 1);
        //
        // Dtails de la mission (lieu, dates, ...)
        //
        PdfPTable tableMission = new PdfPTable(7);
        tableMission.setWidthPercentage(100);
        float[] columnWidths = { 1f, 2f, 1.5f, 1f, 2f, 1.5f, 1f };
        tableMission.setWidths(columnWidths);
        PdfPCell cell;
        //
        // Ligne d'entete du tableau des dtails de la mission
        //
        tableMission.addCell("");
        cell = new PdfPCell(new Phrase("Lieu de dpart"));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        tableMission.addCell(cell);
        cell = new PdfPCell(new Phrase("Date"));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        tableMission.addCell(cell);
        cell = new PdfPCell(new Phrase("Heure"));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        tableMission.addCell(cell);
        cell = new PdfPCell(new Phrase("Lieu d'arrive"));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        tableMission.addCell(cell);
        cell = new PdfPCell(new Phrase("Date"));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        tableMission.addCell(cell);
        cell = new PdfPCell(new Phrase("Heure"));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        tableMission.addCell(cell);
        //
        // description du voyage aller
        //
        tableMission.addCell("Aller");
        cell = new PdfPCell(new Phrase(util.getOrdreMission().getLieuDepartAller()));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        tableMission.addCell(cell);
        cell = new PdfPCell(new Phrase(util.getOrdreMission().getDateDepartAller()));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        tableMission.addCell(cell);
        cell = new PdfPCell(new Phrase(util.getOrdreMission().getHeureDepartAller() + ":"
                + util.getOrdreMission().getMinuteDepartAller()));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        tableMission.addCell(cell);
        cell = new PdfPCell(new Phrase(util.getOrdreMission().getLieuArriveeAller()));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        tableMission.addCell(cell);
        cell = new PdfPCell(new Phrase(util.getOrdreMission().getDateArriveeAller()));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        tableMission.addCell(cell);
        cell = new PdfPCell(new Phrase(util.getOrdreMission().getHeureArriveeAller() + ":"
                + util.getOrdreMission().getMinuteArriveeAller()));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        tableMission.addCell(cell);

        //
        // Description du voyage retour
        //                
        tableMission.addCell("Retour");
        cell = new PdfPCell(new Phrase(util.getOrdreMission().getLieuDepartRetour()));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        tableMission.addCell(cell);
        cell = new PdfPCell(new Phrase(util.getOrdreMission().getDateDepartRetour()));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        tableMission.addCell(cell);
        cell = new PdfPCell(new Phrase(util.getOrdreMission().getHeureDepartRetour() + ":"
                + util.getOrdreMission().getMinuteDepartRetour()));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        tableMission.addCell(cell);
        cell = new PdfPCell(new Phrase(util.getOrdreMission().getLieuArriveeRetour()));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        tableMission.addCell(cell);
        cell = new PdfPCell(new Phrase(util.getOrdreMission().getDateArriveeRetour()));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        tableMission.addCell(cell);
        cell = new PdfPCell(new Phrase(util.getOrdreMission().getHeureArriveeRetour() + ":"
                + util.getOrdreMission().getMinuteArriveeRetour()));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        tableMission.addCell(cell);

        mission.add(tableMission);
        document.add(mission);
        //
        // Moyens de transport
        //
        Paragraph moyensTransport = new Paragraph();
        addEmptyLine(moyensTransport, 1);
        moyensTransport.add(new Chunk("Moyens de transport utiliss\n", fontTitleSection));
        if (util.use("Passager")) {
            moyensTransport.add(new Chunk("Pas de frais de transport comme passager de la voiture de: "
                    + util.getOrdreMission().getNomConducteur() + "\n", fontItemSection));
        }
        if (util.use("Train")) {
            moyensTransport.add(new Chunk("Train:   Classe: " + util.getOrdreMission().getTrainClasse()
                    + "   Prix des billets: " + util.getOrdreMission().getTrainPrixBillet()
                    + "    Bon de commande: " + util.getOrdreMission().getTrainBonCommande()
                    + "   Carte affaire: " + util.getOrdreMission().getTrainCarteAffaire() + "\n",
                    fontItemSection));
        }
        if (util.use("Avion_Bateau")) {
            moyensTransport.add(new Chunk(
                    "Avion ou Bateau:   Classe: " + util.getOrdreMission().getAvionBateauClasse()
                            + "   Prix des billets: " + util.getOrdreMission().getAvionBateauPrixBillet()
                            + "   Bon de commande: " + util.getOrdreMission().getAvionBateauBonCommande()
                            + "   Carte affaire: " + util.getOrdreMission().getAvionBateauCarteAffaire() + "\n",
                    fontItemSection));
        }
        if (util.use("Vehicule_Service")) {
            moyensTransport.add(new Chunk(
                    "Voiture de service: " + util.getOrdreMission().getVehiculeService()
                            + "  Nombre de kilomtres: "
                            + util.getOrdreMission().getVehiculeServiceNombreKilometres() + "\n",
                    fontItemSection));
            moyensTransport.add(new Chunk(
                    "Nom des passagers: " + util.getOrdreMission().getVehiculeServiceNomPassagers() + "\n",
                    fontItemSection));
        }
        if (util.use("Vehicule_Personnel")) {
            moyensTransport.add(new Chunk(
                    "En vertu du dcret No 2006-781 du 3 juillet 2006: je soussign, "
                            + util.getOrdreMission().getPrenomMissionnaire() + " "
                            + util.getOrdreMission().getNomMissionnaire() + ", sollicite l'autorisation ",
                    fontItemSection));
            moyensTransport.add(new Chunk("d'utiliser mon vhicule de marque "
                    + util.getOrdreMission().getVehiculePersonnelMarque() + ", de puissance "
                    + util.getOrdreMission().getVehiculePersonnelPuissance() + ", d'immatriculation: "
                    + util.getOrdreMission().getVehiculePersonnelImmatriculation(), fontItemSection));
            moyensTransport.add(new Chunk(
                    ", de date d'acquisition " + util.getOrdreMission().getVehiculePersonnelDateAcquisition()
                            + " pour me rendre  " + util.getOrdreMission().getLieuArriveeAller(),
                    fontItemSection));
            moyensTransport.add(new Chunk(" et dclare avoir souscrit auprs de "
                    + util.getOrdreMission().getVehiculePersonnelNomAssureur()
                    + " une police d'assurance garantissant de manire illimite ma responsabilit personnelle aux termes ",
                    fontItemSection));
            moyensTransport.add(new Chunk(
                    "des articles 1382, 1383, 1384 du Code Civil, ainsi qu'ventuellement la responsabilit de l'Etat, y compris le cas o celle-ci est engage vis--vis des personnes transportes. ",
                    fontItemSection));
            moyensTransport
                    .add(new Chunk("Cette police comprend l'assurance contentieuse.\n", fontItemSection));
            moyensTransport.add(new Chunk(
                    "DECLARATION COMPLEMENTAIRE: je certifie avoir contract l'assurance complmentaire couvrant tous les risques non compris dans l'assurance obligatoire.\n",
                    fontItemSection));
        }
        addEmptyLine(moyensTransport, 1);
        if (util.use("taxi")) {
            moyensTransport.add(
                    new Chunk("Le Directeur autorise le remboursement d'un taxi " + "\n", fontItemSection));
        }
        if (util.use("vehicule_location")) {
            moyensTransport
                    .add(new Chunk("Le Directeur autorise le remboursement d'un vhicule de location " + "\n",
                            fontItemSection));
        }
        if (util.use("Vehicule_Service") || util.use("Vehicule_Personnel") || util.use("vehicule_location")) {
            moyensTransport
                    .add(new Chunk(
                            "\nJustication de l'utilisation du vhicule personnel ou de la location:"
                                    + util.getOrdreMission().getVehiculeJustificatif() + "\n",
                            fontItemSection));
            moyensTransport.add(
                    new Chunk("\nJe certifie tre en possession du permis de conduire depuis plus d'un an\n",
                            fontBoldItemSection));
        }

        document.add(moyensTransport);
        //
        // Frais annexe
        //
        Paragraph fraisAnnexe = new Paragraph();
        addEmptyLine(fraisAnnexe, 1);
        fraisAnnexe.add(new Chunk("Frais Annexe\n", fontTitleSection));
        fraisAnnexe.add(new Chunk("Frais d'inscription: " + util.getOrdreMission().getFraisInscription()
                + "    Montant: " + util.getOrdreMission().getMontantInscription() + " ", fontItemSection));
        document.add(fraisAnnexe);

        Paragraph avance = new Paragraph();
        addEmptyLine(avance, 1);
        avance.add(new Chunk("Avance: ", fontTitleSection));
        avance.add(new Chunk(util.getOrdreMission().getAvance(), fontItemSection));
        document.add(avance);
        //
        // Informations financieres
        //
        Paragraph finance = new Paragraph();
        addEmptyLine(finance, 1);
        finance.add(new Chunk("Informations financires\n", fontTitleSection));
        finance.add(new Chunk("Centre financier: " + util.getOrdreMission().getCentreFinancier()
                + "   Projet ou eOTP: " + util.getOrdreMission().getProjet() + "\n", fontItemSection));
        finance.add(new Chunk("Responsable financier: " + util.getOrdreMission().getPrenomResponsableFinancier()
                + " " + util.getOrdreMission().getNomResponsableFinancier() + "\n", fontItemSection));
        finance.add(
                new Chunk("Autorit hirarchique: " + util.getOrdreMission().getPrenomAutoriteHierarchique()
                        + " " + util.getOrdreMission().getNomAutoriteHierarchique(), fontItemSection));
        document.add(finance);
        //
        // Informations complementaires eventuelles
        //              
        if (util.getOrdreMission().getInformationsComplementaires() != null) {
            Paragraph informationsComplementaires = new Paragraph();
            informationsComplementaires.add(new Chunk("\nInformations complementaires: ", fontTitleSection));
            informationsComplementaires
                    .add(new Chunk(util.getOrdreMission().getInformationsComplementaires(), fontItemSection));
            document.add(informationsComplementaires);
        }

        document.close();
        file.close();
    } catch (DocumentException | IOException e) {
        System.err
                .println("Erreur a la generation du fichier " + util.getPdfFileName() + ": " + e.getMessage());
    }
}

From source file:fr.pigouchet.gestion.util.GeneratePdf.java

public static PdfPTable oneCategory(Categorie category) throws DocumentException {
    PdfPTable table = new PdfPTable(5);

    table.setWidthPercentage(100);//  w w  w . j a  v  a  2s  .c om
    table.setWidths(new int[] { 1, 2, 1, 1, 1 });

    dataSubCate = Connection.listCategoryToSubCategory(category);
    for (SubCategorie subcategorie : dataSubCate) {
        PdfPCell cell;
        if (passed == true) {
            cell = new PdfPCell(new Phrase(" "));
            cell.setColspan(5);
            table.addCell(cell);
        }

        cell = new PdfPCell(new Phrase(category.getNom(), subFont));
        cell.setColspan(1);
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        table.addCell(cell);

        cell = new PdfPCell(new Phrase(subcategorie.getNom(), subFont));
        cell.setColspan(5);
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        table.addCell(cell);

        cell = new PdfPCell(new Phrase("Code", smallFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        table.addCell(cell);
        cell = new PdfPCell(new Phrase("Nom", smallFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        table.addCell(cell);
        cell = new PdfPCell(new Phrase("Achat", smallFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        table.addCell(cell);
        cell = new PdfPCell(new Phrase("Artisant", smallFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        table.addCell(cell);
        cell = new PdfPCell(new Phrase("Detail", smallFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        table.addCell(cell);

        data = Connection.listSubCategoryToProduit(subcategorie);

        for (Produit produit1 : data) {
            cell = new PdfPCell(new Phrase(produit1.getCode(), smallFont));
            table.addCell(cell);
            cell = new PdfPCell(new Phrase(produit1.getNom(), smallFont));
            table.addCell(cell);
            cell = new PdfPCell(new Phrase(produit1.getPriceAchat(), smallFont));
            table.addCell(cell);
            cell = new PdfPCell(new Phrase(produit1.getPriceArtisant(), smallFont));
            table.addCell(cell);
            cell = new PdfPCell(new Phrase(produit1.getPriceDetail(), smallFont));
            table.addCell(cell);
        }
        passed = true;
    }

    return table;
}

From source file:fr.pigouchet.gestion.util.GeneratePdf.java

public static PdfPTable allSubCategory(Categorie categorie, Document document) throws DocumentException {
    PdfPTable table = new PdfPTable(5);

    table.setWidthPercentage(100);//from w  w  w  . ja  v  a  2  s  .c om
    table.setWidths(new int[] { 1, 2, 1, 1, 1 });

    dataSubCate = Connection.listCategoryToSubCategory(categorie);
    for (SubCategorie subcategorie : dataSubCate) {
        PdfPCell cell;
        if (passed == true) {
            cell = new PdfPCell(new Phrase(" "));
            cell.setColspan(5);
            table.addCell(cell);
        }

        cell = new PdfPCell(new Phrase(categorie.getNom(), subFont));
        cell.setColspan(1);
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        table.addCell(cell);

        cell = new PdfPCell(new Phrase(subcategorie.getNom(), subFont));
        cell.setColspan(5);
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        table.addCell(cell);

        cell = new PdfPCell(new Phrase("Code", smallFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        table.addCell(cell);
        cell = new PdfPCell(new Phrase("Nom", smallFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        table.addCell(cell);
        cell = new PdfPCell(new Phrase("Achat", smallFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        table.addCell(cell);
        cell = new PdfPCell(new Phrase("Artisant", smallFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        table.addCell(cell);
        cell = new PdfPCell(new Phrase("Detail", smallFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        table.addCell(cell);

        data = Connection.listSubCategoryToProduit(subcategorie);

        for (Produit produit1 : data) {
            cell = new PdfPCell(new Phrase(produit1.getCode(), smallFont));
            table.addCell(cell);
            cell = new PdfPCell(new Phrase(produit1.getNom(), smallFont));
            table.addCell(cell);
            cell = new PdfPCell(new Phrase(produit1.getPriceAchat(), smallFont));
            table.addCell(cell);
            cell = new PdfPCell(new Phrase(produit1.getPriceArtisant(), smallFont));
            table.addCell(cell);
            cell = new PdfPCell(new Phrase(produit1.getPriceDetail(), smallFont));
            table.addCell(cell);
        }
        passed = true;
    }
    return table;
}

From source file:frames.main.java

private void jButton7ActionPerformed(java.awt.event.ActionEvent evt) {
    if (PRINTMODE.getSelectedIndex() == 0) {
        try {/*ww w  .  j ava2  s  .  c  om*/

            //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 {/*from 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:
}