Example usage for com.itextpdf.text FontFactory TIMES_BOLD

List of usage examples for com.itextpdf.text FontFactory TIMES_BOLD

Introduction

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

Prototype

String TIMES_BOLD

To view the source code for com.itextpdf.text FontFactory TIMES_BOLD.

Click Source Link

Document

This is a possible value of a base 14 type 1 font

Usage

From source file:EmployeeInfo.java

private void jButton5ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton5ActionPerformed
    String value1 = txt_empID.getText();
    String value2 = txt_firstName.getText();
    String value3 = txt_lastName.getText();
    String value4 = txt_age.getText();

    try {/*from   w w  w.  java2  s .  com*/
        Document document = new Document();
        PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("Report1.pdf"));
        document.open();
        //add barcode
        PdfContentByte CB = writer.getDirectContent();
        BarcodeEAN codEAN = new BarcodeEAN();
        codEAN.setCode("1234567891023"); //this value must be 13 digits
        Paragraph para = new Paragraph();
        document.add(new Paragraph("Barcode UDCA"));
        codEAN.setCodeType(BarcodeEAN.UPCA);
        codEAN.setCode("1098765432112");
        document.add(codEAN.createImageWithBarcode(CB, BaseColor.BLACK, BaseColor.BLACK));
        document.add(para);

        Image image = Image.getInstance("images/Cherry.png");
        document.add(new Paragraph("Image"));
        document.add(image);

        // write tile with style
        document.add(new Paragraph("Hello World",
                FontFactory.getFont(FontFactory.TIMES_BOLD, 18, Font.BOLD, BaseColor.RED)));
        // write date
        document.add(new Paragraph(new Date().toString()));
        document.add(new Paragraph("--------------------------------------------"));
        PdfPTable table = new PdfPTable(2);// 2 columns
        // set title , column sapn, aliignment,background color
        PdfPCell cell = new PdfPCell(new Paragraph("Title"));
        cell.setColspan(4);
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setBackgroundColor(BaseColor.BLUE);
        table.addCell(cell);
        // PdfPTable table = new PdfPTable(x); should add multiple of x
        table.addCell("EmployeeID");
        table.addCell(value1);
        table.addCell("Name");
        table.addCell(value2);
        table.addCell("Last Name");
        table.addCell(value3);
        table.addCell("Age");
        table.addCell(value4);
        document.add(table);
        List list = new List(true, 20);
        list.add("First Item");
        list.add("Second Item");
        list.add("Third Item");
        list.add("Fourth Item");
        document.add(list);
        document.close();
        JOptionPane.showMessageDialog(null, "Report saved");
    } catch (Exception e) {
        JOptionPane.showMessageDialog(null, e);
    }

}

From source file:ApplicationClasses.Reservation.ReservationInvoice.java

public void generatePDFinvoice(ReservationCustomer cus) throws Exception {

    SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");

    Calendar c = Calendar.getInstance();
    c.add(Calendar.DAY_OF_YEAR, 0);
    String date2 = dateFormat.format(c.getTime());

    Document doc = new Document();
    PdfWriter.getInstance(doc, new FileOutputStream(this.invoiceNo + ".pdf"));
    doc.open();/* w ww.  j  a v  a 2  s  .  co  m*/
    doc.add(new Paragraph("CREATE TOURS PVT LTD",
            FontFactory.getFont(FontFactory.TIMES_BOLD, 16, Font.BOLD, BaseColor.RED)));

    Paragraph p = new Paragraph();

    p.add("Reservation Invoice");
    p.add("\n INVOICE DATE : " + date2);

    p.setAlignment(Paragraph.ALIGN_CENTER);
    doc.add(p);
    doc.add(new Paragraph(cus.getCustomerName()));
    doc.add(new Paragraph(
            "-------------------------------------------------------------------------------------------------------------------------------"));
    //doc.add(new Paragraph("Deposit : " + this.deposit.toString() + "\t Resvation Start Date : " + this.reservationEndDate + "\t Reservation End Date : "+this.reservationEndDate  ));
    PdfPTable table = new PdfPTable(4);
    table.addCell("No");
    table.addCell("Description");
    table.addCell("VehicalRegNo");
    table.addCell("Price");
    for (int i = 0; i < invoiceDataArray.size(); i++) {
        Integer no = i + 1;

        table.addCell(no.toString());
        table.addCell(invoiceDataArray.get(i).getDescription());
        table.addCell(invoiceDataArray.get(i).getRegNo());
        table.addCell(invoiceDataArray.get(i).getPrice().toString());
    }
    doc.add(table);

    doc.add(new Paragraph("Total Cost :" + this.totalPrice.toString()));
    doc.add(new Paragraph("Deposit : " + this.deposit.toString()));
    doc.add(new Paragraph("Resvation Start Date : " + this.reservationStartDate));
    doc.add(new Paragraph("Reservation End Date : " + this.reservationEndDate));

    doc.close();
}

From source file:bemyguest.controller.ValidationResevation.java

