Example usage for com.itextpdf.text PageSize A4

List of usage examples for com.itextpdf.text PageSize A4

Introduction

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

Prototype

Rectangle A4

To view the source code for com.itextpdf.text PageSize A4.

Click Source Link

Document

This is the a4 format

Usage

From source file:Main_Frame.java

private void jMenuItem29ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem29ActionPerformed
    try {//from  w ww  .j  a  va2s .c  o  m
        Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
        Connection con1 = DriverManager.getConnection("jdbc:odbc:College");
        Statement stm1 = con1.createStatement();
        //Statement stm1 = con1.createStatement();
        ResultSet rs = stm1.executeQuery("SELECT * from Slot_Details");
        //ResultSet rs1 = stm2.executeQuery("SELECT * from Slot_Details");
        String[] start = new String[10];
        String[] end = new String[10];
        int line = 0;
        while (rs.next()) {

            start[line] = rs.getString("START");
            end[line] = rs.getString("END");
            line++;
        }

        /*   try{
        Class.forName ("sun.jdbc.odbc.JdbcOdbcDriver"); 
        Connection con2=DriverManager.getConnection("jdbc:odbc:College");*/
        Statement stm2 = con1.createStatement();
        ResultSet query_set = stm2.executeQuery("SELECT * from format");
        /* Step-2: Initialize PDF documents - logical objects */
        Document my_pdf_report = new Document(PageSize.A4);
        PdfWriter.getInstance(my_pdf_report, new FileOutputStream("C:\\Users\\Durga\\Desktop\\Time_Table.pdf"));
        my_pdf_report.open();
        //we have four columns in our table

        PdfPTable table = new PdfPTable(10);
        //table.setWidthPercentage(100);
        //          table.getDefaultCell().setBorder(Rectangle.NO_BORDER);
        table.getDefaultCell().setHorizontalAlignment(Element.ALIGN_CENTER);

        String a[] = { "//////", "//////", "//////", "//////", "//////", "//////", "//////", "//////", "L", "U",
                "N", "C", "H", "//////", "//////", "//////", "//////", "//////", "//////" };

        int len = 1;
        table.addCell("Day");

        table.addCell("Branch");

        String s;

        for (int i = 0; i < line; i++) {
            int j = i;
            if (i == 5)
                table.addCell(a[0]);
            if (i >= 5)
                j = line - 1;
            table.addCell("Period" + (i) + " \n[" + start[j] + "-" + end[j] + "]");

        }

        table.getDefaultCell().setFixedHeight(70);
        table.getDefaultCell().setVerticalAlignment(Element.ALIGN_MIDDLE);
        while (query_set.next()) {
            String Day = query_set.getString("Day");
            table.addCell(Day);

            String Branch = query_set.getString("Branch");
            table.addCell(Branch);

            for (int i = 0; i < line; i++) {
                if (i == 5) {
                    table.addCell(a[len++]);

                    table.addCell(query_set.getString("slot" + (i + 1)) + "G1");
                } else if (i == 6) {
                    table.addCell(query_set.getString("slot" + (i + 1)) + "G2");
                } else
                    table.addCell(query_set.getString("slot" + (i + 1)));

            }
        }

        /* Attach report table to PDF */
        // my_pdf_report.add(my_report_table);  
        my_pdf_report.add(table);
        my_pdf_report.close();

        /* Close all DB related objects */
        query_set.close();
        stm2.close();
        //con2.close();     
        // }
        /*  catch(Exception e)
           {
           System.out.println(e);
            }*/
        stm1.close();
        con1.close();
    } catch (Exception e) {
        System.out.println(e);
    }

    if (Desktop.isDesktopSupported()) //Open pdf file
    {
        try {
            File myFile = new File("C:\\Users\\Durga\\Desktop\\Time_Table.pdf");
            Desktop.getDesktop().open(myFile);
        } catch (Exception ex) {
            System.out.println(ex);
        }
        //System.out.println(ex);
    }
}

From source file:JT.java

private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton3ActionPerformed
    String pa = "H? v tn         : L Ng?c Long\n" + "MSSV                : 20142659\n"
            + "?? ti               : Xy dng chng trnh qun l th vin";
    pa += "\n\nTr?ng ?i H?c Bch Khoa H Ni          Cng Ha - X Hi - Ch Ngha - Vit Nam\n"
            + "      Th vin T Quang Bu                              ?c Lp - T Do - Hnh Phc";
    pa += "\n\n                                         TM KIM S?CH THEO xxx";
    //Model.ThuVien.xuatFilePDF(RESULT,jTable1, "tieu d? nononoo ch",PageSize.A4);
    String[] tenCot = new String[] { "Name", "Position", "Team" };
    String af = "H Ni, Vit Nam Ngy " + Model.ThuVien.getTodayNgayThangNam() + "\n"
            + "Ng?i to bng : L Ng?c Long";
    Model.ThuVien.xuatFilePDF2(RESULT, pa, tenCot, af, jTable1, "tieu d? nononoo ch", PageSize.A4);
}

