Example usage for com.itextpdf.text Paragraph setAlignment

List of usage examples for com.itextpdf.text Paragraph setAlignment

Introduction

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

Prototype

public void setAlignment(int alignment) 

Source Link

Document

Sets the alignment of this paragraph.

Usage

From source file:PrefichaPDF.java

protected void doGet(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
    try {/*from   w w  w. j a  va 2 s.  c  o  m*/
        response.setContentType("application/pdf");

        String curp = new String(request.getParameter("curp").getBytes("ISO-8859-1"), "UTF-8");

        ConexionOracle conexionOracle = new ConexionOracle();

        String sql = "select * from PERSONALDATA_ASP_TAB where curp=" + "'" + curp + "'";
        System.out.println(sql);
        System.out.println("Esta es la curp: " + curp);

        conexionOracle.conectar();
        Connection conn = conexionOracle.getConnection();
        // driver@machineName:port:SID           ,  userid,  password
        Statement stmt = conn.createStatement();

        ResultSet rset = stmt.executeQuery(sql);

        while (rset.next()) {

            fichabd = rset.getString("id_aspirante");
            periodobd = rset.getString("periodo_solicitud");
            prefichabd = rset.getString("preficha");
            nombrebd = rset.getString("nombre");
            String appat = rset.getString("apellido_pat");
            String apmat = rset.getString("apellido_mat");
            apellidosbd = appat + " " + apmat;
            curpbd = rset.getString("curp");
            carrerabd = rset.getString("carrera");
            modalidadbd = rset.getString("modalidad");
        }

        try {

            Document preficha = new Document();
            PdfWriter writer = PdfWriter.getInstance(preficha, response.getOutputStream());
            preficha.open();
            //encabezado
            //encabezado
            //encabezado
            //encabezado

            //                documento.add(vacio);
            //                documento.add(vacio);
            //                documento.add(vacio);
            Paragraph depto = new Paragraph("Departamento de servicios escolares",
                    FontFactory.getFont("arial", 20, Font.BOLD));
            depto.setAlignment(Element.ALIGN_CENTER);

            preficha.add(depto);

            Paragraph vacio = new Paragraph("  ", FontFactory.getFont("arial", 10, Font.BOLD));
            vacio.setAlignment(Element.ALIGN_CENTER);
            preficha.add(vacio);
            preficha.add(vacio);
            //                preficha.add(vacio);
            //cuerpo
            //cuerpo
            //cuerpo
            //cuerpo
            //cuerpo

            Paragraph periodo_text = new Paragraph("Convocatoria de nuevo ingreso periodo: " + periodobd,
                    FontFactory.getFont("arial", 10, Font.BOLD));
            periodo_text.setAlignment(Element.ALIGN_CENTER);
            preficha.add(periodo_text);

            preficha.add(vacio);
            preficha.add(vacio);

            Paragraph fotografia = new Paragraph("Fotografa", FontFactory.getFont("arial", 10, Font.BOLD));
            fotografia.setAlignment(Element.ALIGN_CENTER);
            preficha.add(fotografia);

            PdfContentByte rectangulo_general = writer.getDirectContentUnder();
            rectangulo_general.rectangle(50, 48, 500, 710);
            rectangulo_general.fill();
            drawRectangleSC(rectangulo_general, 50, 48, 500, 710);

            PdfContentByte rectangulo_periodo = writer.getDirectContentUnder();
            rectangulo_periodo.rectangle(125, 725, 350, 20);
            rectangulo_periodo.fill();
            drawRectangleSC(rectangulo_periodo, 125, 725, 350, 20);

            String url_logo = "/Imagenes/itt_logo_opt.jpg";
            String absolute_url_logo = getServletContext().getRealPath(url_logo);
            Image itt_logo = Image.getInstance(absolute_url_logo);

            String url_logo_bnmx = "/Imagenes/bnmx_color_opt.jpg";
            String absolute_url_logo_bnmx = getServletContext().getRealPath(url_logo_bnmx);
            Image bnmx_logo = Image.getInstance(absolute_url_logo_bnmx);

            Image Logo_itt = Image.getInstance(itt_logo);
            Logo_itt.setAbsolutePosition(140f, 640f);
            preficha.add(Logo_itt);

            Image Logo_banco = Image.getInstance(bnmx_logo);
            Logo_banco.setAbsolutePosition(380f, 340f);
            preficha.add(Logo_banco);

            PdfContentByte espacio_imagen = writer.getDirectContentUnder();
            espacio_imagen.rectangle(255, 635, 85, 80);
            espacio_imagen.fill();
            drawRectangleSC(espacio_imagen, 255, 635, 85, 80);

            //                preficha.add(vacio);
            preficha.add(vacio);

            PdfContentByte fechaimpr = writer.getDirectContentUnder();
            fechaimpr.rectangle(416, 635, 100, 35);
            fechaimpr.fill();
            drawRectangleSC(fechaimpr, 416, 635, 100, 35);
            //            drawRectangle(fechaimpr, 85, 530, 430, 25);

            Paragraph fechapdf = new Paragraph("\tFecha de impresin                ",
                    FontFactory.getFont("arial", 10, com.itextpdf.text.Font.BOLD));
            fechapdf.setAlignment(Element.ALIGN_RIGHT);
            preficha.add(fechapdf);

            Paragraph fechapdf_fec = new Paragraph("\t" + fecha_hoy() + "                          ",
                    FontFactory.getFont("arial", 10, com.itextpdf.text.Font.BOLD));
            fechapdf_fec.setAlignment(Element.ALIGN_RIGHT);
            preficha.add(fechapdf_fec);

            preficha.add(vacio);

            Paragraph no_preficha = new Paragraph("Preficha N: " + prefichabd,
                    FontFactory.getFont("arial", 20, Font.BOLD));
            no_preficha.setAlignment(Element.ALIGN_CENTER);
            preficha.add(no_preficha);

            preficha.add(vacio);
            //                preficha.add(vacio);

            PdfContentByte rectangulo_preficha_no = writer.getDirectContentUnder();
            rectangulo_preficha_no.rectangle(85, 590, 430, 25);
            rectangulo_preficha_no.fill();
            drawRectangleSC(rectangulo_preficha_no, 85, 590, 430, 25);

            PdfContentByte rectangulo_datos = writer.getDirectContentUnder();
            rectangulo_datos.rectangle(85, 500, 430, 80);
            //                rectangulo_datos.rec
            rectangulo_datos.fill();
            drawRectangleSC(rectangulo_datos, 85, 500, 430, 80);

            //////////////////////////////
            Paragraph nombre = new Paragraph(
                    "                                                                              Nombre:   "
                            + nombrebd,
                    FontFactory.getFont("arial", 10, Font.BOLD));
            nombre.setAlignment(Element.ALIGN_LEFT);
            preficha.add(nombre);

            //                preficha.add(vacio);
            Paragraph apellidos = new Paragraph(
                    "                                                                                               "
                            + apellidosbd,
                    FontFactory.getFont("arial", 10, Font.BOLD));
            apellidos.setAlignment(Element.ALIGN_LEFT);
            preficha.add(apellidos);

            //                preficha.add(vacio);
            Paragraph CURP = new Paragraph(
                    "                                                                                 CURP:   "
                            + curpbd,
                    FontFactory.getFont("arial", 10, Font.BOLD));
            CURP.setAlignment(Element.ALIGN_LEFT);
            preficha.add(CURP);

            //                preficha.add(vacio);
            Paragraph carrera = new Paragraph(
                    "                                                            Carrera Solicitada:   "
                            + carrerabd,
                    FontFactory.getFont("arial", 10, Font.BOLD));
            carrera.setAlignment(Element.ALIGN_LEFT);
            preficha.add(carrera);

            //                preficha.add(vacio);
            Paragraph modalidad = new Paragraph(
                    "                                                                          Modalidad:   "
                            + modalidadbd,
                    FontFactory.getFont("arial", 10, Font.BOLD));
            modalidad.setAlignment(Element.ALIGN_LEFT);
            preficha.add(modalidad);

            preficha.add(vacio);
            //                preficha.add(vacio);

            Paragraph formatoBanamex = new Paragraph("FORMATO UNIVERSAL PARA DEPSITOS EN SUCURSALES BANAMEX",
                    FontFactory.getFont("arial", 10, Font.BOLD));
            formatoBanamex.setAlignment(Element.ALIGN_CENTER);
            preficha.add(formatoBanamex);

            PdfContentByte rectanguloDepositoB = writer.getDirectContentUnder();
            rectanguloDepositoB.rectangle(85, 470, 430, 20);
            rectanguloDepositoB.fill();
            drawRectangle(rectanguloDepositoB, 85, 470, 430, 20);

            PdfContentByte rectanguloPago = writer.getDirectContentUnder();
            rectanguloPago.rectangle(85, 280, 430, 190);
            rectanguloPago.fill();
            drawRectangleSC(rectanguloPago, 85, 280, 430, 190);

            preficha.add(vacio);

            PdfContentByte rectanguloConcepto = writer.getDirectContentUnder();
            rectanguloConcepto.rectangle(150, 425, 295, 35);
            //                rectangulo_datos.rec
            rectanguloConcepto.fill();
            drawRectangleSC(rectanguloConcepto, 150, 425, 295, 35);

            Paragraph formatoConceptoPre = new Paragraph("CONCEPTO: PAGO DE DERECHO A EXAMEN DE ADMISIN",
                    FontFactory.getFont("arial", 10, Font.BOLD));
            formatoConceptoPre.setAlignment(Element.ALIGN_CENTER);
            preficha.add(formatoConceptoPre);

            Paragraph fechaEmision = new Paragraph("FECHA DE EMISIN: 18/12/2014",
                    FontFactory.getFont("arial", 10, Font.BOLD));
            fechaEmision.setAlignment(Element.ALIGN_CENTER);
            preficha.add(fechaEmision);

            preficha.add(vacio);
            //                preficha.add(vacio);
            //                preficha.add(vacio);
            //                preficha.add(vacio);
            //                preficha.add(vacio);
            preficha.add(vacio);

            Paragraph importe = new Paragraph("IMPORTE A PAGAR: $1,500.",
                    FontFactory.getFont("arial", 15, Font.BOLD));
            importe.setAlignment(Element.ALIGN_CENTER);
            preficha.add(importe);

            preficha.add(vacio);
            preficha.add(vacio);
            preficha.add(vacio);
            //                preficha.add(vacio);
            //                preficha.add(vacio);

            String ref = "44353452342353464765634523434";

            Paragraph referencia = new Paragraph(
                    "                                                   REFERENCIA (B): " + ref,
                    FontFactory.getFont("arial", 10, Font.BOLD));
            referencia.setAlignment(Element.ALIGN_LEFT);
            preficha.add(referencia);

            preficha.add(vacio);

            //                Paragraph descrConcepto = new Paragraph("DESCRIPCIN DEL CONCEPTO: CUOTA POR CONCEPTO DE PREINCRIPCIN.", FontFactory.getFont("arial", 10, Font.BOLD));
            //                descrConcepto.setAlignment(Element.ALIGN_CENTER);
            //                preficha.add(descrConcepto);

            preficha.add(vacio);
            preficha.add(vacio);
            preficha.add(vacio);
            //                preficha.add(vacio);
            //                preficha.add(vacio);
            //                preficha.add(vacio);
            //                preficha.add(vacio);
            //                preficha.add(vacio);

            Paragraph atencion = new Paragraph("Atencin", FontFactory.getFont("arial", 15, Font.BOLD));
            atencion.setAlignment(Element.ALIGN_CENTER);
            preficha.add(atencion);

            PdfContentByte rectangulo_atencion = writer.getDirectContentUnder();
            rectangulo_atencion.rectangle(245, 229, 100, 25);
            rectangulo_atencion.fill();
            drawRectangle(rectangulo_atencion, 245, 229, 100, 25);

            PdfContentByte rectangulo_info = writer.getDirectContentUnder();
            rectangulo_info.rectangle(85, 94, 430, 100);
            rectangulo_info.fill();
            drawRectangle(rectangulo_info, 85, 94, 430, 120);

            preficha.add(vacio);
            preficha.add(vacio);

            Paragraph informacion = new Paragraph(
                    "                        Para continuar con el proceso de preinscripcin debers:\n"
                            + "                           - Realizar el pago para tu examen de admisin con la \"REFERENCIA\" que aparece\n"
                            + "                             en este documento en cualquier sucursal BANAMEX.\n"
                            + "                           - Recibir la notificacin en tu correo electrnico y estar al pendiente de \n"
                            + "                             las notificaciones que sern enviadas al mismo de que el pago ya fue procesado \n"
                            + "                             para completar tu proceso de preinscripcin.\n",
                    FontFactory.getFont("arial", 10, Font.BOLD));
            informacion.setAlignment(Element.ALIGN_LEFT);
            preficha.add(informacion);
            //  pie
            //  pie
            //  pie
            //  pie
            //  pie
            preficha.add(vacio);
            preficha.add(vacio);

            preficha.addTitle("Preficha");
            preficha.addSubject("Instituto Tecnolgico de Toluca");
            preficha.addKeywords("Instituto Tecnolgico de Toluca");
            preficha.addAuthor("Departamento de Servicios escolares");
            preficha.addCreator("Departamento de Servicios escolares");

            preficha.close();

            preficha.close();
        } catch (DocumentException de) {
            throw new IOException(de.getMessage());
        }
    } catch (SQLException ex) {
        Logger.getLogger(PrefichaPDF.class.getName()).log(Level.SEVERE, null, ex);
    }
}