@FXML
private void handleButtonValiderAction(ActionEvent event) throws FileNotFoundException, DocumentException {
    Resrevation e = tab_reservation.getSelectionModel().getSelectedItem();
    if (e == null) {

        Alert alert = new Alert(Alert.AlertType.WARNING);
        alert.setTitle("Warning Dialog");
        alert.setHeaderText(null);//from   w ww. ja v  a2  s.  c om
        alert.setContentText("selectionner un demande de  reservation a traiter svp!");

        alert.showAndWait();
        LoadData();
        setCellTable();
    }

    else {
        Alert alert = new Alert(Alert.AlertType.CONFIRMATION);
        alert.setTitle("Confiramtion");
        alert.setHeaderText(null);
        alert.setContentText("vous etes sur d'accepter cette demande de reservation");
        Optional<ButtonType> answer = alert.showAndWait();

        if (answer.get() == ButtonType.OK) {
            ResevationDAO dao = new ResevationDAO();
            if (dao.ajouter_Reservation(e)) {

                LoadData();
                setCellTable();

                alert.setTitle("Success Dialog");
                alert.setHeaderText(null);
                alert.setContentText("Demandes accepter avec success");

                alert.showAndWait();

                try {

                    Document d = new Document(PageSize.A4.rotate());
                    PdfWriter.getInstance(d, new FileOutputStream(e.getUser().getNom() + "Facture.pdf"));
                    d.open();

                    d.add(new Paragraph("BeMyGuest Facture :",
                            FontFactory.getFont(FontFactory.TIMES_BOLD, 18, Font.BOLD, BaseColor.RED)));
                    d.add(new Paragraph(new Date().toString()));
                    d.add(new Paragraph(
                            "-------------------------------------------------------------------------------------------------------------"));
                    d.add(new Paragraph("             "));
                    d.add(new Paragraph("             "));
                    PdfPTable pdt = new PdfPTable(7);
                    PdfPCell cell = new PdfPCell(new Paragraph("Composant de facture"));
                    cell.setColspan(7);
                    cell.setHorizontalAlignment(Element.ALIGN_CENTER);
                    cell.setBackgroundColor(BaseColor.RED);
                    pdt.addCell(cell);

                    pdt.addCell(new Paragraph("Nom:",
                            FontFactory.getFont(FontFactory.TIMES_BOLD, 8, Font.BOLD, BaseColor.BLACK)));
                    pdt.addCell(new Paragraph("Prenom:",
                            FontFactory.getFont(FontFactory.TIMES_BOLD, 8, Font.BOLD, BaseColor.BLACK)));
                    pdt.addCell(new Paragraph("Date Debut:",
                            FontFactory.getFont(FontFactory.TIMES_BOLD, 8, Font.BOLD, BaseColor.BLACK)));
                    pdt.addCell(new Paragraph("Date Fin:",
                            FontFactory.getFont(FontFactory.TIMES_BOLD, 8, Font.BOLD, BaseColor.BLACK)));
                    pdt.addCell(new Paragraph("nbre chambre:",
                            FontFactory.getFont(FontFactory.TIMES_BOLD, 8, Font.BOLD, BaseColor.BLACK)));
                    pdt.addCell(new Paragraph("nbre personne:",
                            FontFactory.getFont(FontFactory.TIMES_BOLD, 8, Font.BOLD, BaseColor.BLACK)));
                    pdt.addCell(new Paragraph("Prix:",
                            FontFactory.getFont(FontFactory.TIMES_BOLD, 8, Font.BOLD, BaseColor.BLACK)));
                    pdt.addCell(new Paragraph(e.getUserDemandant().getNom(),
                            FontFactory.getFont(FontFactory.TIMES_BOLD, 8, Font.BOLD, BaseColor.BLACK)));
                    pdt.addCell(new Paragraph(e.getUserDemandant().getPrenom(),
                            FontFactory.getFont(FontFactory.TIMES_BOLD, 8, Font.BOLD, BaseColor.BLACK)));
                    pdt.addCell(new Paragraph(e.getDateDebut().toString(),
                            FontFactory.getFont(FontFactory.TIMES_BOLD, 8, Font.BOLD, BaseColor.BLACK)));
                    pdt.addCell(new Paragraph(e.getDateFin().toString(),
                            FontFactory.getFont(FontFactory.TIMES_BOLD, 8, Font.BOLD, BaseColor.BLACK)));
                    pdt.addCell(e.getDateDebut().toString());

                    int nb = e.getPropriete().getNbrChambre();

                    float pr = e.getPropriete().getPrix();
                    int nbp = e.getPropriete().getNbrVoyageur();
                    pdt.addCell(new Paragraph(Integer.toString(nb),
                            FontFactory.getFont(FontFactory.TIMES_BOLD, 8, Font.BOLD, BaseColor.BLACK)));
                    pdt.addCell(new Paragraph(Integer.toString(nbp),
                            FontFactory.getFont(FontFactory.TIMES_BOLD, 8, Font.BOLD, BaseColor.BLACK)));
                    pdt.addCell(new Paragraph(Float.toString(pr),
                            FontFactory.getFont(FontFactory.TIMES_BOLD, 8, Font.BOLD, BaseColor.BLACK)));

                    pdt.addCell(Float.toString(pr));

                    d.add(pdt);
                    d.close();
                } catch (Exception b) {

                    JOptionPane.showMessageDialog(null, b);
                }
            } else {
                alert.setTitle("Error Dialog");
                alert.setHeaderText(null);
                alert.setContentText("Cette Propriete Reserver pendant cette date ");

                alert.showAndWait();

                LoadData();
                setCellTable();
            }
        }

        else {
            LoadData();
            setCellTable();
        }
    }

}

From source file:com.mx.ipn.clases.PDF.java