From source file:FullPageTable.java

public void createPdf(String dest) throws IOException, DocumentException {
    Document document = new Document(PageSize.A4, 0, 0, 0, 0);
    PdfWriter.getInstance(document, new FileOutputStream(dest));
    document.open();//  w  w  w  .  j a v a2  s.  c  om
    PdfPTable table = new PdfPTable(10);

    table.setWidthPercentage(100);
    table.setSpacingBefore(0f);
    table.setSpacingAfter(0f);

    // first row
    PdfPCell cell = new PdfPCell(new Phrase("DateRange"));
    cell.setColspan(10);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER);
    cell.setPadding(10.0f);
    cell.setBackgroundColor(new BaseColor(140, 221, 8));
    table.addCell(cell);

    table.addCell("Calldate");
    table.addCell("Calltime");
    table.addCell("Source");
    table.addCell("DialedNo");
    table.addCell("Extension");
    table.addCell("Trunk");
    table.addCell("Duration");
    table.addCell("Calltype");
    table.addCell("Callcost");
    table.addCell("Site");

    for (int i = 0; i < 100; i++) {
        table.addCell("date" + i);
        table.addCell("time" + i);
        table.addCell("source" + i);
        table.addCell("destination" + i);
        table.addCell("extension" + i);
        table.addCell("trunk" + i);
        table.addCell("dur" + i);
        table.addCell("toc" + i);
        table.addCell("callcost" + i);
        table.addCell("Site" + i);
    }
    document.add(table);
    document.close();
}

From source file:imprimer.java

public void openPDF() {

    Document document = new Document(PageSize.A4);
    try {/* w  w w.j  a  v a 2s.c om*/
        PdfWriter.getInstance(document, new FileOutputStream("imprimer test.pdf"));

        document.open();

        imagee(document);

        SimpleDateFormat td = new SimpleDateFormat("dd-MM-yyyy");
        java.util.Date now = new java.util.Date();
        String tdnow = td.format(now);
        Paragraph pa = new Paragraph("Attestation de travail",
                FontFactory.getFont(FontFactory.TIMES, 30, Font.UNDERLINE, BaseColor.DARK_GRAY));
        pa.setAlignment(Paragraph.ALIGN_CENTER);
        document.add(pa);
        for (int i = 0; i < 3; i++) {
            document.add(new Paragraph(" "));
        }

        Paragraph p = new Paragraph(text,
                FontFactory.getFont(FontFactory.TIMES, 16, Font.NORMAL, BaseColor.DARK_GRAY));
        document.add(p);

        Paragraph time = new Paragraph("                Fait  Ouarzazate le : " + tdnow,
                FontFactory.getFont(FontFactory.TIMES, 17, Font.BOLD, BaseColor.DARK_GRAY));
        Paragraph a = new Paragraph("");
        Paragraph si = new Paragraph("                 Signature:",
                FontFactory.getFont(FontFactory.TIMES, 17, Font.BOLD, BaseColor.DARK_GRAY));

        time.setAlignment(Paragraph.ALIGN_CENTER);
        si.setAlignment(Paragraph.ALIGN_CENTER);
        document.add(time);
        document.add(si);
        document.add(a);
        document.close();

        System.out.println("date2");
        /* Open Pdf */
        Desktop desktop = Desktop.getDesktop();
        if (desktop.isSupported(Desktop.Action.OPEN)) {
            desktop.open(new File("imprimer test.pdf"));
        } else {
            System.out.println("Open is not supported");
        }

        System.out.println("date");

    } catch (Exception ex) {
        System.out.println("qsdqs");
    }
}

From source file:imprimer.java