From source file:user_details.java

private void jButton5ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton5ActionPerformed

    int option = JOptionPane.showConfirmDialog(null, "Are you sure?");

    if (option == 0) {

        Document document = new Document();
        PdfWriter writer;/*from   w ww  . jav  a 2s  .c om*/
        try {
            try {
                writer = PdfWriter.getInstance(document, new FileOutputStream("Your_Resume.pdf"));
            } catch (FileNotFoundException ex) {
                Logger.getLogger(user_details.class.getName()).log(Level.SEVERE, null, ex);
            }

            Font fontdesign1 = FontFactory.getFont("Times-Roman", 20, Font.BOLD);
            Font fontdesign2 = FontFactory.getFont("Times-Roman", 10, Font.ITALIC);
            Font fontdesign4 = FontFactory.getFont("Times-Roman", 12, Font.BOLD);
            Font fontdesign3 = FontFactory.getFont("Times-Roman", 11);
            document.open();

            Paragraph namepara = new Paragraph(fname + " " + lname, fontdesign1);
            namepara.setAlignment(Element.ALIGN_CENTER);
            document.add(namepara);

            document.add(Chunk.NEWLINE);

            if (edu_details.equals("") || edu_details.equals("-")) {

            } else {
                Paragraph eduTitle = new Paragraph("EDUCATIONAL QUALIFICATION:", fontdesign4);
                document.add(eduTitle);

                Paragraph edupara = new Paragraph(edu_details, fontdesign3);
                document.add(edupara);
            }

            document.add(Chunk.NEWLINE);

            if (present_comp.equals("") || present_comp.equals("-")) {

            } else {
                Paragraph Present_compTitle = new Paragraph("CURRENT COMPANY AND POSITION:", fontdesign4);
                document.add(Present_compTitle);

                Paragraph Present_compPara = new Paragraph(present_comp, fontdesign3);

                document.add(Present_compPara);
            }

            document.add(Chunk.NEWLINE);

            if (past_emp.equals("") || past_emp.equals("-")) {

            } else {
                Paragraph Past_compTitle = new Paragraph("PAST EMPLOYMENT DETAILS:", fontdesign4);
                document.add(Past_compTitle);

                Paragraph Past_compPara = new Paragraph(past_emp, fontdesign3);
                document.add(Past_compPara);
            }

            document.add(Chunk.NEWLINE);

            if (key_responsibility.equals("") || key_responsibility.equals("-")) {

            } else {
                Paragraph KeyTitle = new Paragraph("KEY RESPONSIBILITIES: ", fontdesign4);
                document.add(KeyTitle);

                Paragraph Keypara = new Paragraph(key_responsibility, fontdesign3);
                document.add(Keypara);
            }

            document.add(Chunk.NEWLINE);

            if (accomplishments.equals("") || accomplishments.equals("-")) {

            } else {
                Paragraph AccTitle = new Paragraph("ACCOMPLISHMENTS AND ACHIEVEMENTS:", fontdesign4);
                document.add(AccTitle);

                Paragraph Accpara = new Paragraph(accomplishments, fontdesign3);
                document.add(Accpara);
            }

            document.add(Chunk.NEWLINE);

            if (training.equals("") || training.equals("-")) {

            } else {
                Paragraph TrainingTitle = new Paragraph("On-Job TRAININGS/SEMINARS/WORKSHOPS:", fontdesign4);
                document.add(TrainingTitle);

                Paragraph Trainingpara = new Paragraph(training, fontdesign3);
                document.add(Trainingpara);
            }

            document.add(Chunk.NEWLINE);

            Paragraph RefTitle = new Paragraph("REFERENCES:", fontdesign4);
            document.add(RefTitle);

            for (int i = 0; i < refno; i++) {
                Paragraph refpara = new Paragraph(i + 1 + "." + ref[i], fontdesign3);
                document.add(refpara);

            }
            document.add(Chunk.NEWLINE);
            document.add(Chunk.NEWLINE);

            Paragraph contactpara = new Paragraph("PHONE: " + contactNo, fontdesign2);
            document.add(contactpara);

            if (fthername.equals("") || fthername.equals("-")) {

            } else {
                Paragraph fthrnamepara = new Paragraph("FATHER'S NAME: " + fthername, fontdesign2);
                document.add(fthrnamepara);
            }

            Paragraph dobpara = new Paragraph("DOB: " + dob, fontdesign2);
            document.add(dobpara);

            Paragraph addresspara = new Paragraph("PERMANENT ADDRESS: " + pa, fontdesign2);
            document.add(addresspara);

            document.close();

        } catch (DocumentException ex) {
            Logger.getLogger(user_details.class.getName()).log(Level.SEVERE, null, ex);
        }

        references.dispose();
        new user_details().setVisible(true);
        JOptionPane.showMessageDialog(null,
                "Congratulations! Your resume has been created. Kindly check the directory.");
    } else {
        JOptionPane.showMessageDialog(null, "Okay! You can edit your Information.");

    }

}