public void crearpdf(String nombre, String appat, String apmat)
        throws FileNotFoundException, DocumentException {
    // Creacion del documento con los margenes
    // Creacion del documento con los margenes
    Document document = new Document(PageSize.A4, 35, 30, 50, 50);
    try {/*from   w  w w .  j a va 2s .co  m*/

        // El archivo pdf que vamos a generar
        FileOutputStream fileOutputStream = new FileOutputStream("AvisoPrivacidad.pdf");

        // Obtener la instancia del PdfWriter
        PdfWriter.getInstance(document, fileOutputStream);

        // Abrir el documento
        document.open();

        // Crear las fuentes para el contenido y los titulos
        Font fontContenido = FontFactory.getFont(FontFactory.TIMES_ROMAN.toString(), 9, Font.NORMAL,
                BaseColor.DARK_GRAY);
        Font fontTitulos = FontFactory.getFont(FontFactory.TIMES_BOLD, 11, Font.UNDERLINE, BaseColor.DARK_GRAY);
        Font nomb = FontFactory.getFont(FontFactory.TIMES_BOLD, 9, Font.NORMAL, BaseColor.DARK_GRAY);

        // Creacion del parrafo
        Paragraph paragraph = new Paragraph();

        // Agregar un titulo con su respectiva fuente
        paragraph.add(new Phrase("Aviso de Privacidad", fontTitulos));
        paragraph.setAlignment(Element.ALIGN_CENTER);

        // Agregar saltos de linea
        paragraph.add(new Phrase(Chunk.NEWLINE));
        paragraph.add(new Phrase(Chunk.NEWLINE));

        // Agregar contenido con su respectiva fuente
        paragraph.add(new Phrase(
                "Con fundamento en los artculos 15, 16 y de acuerdo a lo Previsto en la Ley Federal de Proteccin de Datos"
                        + "Personales, hacemos de su conocimiento que ZERCHERS, S.A. de C.V., es una empresa legalmente"
                        + "constituido de conformidad con las leyes mexicanas, con domicilio en Av. Juan de Dios Btiz s/n, Gustavo"
                        + "A. Madero, Nueva Industrial Vallejo, 07700 Ciudad de Mxico; y como responsable del tratamiento de sus"
                        + "datos personales, del uso que se le d a los mismos y de su proteccin. Hace de su conocimiento que la"
                        + "informacin de nuestros clientes es tratada de forma estrictamente confidencial por lo que, al proporcionar"
                        + "sus datos personales. Estos sern utilizados nica y exclusivamente para los siguientes fines: "
                        + "Proveer los servicios y productos que ha solicitado; notificarle sobre nuevos servicios o productos que"
                        + "tengan relacin con los ya contratados o adquiridos; comunicarle sobre cambios en los mismos; evaluar la"
                        + "calidad de los servicios que brindamos; mantener actualizada nuestra base de datos con sus datos"
                        + "recientes y en general, para dar cumplimiento a las obligaciones que hemos contrado con usted.",
                fontContenido));

        paragraph.add(new Phrase(Chunk.NEWLINE));
        paragraph.add(new Phrase(
                " Para las finalidades antes mencionadas, requerimos obtener los siguientes datos personales:",
                fontContenido));
        paragraph.setAlignment(Element.ALIGN_JUSTIFIED);
        paragraph.add(new Phrase(Chunk.NEWLINE));
        paragraph.add(new Phrase(Chunk.NEWLINE));
        // Agregar el parrafo al documento
        document.add(paragraph);

        document.add(Tabla_Simple());
        paragraph = new Paragraph();
        paragraph.add(new Phrase(Chunk.NEWLINE));
        paragraph.add(new Phrase(Chunk.NEWLINE));

        paragraph.add(new Phrase(
                "Para prevenir el acceso no autorizado a sus datos personales y con el fin de asegurar que la informacin sea "
                        + "utilizada para los fines establecidos en este aviso de privacidad, hemos establecido diversos procedimientos"
                        + " con la finalidad de evitar el uso o divulgacin no autorizados de sus datos, permitindonos tratarlos debidamente."
                        + "  As mismo, le informamos que sus datos personales pueden ser Transmitidos para ser tratados por personas "
                        + "distintas a esta empresa.   Todos sus datos personales son tratados de acuerdo a la legislacin aplicable y "
                        + "vigente en el pas, por ello le informamos que usted tiene en todo momento los derechos (ARCO) de acceder, "
                        + "rectificar, cancelar u oponerse al tratamiento que le damos a sus datos personales; derecho que podr "
                        + "hacer valer a travs del ?rea de Privacidad encargada de la seguridad de datos personales en el "
                        + "Telfono 5729 6000.",
                fontContenido));
        paragraph.setAlignment(Element.ALIGN_JUSTIFIED);

        paragraph.add(new Phrase(Chunk.NEWLINE));
        paragraph.add(new Phrase(Chunk.NEWLINE));

        paragraph.add(new Phrase(
                " A travs de estos canales usted podr actualizar sus datos y especificar el medio por el cual desea recibir "
                        + "informacin, ya que en caso de no contar con esta especificacin de su parte, ZERCHERS, S.A. de C.V., "
                        + "establecer libremente el canal que considere pertinente para enviarle informacin.  Este aviso de"
                        + " privacidad podr ser modificado por ZERCHERS, S.A. de C.V., dichas modificaciones sern oportunamente "
                        + "informadas a travs de correo electrnico, telfono, pgina web o cualquier otro medio de comunicacin"
                        + " que ZERCHERS, S.A. de C.V., determine para tal efecto.",
                fontContenido));
        paragraph.setAlignment(Element.ALIGN_JUSTIFIED);
        paragraph.add(new Phrase(Chunk.NEWLINE));
        paragraph.add(new Phrase(Chunk.NEWLINE));

        paragraph.add(new Phrase(" ATENTAMENTE", nomb));
        paragraph.add(new Phrase(Chunk.NEWLINE));
        paragraph.add(new Phrase(" Direccin General TT/SisPLD", nomb));
        paragraph.add(new Phrase(Chunk.NEWLINE));
        paragraph.add(new Phrase(Chunk.NEWLINE));
        paragraph.add(new Phrase(Chunk.NEWLINE));
        paragraph.add(new Phrase(Chunk.NEWLINE));
        paragraph.add(new Phrase(" Consiento que mis datos personales sensibles sean tratados conforme a"
                + "los trminos y condiciones del presente aviso de privacidad.", fontContenido));
        paragraph.add(new Phrase(Chunk.NEWLINE));
        paragraph.add(new Phrase(Chunk.NEWLINE));
        paragraph.add(new Phrase("Nombre: " + nombre + " " + appat + " " + apmat, nomb));
        paragraph.add(new Phrase(Chunk.NEWLINE));
        paragraph.add(new Phrase(Chunk.NEWLINE));
        paragraph.add(new Phrase("____________________________________", fontContenido));
        paragraph.add(new Phrase(Chunk.NEWLINE));
        paragraph.add(new Phrase(Chunk.NEWLINE));
        paragraph.add(new Phrase(Chunk.NEWLINE));
        paragraph.add(new Phrase(" ltima Fecha de Emisin:  Mayo 13, 2016", fontContenido));

        document.add(paragraph);

        // Cerrar el documento
        document.close();

        // Abrir el archivo
        File file = new File("AvisoPrivacidad.pdf");
        Desktop.getDesktop().open(file);
    } catch (Exception ex) {
        ex.printStackTrace();
    }
}