public void attestation_travail_prof() {

    Document document = new Document(PageSize.A4);
    try {// w  w  w. j  a  v  a 2  s.c om
        PdfWriter.getInstance(document, new FileOutputStream("Attestation de travail Professeur.pdf"));
        document.open();

        imagee(document);
        SimpleDateFormat td = new SimpleDateFormat("dd-MM-yyyy");
        java.util.Date now = new java.util.Date();
        String tdnow = td.format(now);
        Paragraph pa = new Paragraph("Attestation de travail",
                FontFactory.getFont(FontFactory.TIMES, 30, Font.UNDERLINE, BaseColor.DARK_GRAY));
        pa.setAlignment(Paragraph.ALIGN_CENTER);
        document.add(pa);
        for (int i = 0; i < 3; i++) {
            document.add(new Paragraph(" "));
        }

        Paragraph p = new Paragraph(text3,
                FontFactory.getFont(FontFactory.TIMES, 16, Font.NORMAL, BaseColor.DARK_GRAY));
        document.add(p);

        Paragraph time = new Paragraph("                Fait  Ouarzazate le : " + tdnow,
                FontFactory.getFont(FontFactory.TIMES, 17, Font.BOLD, BaseColor.DARK_GRAY));
        Paragraph a = new Paragraph("");
        Paragraph si = new Paragraph("                 Signature:",
                FontFactory.getFont(FontFactory.TIMES, 17, Font.BOLD, BaseColor.DARK_GRAY));

        time.setAlignment(Paragraph.ALIGN_CENTER);
        si.setAlignment(Paragraph.ALIGN_CENTER);
        document.add(time);
        document.add(si);
        document.add(a);
        document.close();

        System.out.println("date2");
        /* Open Pdf */
        Desktop desktop = Desktop.getDesktop();
        if (desktop.isSupported(Desktop.Action.OPEN)) {
            desktop.open(new File("Attestation de travail Professeur.pdf"));
        } else {
            System.out.println("Open is not supported");
        }

        System.out.println("date");
    } catch (Exception ex) {

        System.out.println("qsdqs");
    }
}

From source file:imprimer.java

public void conje() {
    Document document = new Document(PageSize.A4);
    try {/*from www .jav  a  2 s. c om*/
        PdfWriter.getInstance(document, new FileOutputStream("conjee.pdf"));

        document.open();
        imagee(document);
        SimpleDateFormat td = new SimpleDateFormat("dd-MM-yyyy");
        java.util.Date now = new java.util.Date();
        String tdnow = td.format(now);
        Paragraph pa = new Paragraph("Dcision de cong",
                FontFactory.getFont(FontFactory.TIMES, 30, Font.UNDERLINE, BaseColor.DARK_GRAY));
        pa.setAlignment(Paragraph.ALIGN_CENTER);
        document.add(pa);
        for (int i = 0; i < 4; i++) {
            document.add(new Paragraph(" "));
        }

        Paragraph p = new Paragraph(text2,
                FontFactory.getFont(FontFactory.TIMES, 14, Font.NORMAL, BaseColor.DARK_GRAY));
        document.add(p);
        Paragraph p3 = new Paragraph("DECIDE :",
                FontFactory.getFont(FontFactory.TIMES, 14, Font.BOLD, BaseColor.DARK_GRAY));
        p3.setAlignment(Paragraph.ALIGN_CENTER);
        document.add(p3);
        Paragraph p4 = new Paragraph("ARTICLE I Un cong dun .",
                FontFactory.getFont(FontFactory.TIMES, 14, Font.BOLDITALIC, BaseColor.DARK_GRAY));
        document.add(p4);
        Paragraph p5 = new Paragraph(
                "           Est accord    :    \n" + "           C.I.N           :    \n"
                        + "           GRADE           :    \n" + "           Pour la priode :   ",
                FontFactory.getFont(FontFactory.TIMES, 15, Font.NORMAL, BaseColor.DARK_GRAY));
        document.add(p5);
        Paragraph p6 = new Paragraph("ARTICLE II",
                FontFactory.getFont(FontFactory.TIMES, 16, Font.BOLDITALIC, BaseColor.DARK_GRAY));
        document.add(p6);
        Paragraph p7 = new Paragraph(
                "Lintress(e) est autoris  quitter le territoire national durant la priode indique ci-dessus",
                FontFactory.getFont(FontFactory.TIMES, 18, Font.NORMAL, BaseColor.DARK_GRAY));
        document.add(p7);
        Paragraph p8 = new Paragraph("ARTICLE III",
                FontFactory.getFont(FontFactory.TIMES, 16, Font.BOLDITALIC, BaseColor.DARK_GRAY));
        document.add(p8);
        Paragraph p9 = new Paragraph(
                "Lintress(e) est tenu daviser le service du personnel de sa reprise de travail aprs expiration du  cong sus-vis.",
                FontFactory.getFont(FontFactory.TIMES, 18, Font.NORMAL, BaseColor.DARK_GRAY));
        document.add(p9);
        for (int i = 0; i < 4; i++) {
            document.add(new Paragraph(" "));
        }

        Paragraph time = new Paragraph(
                "             Cachet et signature                                        Fait  Ouarzazate le :"
                        + tdnow + "\n" + "\n",
                FontFactory.getFont(FontFactory.TIMES, 14, Font.BOLD, BaseColor.DARK_GRAY));

        Paragraph si = new Paragraph("Signature du demandeur",
                FontFactory.getFont(FontFactory.TIMES, 14, Font.BOLD, BaseColor.DARK_GRAY));
        time.setAlignment(Paragraph.ALIGN_LEFT);
        si.setAlignment(Paragraph.ALIGN_RIGHT);
        document.add(time);
        document.add(si);
        document.close();

        System.out.println("date2");
        /* Open Pdf */
        Desktop desktop = Desktop.getDesktop();
        if (desktop.isSupported(Desktop.Action.OPEN)) {
            desktop.open(new File("conjee.pdf"));
        } else {
            System.out.println("Open is not supported");
        }

        System.out.println("date");
    } catch (Exception ex) {

        System.out.println("qsdqs");
    }
}