From source file:imprimer.java

public void openPDF() {

    Document document = new Document(PageSize.A4);
    try {/*from w  w w.j a va  2  s  .co  m*/
        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 {//from ww w  .ja v a  2 s .  c o m
        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 {/*w  ww .jav  a2s .  com*/
        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 ww. j  a  v  a2  s. c om
        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 {/*from  ww w. j a  v  a  2s.c  o m*/
        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: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();/*from w  w w  .  j a  va  2 s .c  o 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:ara.Confirmsec.java

public void myfunction() throws IOException, DocumentException {
    String a = preres.getText();//from w w  w.ja  v a 2s  .  c o  m
    File file = new File(DEST);
    file.getParentFile().mkdirs();
    Document document = new Document();
    PdfWriter.getInstance(document, new FileOutputStream(DEST));
    document.open();
    Image image = Image.getInstance("logo.jpg");
    document.add(image);
    Font chapterFont = FontFactory.getFont(FontFactory.HELVETICA, 16, Font.BOLD);
    Font paragraphFont = FontFactory.getFont(FontFactory.HELVETICA, 12, Font.NORMAL);
    Font small = FontFactory.getFont(FontFactory.HELVETICA, 5, Font.BOLD);
    String date = new Date().toString();
    Paragraph paragraph1 = new Paragraph(date);
    Paragraph paragraph2 = new Paragraph("To Whom it May Concern", chapterFont);
    paragraph2.setAlignment(Element.ALIGN_CENTER);
    paragraph1.setAlignment(Element.ALIGN_RIGHT);
    paragraph2.setSpacingBefore(20f);
    paragraph2.setSpacingAfter(10f);
    Paragraph paragraph3 = new Paragraph(a, paragraphFont);
    paragraph3.setSpacingAfter(20f);
    Paragraph paragraph4 = new Paragraph("Registrar");
    paragraph4.setAlignment(Element.ALIGN_RIGHT);
    paragraph4.setSpacingAfter(100f);
    Paragraph paragraph5 = new Paragraph(
            "This is a digitally signed document. Use Ref No. " + c + " to verify.", small);
    document.add(paragraph1);
    document.add(paragraph2);
    document.add(paragraph3);
    document.add(paragraph4);
    document.add(paragraph5);
    document.close();
    JOptionPane.showMessageDialog(null, "Document Generated.");
}

From source file:avalonscrollmaker20.AnothakScribe.java

License:Open Source License

public void writeToDoc(ArrayList<AnothakScroll> spellList, boolean simpleMode) {
    // Format content for inserting into a PDF
    for (int i = 0; i < spellList.size(); i++) {
        Paragraph spellCode = new Paragraph(spellList.get(i).spellCode, f_code);
        spellCode.setAlignment(ElementTags.ALIGN_RIGHT);
        spellCode.setMultipliedLeading(0.5f);
        spellCode.setIndentationRight(15f);

        Paragraph spellTitle = new Paragraph(spellList.get(i).spellTitle + "\n", f_title);
        spellTitle.setAlignment(ElementTags.ALIGN_CENTER);
        spellTitle.setMultipliedLeading(0.5f);
        spellTitle.setSpacingAfter(36f);

        Paragraph spellCircleSchool;/*  w  w  w. j  a v a2s. c om*/
        if (spellList.get(i).isPure())
            spellCircleSchool = new Paragraph(spellList.get(i).spellCircle.toString() + " Circle\n    of "
                    + spellList.get(i).spellOldSchool.toString(), f_schoolPure);
        else // !spellList.get( i ).isPure()
            spellCircleSchool = new Paragraph(spellList.get(i).spellCircle.toString() + " Circle\n    of "
                    + spellList.get(i).spellOldSchool.toString(), f_school);
        spellCircleSchool.setAlignment(ElementTags.ALIGN_LEFT);
        spellCircleSchool.setIndentationLeft(18f);
        spellCircleSchool.setMultipliedLeading(1.75f);

        Paragraph sourceKeu = new Paragraph(spellList.get(i).sourceKeu.toString() + "|~", f_keu);
        sourceKeu.setAlignment(ElementTags.ALIGN_RIGHT);
        sourceKeu.setIndentationRight(36f);
        sourceKeu.setMultipliedLeading(1f);

        Paragraph directionKeu = new Paragraph("", f_keu);
        directionKeu.setAlignment(ElementTags.ALIGN_RIGHT);
        directionKeu.setIndentationRight(90f);
        directionKeu.setMultipliedLeading(0.875f);

        Paragraph destinationKeu = new Paragraph(spellList.get(i).destinationKeu.toString() + "|~", f_keu);
        destinationKeu.setAlignment(ElementTags.ALIGN_RIGHT);
        destinationKeu.setIndentationRight(36f);
        destinationKeu.setMultipliedLeading(0.625f);

        Paragraph phraseCommon;
        Paragraph phraseSymbol;

        if (spellList.get(i).spellCircle != Circle.SEVENTH
                && spellList.get(i).spellCircle != Circle.PURE_SEVENTH) {
            phraseCommon = new Paragraph("", f_phraseCommon);
            phraseCommon.setSpacingAfter(27f);
            phraseSymbol = new Paragraph("", f_phraseSymbol);
            if ((i % 2) <= 0)
                phraseSymbol.setSpacingAfter(90f);
            else // ( (i % 2) > 0 )
                phraseSymbol.setSpacingAfter(0f);
        } else {
            phraseCommon = new Paragraph("", f_phraseCommonBreath);
            phraseCommon.setSpacingAfter(36f);
            phraseSymbol = new Paragraph("", f_phraseSymbolBreath);
            if ((i % 2) <= 0)
                phraseSymbol.setSpacingAfter(103.5f);
            else // ( (i % 2) > 0 )
                phraseSymbol.setSpacingAfter(0f);
        }

        phraseCommon.setAlignment(ElementTags.ALIGN_CENTER);
        phraseCommon.setMultipliedLeading(1.5f);
        for (AnothakScroll.Word w : spellList.get(i).liersethPhrase_Common)
            phraseCommon.add(w.toString() + " ");

        if (simpleMode) {
            phraseSymbol.setAlignment(ElementTags.ALIGN_CENTER);
            phraseSymbol.setSpacingBefore(36f);
            phraseSymbol.setSpacingAfter(0f);
            phraseSymbol.setMultipliedLeading(0.75f);
        } else // not simpleMode
        {
            phraseSymbol.setAlignment(ElementTags.ALIGN_CENTER);
            phraseSymbol.setMultipliedLeading(0.5f);
        }

        for (AnothakScroll.Symbol s : spellList.get(i).liersethPhrase_Symbol) {
            phraseSymbol.add(s.toString());
        }

        // Add content to the document
        try {
            if (simpleMode)
                doc_scrolls.add(phraseSymbol);
            else {
                Image tmpImage = null;
                tmpImage = spellList.get(i).backgroundImageFull;

                if (tmpImage != null) {
                    if ((i % 2) <= 0)
                        tmpImage.setAbsolutePosition(9f, 405f);
                    else // (i % 2) >= 0
                        tmpImage.setAbsolutePosition(9f, 9f);

                    doc_scrolls.add(tmpImage);
                }

                //doc_scrolls.add( Chunk.NEWLINE );
                doc_scrolls.add(spellCode);
                doc_scrolls.add(spellTitle);

                // Crap, I hate formatting
                MultiColumnText mct = new MultiColumnText(108f);
                mct.addRegularColumns(doc_scrolls.left(), doc_scrolls.right(), 54f, 2);
                mct.addElement(spellCircleSchool);
                mct.addElement(sourceKeu);
                mct.addElement(directionKeu);
                mct.addElement(destinationKeu);

                doc_scrolls.add(mct);

                doc_scrolls.add(new Chunk("\n", new Font(Font.FontFamily.COURIER, 18f, Font.NORMAL)));

                doc_scrolls.add(phraseCommon);
                doc_scrolls.add(phraseSymbol);

                if ((i % 2) > 0)
                    doc_scrolls.newPage();
            }

        } catch (Exception ex) {
            System.err.println(ex + "\nProgram closing.");
            System.exit(4);
        }
    }

    // Close the Document
    doc_scrolls.close();

    JOptionPane.showMessageDialog(null, doc_name + " was printed successfully!", "Print Status",
            JOptionPane.INFORMATION_MESSAGE);
}