From source file:com.mx.ipn.clases.PDF.java

public PdfPTable Tabla_Simple() throws BadElementException, IOException {
    Paragraph paragraph1 = new Paragraph();
    Font nomb = FontFactory.getFont(FontFactory.TIMES_BOLD, 9, Font.NORMAL, BaseColor.DARK_GRAY);
    Image image;/*from   ww  w . j  a v a2 s.  c o  m*/

    // Obtenemos el logo de datojava
    image = Image.getInstance(getClass().getResource("/com/ipn/mx/imagenes/logo.png"));
    image.scaleAbsolute(70f, 60f);

    //creamos la tabla con 3 columnas
    PdfPTable mitablasimple = new PdfPTable(2);
    PdfPCell cellimage = new PdfPCell(image);

    // Propiedades de la celda

    cellimage.setBorderColor(BaseColor.WHITE);
    cellimage.setHorizontalAlignment(Element.ALIGN_CENTER);

    paragraph1.add(new Phrase("1. Nombre completo Y/O Razn Social.", nomb));
    paragraph1.add(new Phrase(Chunk.NEWLINE));
    paragraph1.add(new Phrase("2. Direccin.", nomb));
    paragraph1.add(new Phrase(Chunk.NEWLINE));
    paragraph1.add(new Phrase("3. Registro Federal de Contribuyentes Y/O CURP.", nomb));
    paragraph1.add(new Phrase(Chunk.NEWLINE));
    paragraph1.add(new Phrase("4. Telfonos de Oficina y mviles.", nomb));
    paragraph1.add(new Phrase(Chunk.NEWLINE));
    paragraph1.add(new Phrase("5. Actividad econmica e ingreso promedio.", nomb));
    paragraph1.add(new Phrase(Chunk.NEWLINE));
    paragraph1.add(new Phrase("6. Correo Electrnico. ", nomb));
    paragraph1.add(new Phrase(Chunk.NEWLINE));
    PdfPCell cell = new PdfPCell(paragraph1);

    // Propiedades de la celda

    cell.setBorderColor(BaseColor.WHITE);
    cell.setHorizontalAlignment(Element.ALIGN_JUSTIFIED);
    mitablasimple.addCell(cell);
    mitablasimple.addCell(cellimage);
    //retornamos la tabla

    return mitablasimple;
}

From source file:cz.zcu.kiv.eegdatabase.logic.pdf.ReservationPDF.java

License:Apache License

public static PdfPTable formatReservation(Reservation reservation) {
    int padding = 5;

    GregorianCalendar created = new GregorianCalendar();
    created.setTime(reservation.getCreationTime());
    GregorianCalendar startTime = new GregorianCalendar();
    startTime.setTime(reservation.getStartTime());
    GregorianCalendar endTime = new GregorianCalendar();
    endTime.setTime(reservation.getEndTime());

    String personName = BookingRoomUtils.formatPersonName(reservation.getPerson());

    Font title = FontFactory.getFont("Trebuchet MS", "utf-8", 15, Font.BOLD, new BaseColor(59, 70, 00));
    Font header = FontFactory.getFont(FontFactory.TIMES_BOLD, 13, Font.BOLD, BaseColor.BLACK);
    Font value = FontFactory.getFont(FontFactory.TIMES, 13);

    PdfPTable table = new PdfPTable(2);
    PdfPCell cell;/*from   w  w  w  .  jav  a2s.co m*/
    Phrase phrase;

    phrase = new Phrase("Reservation by " + personName);
    phrase.setFont(title);
    cell = new PdfPCell(phrase);
    cell.setColspan(2);
    cell.setBorder(0);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER);
    cell.setBorderWidthTop(1);
    cell.setBorderWidthLeft(1);
    cell.setBorderWidthRight(1);
    cell.setPadding(padding);
    cell.setPaddingBottom(5);
    table.addCell(cell);

    phrase = new Phrase("Date: ");
    phrase.setFont(header);
    cell = new PdfPCell(phrase);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER);
    cell.setBorder(0);
    cell.setBorderWidthLeft(1);
    cell.setPadding(padding);
    table.addCell(cell);

    phrase = new Phrase(BookingRoomUtils.getDate(startTime));
    phrase.setFont(value);
    cell = new PdfPCell(phrase);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER);
    cell.setBorder(0);
    cell.setBorderWidthRight(1);
    cell.setPadding(padding);
    table.addCell(cell);

    phrase = new Phrase("Start: ");
    phrase.setFont(header);
    cell = new PdfPCell(phrase);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER);
    cell.setBorder(0);
    cell.setBorderWidthLeft(1);
    cell.setPadding(padding);
    table.addCell(cell);

    phrase = new Phrase(BookingRoomUtils.getHoursAndMinutes(startTime));
    phrase.setFont(value);
    cell = new PdfPCell(phrase);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER);
    cell.setBorder(0);
    cell.setBorderWidthRight(1);
    cell.setPadding(padding);
    table.addCell(cell);

    phrase = new Phrase("End: ");
    phrase.setFont(header);
    cell = new PdfPCell(phrase);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER);
    cell.setBorder(0);
    cell.setBorderWidthLeft(1);
    cell.setBorderWidthBottom(1);
    cell.setPadding(padding);
    table.addCell(cell);

    phrase = new Phrase(BookingRoomUtils.getHoursAndMinutes(endTime));
    phrase.setFont(value);
    cell = new PdfPCell(phrase);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER);
    cell.setBorder(0);
    cell.setBorderWidthRight(1);
    cell.setBorderWidthBottom(1);
    cell.setPadding(padding);
    table.addCell(cell);

    table.setSpacingBefore(10);
    table.setSpacingAfter(10);

    return table;
}