From source file:imprimer.java

public void conje_exp() {
    Document document = new Document(PageSize.A4);
    try {/*from   w  w  w  .ja v  a2 s.  c o  m*/
        PdfWriter.getInstance(document, new FileOutputStream("conjee_exp.pdf"));

        document.open();
        imagee(document);
        SimpleDateFormat td = new SimpleDateFormat("dd-MM-yyyy");
        java.util.Date now = new java.util.Date();
        String tdnow = td.format(now);
        Paragraph pa = new Paragraph("Dcision de cong",
                FontFactory.getFont(FontFactory.TIMES, 30, Font.UNDERLINE, BaseColor.DARK_GRAY));
        pa.setAlignment(Paragraph.ALIGN_CENTER);
        document.add(pa);
        for (int i = 0; i < 4; i++) {
            document.add(new Paragraph(" "));
        }

        Paragraph p = new Paragraph(text2,
                FontFactory.getFont(FontFactory.TIMES, 14, Font.NORMAL, BaseColor.DARK_GRAY));
        document.add(p);
        Paragraph p3 = new Paragraph("DECIDE :",
                FontFactory.getFont(FontFactory.TIMES, 14, Font.BOLD, BaseColor.DARK_GRAY));
        p3.setAlignment(Paragraph.ALIGN_CENTER);
        document.add(p3);
        Paragraph p4 = new Paragraph("ARTICLE I",
                FontFactory.getFont(FontFactory.TIMES, 14, Font.BOLDITALIC, BaseColor.DARK_GRAY));
        document.add(p4);
        Paragraph p5 = new Paragraph(
                "           Un cong Exceptionnel dune dure de jours\n"
                        + "           Est accord    :    \n" + "           C.I.N           :    \n"
                        + "           GRADE           :    \n" + "           Pour la priode :   ",
                FontFactory.getFont(FontFactory.TIMES, 15, Font.NORMAL, BaseColor.DARK_GRAY));
        document.add(p5);
        Paragraph p6 = new Paragraph("ARTICLE II",
                FontFactory.getFont(FontFactory.TIMES, 16, Font.BOLDITALIC, BaseColor.DARK_GRAY));
        document.add(p6);
        Paragraph p7 = new Paragraph(
                "Lintress(e) est autoris  quitter le territoire national durant la priode indique ci-dessus",
                FontFactory.getFont(FontFactory.TIMES, 18, Font.NORMAL, BaseColor.DARK_GRAY));
        document.add(p7);
        Paragraph p8 = new Paragraph("ARTICLE III",
                FontFactory.getFont(FontFactory.TIMES, 16, Font.BOLDITALIC, BaseColor.DARK_GRAY));
        document.add(p8);
        Paragraph p9 = new Paragraph(
                "Lintress(e) est tenu daviser le service du personnel de sa reprise de travail aprs expiration du  cong sus-vis.",
                FontFactory.getFont(FontFactory.TIMES, 18, Font.NORMAL, BaseColor.DARK_GRAY));
        document.add(p9);
        for (int i = 0; i < 4; i++) {
            document.add(new Paragraph(" "));
        }

        Paragraph time = new Paragraph(
                "             Cachet et signature                                        Fait  Ouarzazate le :"
                        + tdnow + "\n" + "\n",
                FontFactory.getFont(FontFactory.TIMES, 14, Font.BOLD, BaseColor.DARK_GRAY));

        Paragraph si = new Paragraph("Signature du demandeur",
                FontFactory.getFont(FontFactory.TIMES, 14, Font.BOLD, BaseColor.DARK_GRAY));
        time.setAlignment(Paragraph.ALIGN_LEFT);
        si.setAlignment(Paragraph.ALIGN_RIGHT);
        document.add(time);
        document.add(si);
        document.close();

        System.out.println("date2");
        /* Open Pdf */
        Desktop desktop = Desktop.getDesktop();
        if (desktop.isSupported(Desktop.Action.OPEN)) {
            desktop.open(new File("conjee_exp.pdf"));
        } else {
            System.out.println("Open is not supported");
        }

        System.out.println("date");
    } catch (Exception ex) {

        System.out.println("qsdqs");
    }
}