From source file:digiho.DigiHoInitial1.java

private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
    // TODO add your handling code here:

    jDate1.setText("");
    Calendar timer = Calendar.getInstance();
    timer.getTime();/*from   www  .j  a v a 2 s . c  o  m*/
    SimpleDateFormat Tdate = new SimpleDateFormat("dd-MMM-yyy");
    jDate1.setText(Tdate.format(timer.getTime()));
    Document doc = new Document();
    try {
        PdfWriter.getInstance(doc,
                new FileOutputStream("f:\\DiGiho\\Complaint From\\" + jCustomer1.getText() + ".pdf"));
        doc.open();
        doc.add(new Paragraph("\n",
                FontFactory.getFont(FontFactory.TIMES_BOLD, 20, Font.BOLD, BaseColor.DARK_GRAY)));
        doc.add(new Paragraph("\n\n\n\n\n\n\n\n\n\n"));
        doc.add(new Phrase("Customer ID.:         "));
        doc.add(new Phrase(jCustomer1.getText(),
                FontFactory.getFont(FontFactory.TIMES_BOLD, 12, Font.BOLD, BaseColor.BLACK)));
        doc.add(new Phrase("                                                    Date:          "
                + jDate1.getText() + "   \n\n"));
        doc.add(new Phrase("Name:                   "));
        doc.add(new Phrase(jName1.getText() + ". " + jName2.getText() + " " + jName3.getText(),
                FontFactory.getFont(FontFactory.TIMES_BOLD, 12, Font.BOLD, BaseColor.BLACK)));
        doc.add(new Phrase("\nFather's Name:     "));
        doc.add(new Phrase(jFatherName1.getText(),
                FontFactory.getFont(FontFactory.TIMES_BOLD, 12, Font.BOLD, BaseColor.BLACK)));
        doc.add(new Phrase("\nAddress:                "));
        doc.add(new Phrase(jAddress1.getText(),
                FontFactory.getFont(FontFactory.TIMES_BOLD, 12, Font.BOLD, BaseColor.BLACK)));
        doc.add(new Phrase("\nBlock:                    "));
        doc.add(new Phrase(jBlock1.getText(),
                FontFactory.getFont(FontFactory.TIMES_BOLD, 12, Font.BOLD, BaseColor.BLACK)));

        doc.add(new Phrase("\nCity:                       "));
        doc.add(new Phrase(jCity1.getText(),
                FontFactory.getFont(FontFactory.TIMES_BOLD, 12, Font.BOLD, BaseColor.BLACK)));
        doc.add(new Phrase("\nDistrict:                  "));
        doc.add(new Phrase(jDistrict1.getText(),
                FontFactory.getFont(FontFactory.TIMES_BOLD, 12, Font.BOLD, BaseColor.BLACK)));
        doc.add(new Phrase("\nMoblie No.:           "));
        doc.add(new Phrase(jMobile1.getText(),
                FontFactory.getFont(FontFactory.TIMES_BOLD, 12, Font.BOLD, BaseColor.BLACK)));

        doc.add(new Paragraph("\n\n\n\n\n\n"));
        doc.add(new Paragraph("        (1)  " + jTextField2.getText()));
        doc.add(new Paragraph("        (2)  " + jcomplain1.getText()));
        doc.add(new Paragraph("        (3)  " + jcomplain3.getText()));
        doc.add(new Paragraph("        (4)  " + jcomplain4.getText()));
        doc.close();
    } catch (DocumentException e) {
        e.printStackTrace();
    } catch (FileNotFoundException ex) {
        Logger.getLogger(DigiHoInitial1.class.getName()).log(Level.SEVERE, null, ex);
    }
    JOptionPane.showMessageDialog(null, "File has been created", "deeps message", JOptionPane.WARNING_MESSAGE);
}

From source file:employee.payroll.system.MainMenu.java

private void jMenuItem6ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem6ActionPerformed
    JFileChooser dialog = new JFileChooser();
    dialog.setSelectedFile(new File("Employees Report.pdf"));
    int dialogResult = dialog.showSaveDialog(null);
    if (dialogResult == JFileChooser.APPROVE_OPTION) {
        String filePath = dialog.getSelectedFile().getPath();

        try {//  w ww  .ja va  2s . c o  m
            // TODO add your handling code here:

            String sql = "select * from Staff_information";

            pst = conn.prepareStatement(sql);
            rs = pst.executeQuery();

            Document myDocument = new Document();
            PdfWriter myWriter = PdfWriter.getInstance(myDocument, new FileOutputStream(filePath));
            PdfPTable table = new PdfPTable(13);
            myDocument.open();

            float[] columnWidths = new float[] { 3, 8, 7, 5, 5, 9, 8, 9, 6, 6, 6, 8, 8 };
            table.setWidths(columnWidths);

            table.setWidthPercentage(100); //set table width to 100%

            myDocument.add(new Paragraph("Employees List",
                    FontFactory.getFont(FontFactory.TIMES_BOLD, 20, Font.BOLD)));
            myDocument.add(new Paragraph(new Date().toString()));
            myDocument.add(new Paragraph(
                    "-------------------------------------------------------------------------------------------"));
            table.addCell(new PdfPCell(
                    new Paragraph("ID", FontFactory.getFont(FontFactory.TIMES_ROMAN, 9, Font.BOLD))));
            table.addCell(new PdfPCell(
                    new Paragraph("First Name", FontFactory.getFont(FontFactory.TIMES_ROMAN, 9, Font.BOLD))));
            table.addCell(new PdfPCell(
                    new Paragraph("Surname", FontFactory.getFont(FontFactory.TIMES_ROMAN, 9, Font.BOLD))));
            table.addCell(new PdfPCell(new Paragraph("Date of Birth",
                    FontFactory.getFont(FontFactory.TIMES_ROMAN, 9, Font.BOLD))));
            table.addCell(new PdfPCell(
                    new Paragraph("Email", FontFactory.getFont(FontFactory.TIMES_ROMAN, 9, Font.BOLD))));
            table.addCell(new PdfPCell(
                    new Paragraph("Telephone", FontFactory.getFont(FontFactory.TIMES_ROMAN, 9, Font.BOLD))));
            table.addCell(new PdfPCell(
                    new Paragraph("Address", FontFactory.getFont(FontFactory.TIMES_ROMAN, 9, Font.BOLD))));
            table.addCell(new PdfPCell(
                    new Paragraph("Department", FontFactory.getFont(FontFactory.TIMES_ROMAN, 9, Font.BOLD))));
            table.addCell(new PdfPCell(
                    new Paragraph("Gender", FontFactory.getFont(FontFactory.TIMES_ROMAN, 9, Font.BOLD))));
            table.addCell(new PdfPCell(
                    new Paragraph("Salary", FontFactory.getFont(FontFactory.TIMES_ROMAN, 9, Font.BOLD))));
            table.addCell(new PdfPCell(
                    new Paragraph("Status", FontFactory.getFont(FontFactory.TIMES_ROMAN, 9, Font.BOLD))));
            table.addCell(new PdfPCell(
                    new Paragraph("Date Hired", FontFactory.getFont(FontFactory.TIMES_ROMAN, 9, Font.BOLD))));
            table.addCell(new PdfPCell(
                    new Paragraph("Job Title", FontFactory.getFont(FontFactory.TIMES_ROMAN, 9, Font.BOLD))));

            while (rs.next()) {

                table.addCell(new PdfPCell(new Paragraph(rs.getString(1),
                        FontFactory.getFont(FontFactory.TIMES_ROMAN, 8, Font.PLAIN))));
                table.addCell(new PdfPCell(new Paragraph(rs.getString(2),
                        FontFactory.getFont(FontFactory.TIMES_ROMAN, 8, Font.PLAIN))));
                table.addCell(new PdfPCell(new Paragraph(rs.getString(3),
                        FontFactory.getFont(FontFactory.TIMES_ROMAN, 8, Font.PLAIN))));
                table.addCell(new PdfPCell(new Paragraph(rs.getString(4),
                        FontFactory.getFont(FontFactory.TIMES_ROMAN, 8, Font.PLAIN))));
                table.addCell(new PdfPCell(new Paragraph(rs.getString(5),
                        FontFactory.getFont(FontFactory.TIMES_ROMAN, 8, Font.PLAIN))));
                table.addCell(new PdfPCell(new Paragraph(rs.getString(6),
                        FontFactory.getFont(FontFactory.TIMES_ROMAN, 8, Font.PLAIN))));
                table.addCell(new PdfPCell(new Paragraph(rs.getString(7),
                        FontFactory.getFont(FontFactory.TIMES_ROMAN, 8, Font.PLAIN))));
                table.addCell(new PdfPCell(new Paragraph(rs.getString(8),
                        FontFactory.getFont(FontFactory.TIMES_ROMAN, 8, Font.PLAIN))));
                table.addCell(new PdfPCell(new Paragraph(rs.getString(10),
                        FontFactory.getFont(FontFactory.TIMES_ROMAN, 8, Font.PLAIN))));
                table.addCell(new PdfPCell(new Paragraph(rs.getString(11),
                        FontFactory.getFont(FontFactory.TIMES_ROMAN, 8, Font.PLAIN))));
                table.addCell(new PdfPCell(new Paragraph(rs.getString(16),
                        FontFactory.getFont(FontFactory.TIMES_ROMAN, 8, Font.PLAIN))));
                table.addCell(new PdfPCell(new Paragraph(rs.getString(17),
                        FontFactory.getFont(FontFactory.TIMES_ROMAN, 8, Font.PLAIN))));
                table.addCell(new PdfPCell(new Paragraph(rs.getString(18),
                        FontFactory.getFont(FontFactory.TIMES_ROMAN, 8, Font.PLAIN))));

            }

            myDocument.add(table);
            myDocument.add(new Paragraph(
                    "--------------------------------------------------------------------------------------------"));
            myDocument.close();
            JOptionPane.showMessageDialog(null, "Report was successfully generated");

        } catch (Exception e) {
            JOptionPane.showMessageDialog(null, e);

        } finally {

            try {
                rs.close();
                pst.close();

            } catch (Exception e) {
                JOptionPane.showMessageDialog(null, e);

            }
        }
    }

}