From source file:imprimer.java

public void quitter_territoire() {

    Document document = new Document(PageSize.A4);
    try {/*w  ww .  java  2 s  .  c  om*/
        PdfWriter.getInstance(document, new FileOutputStream("quitter territoire.pdf"));

        document.open();
        imagee(document);

        document.open();
        imagee(document);
        SimpleDateFormat td = new SimpleDateFormat("dd-MM-yyyy");
        java.util.Date now = new java.util.Date();
        String tdnow = td.format(now);
        Paragraph pa = new Paragraph("Autorisation de quitter le territoire",
                FontFactory.getFont(FontFactory.TIMES, 30, Font.UNDERLINE, BaseColor.DARK_GRAY));
        pa.setAlignment(Paragraph.ALIGN_CENTER);
        document.add(pa);
        for (int i = 0; i < 4; i++) {
            document.add(new Paragraph(" "));
        }

        //      cell = new PdfPCell(new Phrase("Fusion de 2 cellules de la premire colonne"));
        //      cell.setRowspan(2);
        //      table.addCell(cell);
        PdfPTable table = new PdfPTable(2);
        PdfPCell cell = new PdfPCell();
        //contenu du tableau.
        table.addCell("\nNom:\n\n");
        table.addCell("\n\n");
        table.addCell("\nPrenom:\n\n");
        table.addCell("\n\n");
        table.addCell("\nGRADE :\n\n");
        table.addCell("\n\n");
        table.addCell("\nADRESSE PERSONNELLE :\n\n");
        table.addCell("\n\n");
        table.addCell("\nAFFECTATION :\n\n");
        table.addCell("\n\n");

        cell = new PdfPCell(
                new Phrase("\nJai  lhonneur de solliciter une autorisation  dabsence.\n\n"));
        cell.setColspan(2);
        table.addCell(cell);

        table.addCell("\nDU:\n\n");
        table.addCell("\n\n");
        table.addCell("\nAU:\n\n");
        table.addCell("\n\n");
        table.addCell("\nMOTIF :\n\n");
        table.addCell("\n\n");
        table.addCell("\nAVIS DU  CHEF \nDETABLISSEMENT:\n\n");
        table.addCell("\n\nFAVORABLE.def\n\n");
        cell = new PdfPCell(new Phrase("\nFait  Ouarzazate le :" + tdnow + "\n\n"));
        cell.setColspan(2);

        table.addCell(cell);
        table.addCell("Signature du  demandeur\n\n\n\n\n\n\n\n\n");
        table.addCell("Cachet  et  signature\n\n\n\n\n\n\n\n");
        document.add(table);
        document.close();
        Desktop desktop = Desktop.getDesktop();
        if (desktop.isSupported(Desktop.Action.OPEN)) {
            desktop.open(new File("quitter territoire.pdf"));
        } else {
            System.out.println("Open is not supported");
        }

    } catch (Exception ex) {
        System.out.print("catch");
    }
}

From source file:admission_form.FXMLController1.java