From source file:employee.payroll.system.MainMenu.java

private void jMenuItem7ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem7ActionPerformed
    // TODO add your handling code here:
    JFileChooser dialog = new JFileChooser();
    dialog.setSelectedFile(new File("Employee Allowance Report.pdf"));
    int dialogResult = dialog.showSaveDialog(null);
    if (dialogResult == JFileChooser.APPROVE_OPTION) {
        String filePath = dialog.getSelectedFile().getPath();

        try {/*  w  w w . jav a2s  .  c  om*/
            // TODO add your handling code here:

            String sql = "select * from Allowance";

            pst = conn.prepareStatement(sql);
            rs = pst.executeQuery();

            Document myDocument = new Document();
            PdfWriter myWriter = PdfWriter.getInstance(myDocument, new FileOutputStream(filePath));
            PdfPTable table = new PdfPTable(11);
            myDocument.open();

            float[] columnWidths = new float[] { 3, 7, 7, 5, 5, 9, 6, 5, 8, 8, 8 };
            table.setWidths(columnWidths);

            table.setWidthPercentage(100); //set table width to 100%

            myDocument.add(new Paragraph("Employees Allowance List",
                    FontFactory.getFont(FontFactory.TIMES_BOLD, 20, Font.BOLD)));
            myDocument.add(new Paragraph(new Date().toString()));
            myDocument.add(new Paragraph(
                    "-------------------------------------------------------------------------------------------"));
            table.addCell(new PdfPCell(
                    new Paragraph("ID", FontFactory.getFont(FontFactory.TIMES_ROMAN, 10, Font.BOLD))));
            table.addCell(new PdfPCell(
                    new Paragraph("Overtime", FontFactory.getFont(FontFactory.TIMES_ROMAN, 10, Font.BOLD))));
            table.addCell(new PdfPCell(
                    new Paragraph("Medical", FontFactory.getFont(FontFactory.TIMES_ROMAN, 10, Font.BOLD))));
            table.addCell(new PdfPCell(
                    new Paragraph("Bonus", FontFactory.getFont(FontFactory.TIMES_ROMAN, 10, Font.BOLD))));
            table.addCell(new PdfPCell(
                    new Paragraph("Other", FontFactory.getFont(FontFactory.TIMES_ROMAN, 10, Font.BOLD))));
            table.addCell(new PdfPCell(
                    new Paragraph("Employee ID", FontFactory.getFont(FontFactory.TIMES_ROMAN, 10, Font.BOLD))));
            table.addCell(new PdfPCell(
                    new Paragraph("Salary", FontFactory.getFont(FontFactory.TIMES_ROMAN, 10, Font.BOLD))));
            table.addCell(new PdfPCell(
                    new Paragraph("Rate", FontFactory.getFont(FontFactory.TIMES_ROMAN, 10, Font.BOLD))));
            table.addCell(new PdfPCell(
                    new Paragraph("Allowance", FontFactory.getFont(FontFactory.TIMES_ROMAN, 10, Font.BOLD))));
            table.addCell(new PdfPCell(
                    new Paragraph("First Name", FontFactory.getFont(FontFactory.TIMES_ROMAN, 10, Font.BOLD))));
            table.addCell(new PdfPCell(
                    new Paragraph("Surname", FontFactory.getFont(FontFactory.TIMES_ROMAN, 10, Font.BOLD))));

            while (rs.next()) {

                table.addCell(new PdfPCell(new Paragraph(rs.getString(1),
                        FontFactory.getFont(FontFactory.TIMES_ROMAN, 9, Font.PLAIN))));
                table.addCell(new PdfPCell(new Paragraph(rs.getString(2),
                        FontFactory.getFont(FontFactory.TIMES_ROMAN, 9, Font.PLAIN))));
                table.addCell(new PdfPCell(new Paragraph(rs.getString(3),
                        FontFactory.getFont(FontFactory.TIMES_ROMAN, 9, Font.PLAIN))));
                table.addCell(new PdfPCell(new Paragraph(rs.getString(4),
                        FontFactory.getFont(FontFactory.TIMES_ROMAN, 9, Font.PLAIN))));
                table.addCell(new PdfPCell(new Paragraph(rs.getString(5),
                        FontFactory.getFont(FontFactory.TIMES_ROMAN, 9, Font.PLAIN))));
                table.addCell(new PdfPCell(new Paragraph(rs.getString(6),
                        FontFactory.getFont(FontFactory.TIMES_ROMAN, 9, Font.PLAIN))));
                table.addCell(new PdfPCell(new Paragraph(rs.getString(7),
                        FontFactory.getFont(FontFactory.TIMES_ROMAN, 9, Font.PLAIN))));
                table.addCell(new PdfPCell(new Paragraph(rs.getString(8),
                        FontFactory.getFont(FontFactory.TIMES_ROMAN, 9, Font.PLAIN))));
                table.addCell(new PdfPCell(new Paragraph(rs.getString(9),
                        FontFactory.getFont(FontFactory.TIMES_ROMAN, 9, Font.PLAIN))));
                table.addCell(new PdfPCell(new Paragraph(rs.getString(10),
                        FontFactory.getFont(FontFactory.TIMES_ROMAN, 9, Font.PLAIN))));
                table.addCell(new PdfPCell(new Paragraph(rs.getString(11),
                        FontFactory.getFont(FontFactory.TIMES_ROMAN, 9, Font.PLAIN))));

            }

            myDocument.add(table);
            myDocument.add(new Paragraph(
                    "--------------------------------------------------------------------------------------------"));
            myDocument.close();
            JOptionPane.showMessageDialog(null, "Report was successfully generated");

        } catch (Exception e) {
            JOptionPane.showMessageDialog(null, e);

        } finally {

            try {
                rs.close();
                pst.close();

            } catch (Exception e) {
                JOptionPane.showMessageDialog(null, e);

            }
        }
    }

}