@FXML
private void doPrinting(ActionEvent event) {
    print_btn.setVisible(false);/*from  w  w w  .  ja  va 2  s.co  m*/
    back_btn.setVisible(false);
    Scene scene = print_btn.getScene();
    WritableImage snapshot = scene.snapshot(null);
    BufferedImage image = SwingFXUtils.fromFXImage(snapshot, null);
    File f = new File("test2.png");
    try {
        ImageIO.write(image, "png", f);
    } catch (IOException ex) {

    }
    Document document = new Document(PageSize.A4, 0, 0, 0, 0);
    try {
        PdfWriter.getInstance(document, new FileOutputStream("Image.pdf"));
        document.open();
        // BufferedImage img = ImageIO.read(new File("test1.png"));
        //File f = new File("test1.png");
        Image image1 = Image.getInstance("test2.png");
        document.add(image1);

        document.close();
    } catch (Exception e) {
        e.printStackTrace();
    }
    try {
        InputStream is = new BufferedInputStream(new FileInputStream("Image.pdf"));
        DocFlavor flavor = DocFlavor.INPUT_STREAM.PDF;
        PrintService service = PrintServiceLookup.lookupDefaultPrintService();
        DocPrintJob printJob = service.createPrintJob();
        printJob.addPrintJobListener(new JobCompleteMonitor());
        Doc doc = new SimpleDoc(is, flavor, null);
        PrintRequestAttributeSet attributes = new HashPrintRequestAttributeSet();
        //attributes.add(new Destination(new java.net.URI("file:/home/jayesh/NetBeansProjects/myFile.ps")));
        printJob.print(doc, attributes);
        //while(jobRunning)
        //{
        //    Thread.sleep(1000);
        //}
        is.close();
    } catch (Exception ex) {
    } finally {
        System.out.println("exiting");

    }
    System.out.println("Done");
    try {
        Class.forName("com.mysql.jdbc.Driver");
        Connection con = DriverManager.getConnection("jdbc:mysql://localhost/pro", username, password);
        String query = "insert into log values(?,?)";
        PreparedStatement ps = con.prepareStatement(query);
        ps.setString(1, getCurUser());
        Date date = new Date();
        SimpleDateFormat df = new SimpleDateFormat("dd/MM/YYYY HH:mm:ss");
        ps.setString(2, "Printed Admission Form Page2 at " + df.format(date));
        ps.executeUpdate();
    } catch (Exception ex) {
        ex.printStackTrace();
    }
    print_btn.setVisible(true);
    back_btn.setVisible(true);
}

From source file:admission_form.FXMLDocumentController.java

@FXML
private void doPrininting(ActionEvent event) {

    next.setVisible(false);// w w w  . java 2s  .  com
    print_btn.setVisible(false);
    Scene scene = print_btn.getScene();
    WritableImage snapshot = scene.snapshot(null);
    BufferedImage image = SwingFXUtils.fromFXImage(snapshot, null);
    File f = new File("test2.png");
    try {
        ImageIO.write(image, "png", f);
    } catch (IOException ex) {

    }
    Document document = new Document(PageSize.A4, 0, 0, 0, 0);
    try {
        PdfWriter.getInstance(document, new FileOutputStream("Image.pdf"));
        document.open();
        // BufferedImage img = ImageIO.read(new File("test1.png"));
        //File f = new File("test1.png");
        Image image1 = Image.getInstance("test2.png");
        document.add(image1);

        document.close();
    } catch (Exception e) {
        e.printStackTrace();
    }
    try {
        InputStream is = new BufferedInputStream(new FileInputStream("Image.pdf"));
        DocFlavor flavor = DocFlavor.INPUT_STREAM.PDF;
        PrintService service = PrintServiceLookup.lookupDefaultPrintService();
        DocPrintJob printJob = service.createPrintJob();
        printJob.addPrintJobListener(new JobCompleteMonitor());
        Doc doc = new SimpleDoc(is, flavor, null);
        PrintRequestAttributeSet attributes = new HashPrintRequestAttributeSet();
        //attributes.add(new Destination(new java.net.URI("file:/home/jayesh/NetBeansProjects/myFile.ps")));
        printJob.print(doc, attributes);
        //while(jobRunning)
        //{
        //    Thread.sleep(1000);
        //}
        is.close();
    } catch (Exception ex) {
    } finally {
        System.out.println("exiting");

    }
    System.out.println("Done");
    try {
        con1();
        Class.forName("com.mysql.jdbc.Driver");
        Connection con = DriverManager.getConnection("jdbc:mysql://localhost/pro", username, password);
        String query = "insert into log values(?,?)";
        PreparedStatement ps = con.prepareStatement(query);
        ps.setString(1, getCurUser());
        Date date = new Date();
        SimpleDateFormat df = new SimpleDateFormat("dd/MM/YYYY HH:mm:ss");
        ps.setString(2, "Printed Admission Form Page1 at " + df.format(date));
        ps.executeUpdate();

    } catch (Exception ex) {
        ex.printStackTrace();
    }
    next.setVisible(true);
    print_btn.setVisible(true);
}