From source file:employee.payroll.system.MainMenu.java

private void jMenuItem2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem2ActionPerformed
    // TODO add your handling code here:

    JFileChooser dialog = new JFileChooser();
    dialog.setSelectedFile(new File("Employee Deduction Report.pdf"));
    int dialogResult = dialog.showSaveDialog(null);
    if (dialogResult == JFileChooser.APPROVE_OPTION) {
        String filePath = dialog.getSelectedFile().getPath();

        try {/*from  w  w  w  .ja  v a  2s . c  om*/
            // TODO add your handling code here:

            String sql = "select * from Deductions";

            pst = conn.prepareStatement(sql);
            rs = pst.executeQuery();

            Document myDocument = new Document();
            PdfWriter myWriter = PdfWriter.getInstance(myDocument, new FileOutputStream(filePath));
            PdfPTable table = new PdfPTable(8);
            myDocument.open();

            float[] columnWidths = new float[] { 3, 7, 7, 5, 5, 9, 6, 5 };
            table.setWidths(columnWidths);

            table.setWidthPercentage(100); //set table width to 100%

            myDocument.add(new Paragraph("Employees Deduction List",
                    FontFactory.getFont(FontFactory.TIMES_BOLD, 20, Font.BOLD)));
            myDocument.add(new Paragraph(new Date().toString()));
            myDocument.add(new Paragraph(
                    "-------------------------------------------------------------------------------------------"));
            table.addCell(new PdfPCell(
                    new Paragraph("ID", FontFactory.getFont(FontFactory.TIMES_ROMAN, 10, Font.BOLD))));
            table.addCell(new PdfPCell(
                    new Paragraph("First Name", FontFactory.getFont(FontFactory.TIMES_ROMAN, 10, Font.BOLD))));
            table.addCell(new PdfPCell(
                    new Paragraph("Surname", FontFactory.getFont(FontFactory.TIMES_ROMAN, 10, Font.BOLD))));
            table.addCell(new PdfPCell(
                    new Paragraph("Salary", FontFactory.getFont(FontFactory.TIMES_ROMAN, 10, Font.BOLD))));
            table.addCell(new PdfPCell(new Paragraph("Deduction Amount",
                    FontFactory.getFont(FontFactory.TIMES_ROMAN, 10, Font.BOLD))));
            table.addCell(new PdfPCell(new Paragraph("Deduction Reason",
                    FontFactory.getFont(FontFactory.TIMES_ROMAN, 10, Font.BOLD))));
            table.addCell(new PdfPCell(
                    new Paragraph("Employee ID", FontFactory.getFont(FontFactory.TIMES_ROMAN, 10, Font.BOLD))));
            table.addCell(new PdfPCell(
                    new Paragraph("Created By", FontFactory.getFont(FontFactory.TIMES_ROMAN, 10, Font.BOLD))));

            while (rs.next()) {
                table.addCell(new PdfPCell(new Paragraph(rs.getString(1),
                        FontFactory.getFont(FontFactory.TIMES_ROMAN, 9, Font.PLAIN))));
                table.addCell(new PdfPCell(new Paragraph(rs.getString(2),
                        FontFactory.getFont(FontFactory.TIMES_ROMAN, 9, Font.PLAIN))));
                table.addCell(new PdfPCell(new Paragraph(rs.getString(3),
                        FontFactory.getFont(FontFactory.TIMES_ROMAN, 9, Font.PLAIN))));
                table.addCell(new PdfPCell(new Paragraph(rs.getString(4),
                        FontFactory.getFont(FontFactory.TIMES_ROMAN, 9, Font.PLAIN))));
                table.addCell(new PdfPCell(new Paragraph(rs.getString(5),
                        FontFactory.getFont(FontFactory.TIMES_ROMAN, 9, Font.PLAIN))));
                table.addCell(new PdfPCell(new Paragraph(rs.getString(6),
                        FontFactory.getFont(FontFactory.TIMES_ROMAN, 9, Font.PLAIN))));
                table.addCell(new PdfPCell(new Paragraph(rs.getString(7),
                        FontFactory.getFont(FontFactory.TIMES_ROMAN, 9, Font.PLAIN))));
                table.addCell(new PdfPCell(new Paragraph(rs.getString(8),
                        FontFactory.getFont(FontFactory.TIMES_ROMAN, 9, Font.PLAIN))));

            }

            myDocument.add(table);
            myDocument.add(new Paragraph(
                    "--------------------------------------------------------------------------------------------"));
            myDocument.close();
            JOptionPane.showMessageDialog(null, "Report was successfully generated");

        } catch (Exception e) {
            JOptionPane.showMessageDialog(null, e);

        } finally {

            try {
                rs.close();
                pst.close();

            } catch (Exception e) {
                JOptionPane.showMessageDialog(null, e);

            }
        }
    }

}