Example usage for com.itextpdf.text Document addCreator

List of usage examples for com.itextpdf.text Document addCreator

Introduction

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

Prototype


public boolean addCreator(String creator) 

Source Link

Document

Adds the creator to a Document.

Usage

From source file:PrintProjects.java

protected void processRequest(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {

    try {/*  ww w.j a va 2 s  .  c  o  m*/
        response.setContentType("Invoice.pdf");
        //Get the output stream for writing PDF object
        OutputStream out = response.getOutputStream();
        SystemDao dao = new SystemDao();

        String username_dbase = getServletContext().getInitParameter("username");
        String dbasepsw = getServletContext().getInitParameter("password");
        String dbase = getServletContext().getInitParameter("jdbcConnection");
        dao.open(username_dbase, dbasepsw, dbase);

        Document document = new Document();
        /* Basic PDF Creation inside servlet */

        ArrayList<User> users = dao.gettAllUsers();
        //tithes
        ArrayList<Donation> list = dao.getAllDonations();
        ArrayList<String> projects = dao.getProjects();

        PdfWriter.getInstance(document, out);

        document.open();
        document.addAuthor("LightHouse Chapel International");
        document.addCreationDate();
        document.addCreator("lci.com");

        document.add(new Paragraph("============ PROJECTS ==========="));
        document.add(new Paragraph(" "));
        document.add(new Paragraph(" "));

        document.add(new Paragraph("   NAME     " + "                  " + " NUMBER   "));
        for (int x = 0; x < projects.size(); ++x) {
            String[] data = projects.get(x).split("@");
            document.add(new Paragraph("  " + data[1] + "                  " + data[0]));
        }
        document.add(new Paragraph(" "));
        document.add(new Paragraph(" "));
        document.add(new Paragraph(" "));
        document.add(new Paragraph("Total Donations : " + projects.size()));
        document.add(new Paragraph(" "));
        document.add(new Paragraph(" "));
        document.close();
    } catch (Exception ex) {
        response.sendRedirect("systemError.jsp");
    }
}

From source file:PrefichaPDF.java

protected void doGet(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
    try {//  w  ww . j  a v  a2s.co  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:pdfservlet.java

/**
 * Handles the HTTP <code>POST</code> method.
 *
 * @param request servlet request/*  w w w. jav  a2  s.  c  o m*/
 * @param response servlet response
 * @throws ServletException if a servlet-specific error occurs
 * @throws IOException if an I/O error occurs
 */
@Override
protected void doPost(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
    ResultSet resultSet = null;
    Statement statement = null;
    try {
        Connection connection = ConnectionManager.createConnectionToDB();

        String query = "SELECT * FROM employees";
        statement = connection.createStatement();
        resultSet = statement.executeQuery(query);
    } catch (SQLException e) {
        e.printStackTrace();
    }

    response.setContentType("application/pdf");
    Document document = new Document();
    Font font3 = new Font(Font.FontFamily.TIMES_ROMAN, 8);
    Font font4 = new Font(Font.FontFamily.TIMES_ROMAN, 10, Font.BOLD);
    Font font2 = new Font(Font.FontFamily.COURIER, 10, Font.UNDERLINE);

    try {

        PdfWriter.getInstance(document, response.getOutputStream());
        document.open();
        document.add(new Phrase(new Date().toString() + "\n", font3));
        String imageUrl = "http://www.technolinks.in/images/bhel_logo.jpg";

        Image image2 = Image.getInstance(new URL(imageUrl));
        image2.scaleAbsolute(100f, 100f);
        image2.setAbsolutePosition(25f, 725f);
        document.add(image2);

        document.add(new Phrase(
                "                                                                                                               BHEL Recruitment for Medical Professionals \n                                                              ",
                font3));
        document.add(new Phrase("Admit Card for Interview of Medical Professional in BHEL\n", font2));
        document.add(
                new Phrase("                                                 Acknowledgement No :", font3));

        document.addCreator("Shivin");
        document.addTitle("BHEL");

        resultSet.next();
        String trade_id = "100003";
        do {
            if (trade_id.matches(resultSet.getString("TRADE")))
                break;

        } while (resultSet.next());

        document.add(new Phrase("Post Applied:           " + resultSet.getString("TRADE") + "\n"));
        document.add(new Phrase("Name:                   " + resultSet.getString("FIRSTNAME") + "\n"));
        document.add(new Phrase("Father's/Husband's Name:" + resultSet.getString("FATHERNAME")));
        document.add(new Phrase("Address:                " + resultSet.getString("ADDRESS1") + "\n"
                + resultSet.getString("ADDRESS2") + "\n" + resultSet.getString("DISTRICT")
                + resultSet.getString("CITY") + "\n"));
        document.add(new Phrase("State:                  " + resultSet.getString("STATE") + "\n"));
        document.add(new Phrase("Pin:                    " + resultSet.getString("PIN") + "\n"));
        document.add(new Phrase("Caste:                  " + resultSet.getString("CASTE") + "\n"));
        document.add(new Phrase("Interview Date:         " + resultSet.getString("INTERVIEW_DATE") + "\n"));
        document.add(
                new Phrase("Interview Time:                  " + resultSet.getString("INTERVIEW_TIME") + "\n"));
        document.add(
                new Phrase("Reporting Time:                  " + resultSet.getString("REPORTING_TIME") + "\n"));
        document.add(new Phrase("Interview Venue:          " + resultSet.getString("INTERVIEW_VENUE") + "\n"));

        document.add(new Phrase("Important Instructions: \n", font4));
        document.add(
                new Paragraph("1.You must bring along with you the original documents and 01 selfattested\n"
                        + "photocopy of the following :\n"
                        + "Xth Certificate/ Birth Certificate mentioning Date of Birth\n"
                        + "MBBS Degree Certificate / Marksheets of all year\n"
                        + "PG Diploma / PG Degree / DNB Certificate in relevant discipline\n"
                        + "Medical Council Registration Certificate\n"
                        + "Post Qualification Experience Certificate in support of the experience being claimed\n"
                        + "Certificate for SC/ST in the prescribed format, if applicable\n"
                        + "Certificate for OBC indicating Non Creamy Layer status in the prescribed format, if applicable\n"
                        + "Self Undertaking for Non Creamy Layer status of OBC in the prescribed format, if applicable\n"
                        + "Medical Certificate for Physically Handicapped candidates for their disability from Government Hospital or Medical Board, if applicable.\n"
                        + "Discharge Certificate for ExServicemen\n"
                        + "NOC from the present employer, if applicable\n"
                        + "2. The shortlisted candidates after attending the interviews will be reimbursed train fare to the extent of single AC 2nd class return train fare\n"
                        + "from the address mentioned in the Application form to Interview Centre, by the shortest route subject to submission of rail/bus Ticket\n"
                        + "3. Please ensure that you fulfill all the prescribed job specifications as advertised and produce all the relevant documents thereof as aforesaid (as\n"
                        + "applicable to you), failing which we will not be able to interview you nor reimburse the Travelling Allowance. In case it is found that a\n"
                        + "candidate does not possess the qualification and /or other specification as prescribed in our advertisement, their candidature will be cancelled abinitio\n"
                        + "and no Travelling Allowance will be paid.\n"
                        + "4. You have the option to answer either in English or in Hindi during the Interview. Please note that no change of Interview place and/or date of\n"
                        + "interview will be possible. Also, we will not be able to respond to any individual queries regarding the results of personal Interview."));
        document.add(new Phrase("Declaration by the candidate: \n", font4));
        document.add(new Paragraph(
                "I understand that my permission to this test interview is provisional and if it is found at the later date that I do not fulfill the essential eligibility\n"
                        + "criteria regarding qualification, marks, age, caste, Experience etc. as per requirement of the Company, I will be debarred abinitio\n"
                        + "and I will not\n" + "be able to make any claim to the post."));
        document.add(new Phrase("DATE:", font2));
        document.add(new Phrase("\n"));
        document.add(new Phrase("PLACE:", font2));
        document.add(new Phrase("\n"));

        /* PdfPTable table2 = new PdfPTable(1);
                 
         table2.addCell("1.");
         table2.addCell("2.");
         table2.addCell("3.");
                
                 
                
          document.add(new Paragraph("                                                 \n\n\n\n            \n\n\n\n\n\n"));
                
          document.add(new Paragraph("             *Terms and Conditions      \n                               "));
                  
          document.add(table2); 
          document.close();
                  
                  
                  
        */
    } catch (Exception e) {
        e.printStackTrace();

    }

    /**
     * Returns a short description of the servlet.
     *
     * @return a String containing servlet description
     */

}

From source file:PDFmaker.java

private static void addMetaData(Document document) {
    document.addTitle("My first PDF");
    document.addSubject("Using iText");
    document.addKeywords("Java, PDF, iText");
    document.addAuthor("Lars Vogel");
    document.addCreator("Lars Vogel");
}

From source file:PrintAll.java

/**
 * Processes requests for both HTTP <code>GET</code> and <code>POST</code>
 * methods.//www  .  j a v a  2s .  c o m
 *
 * @param request servlet request
 * @param response servlet response
 * @throws ServletException if a servlet-specific error occurs
 * @throws IOException if an I/O error occurs
 */
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
    try {
        response.setContentType("Invoice.pdf");
        //Get the output stream for writing PDF object
        OutputStream out = response.getOutputStream();
        SystemDao dao = new SystemDao();

        String username_dbase = getServletContext().getInitParameter("username");
        String dbasepsw = getServletContext().getInitParameter("password");
        String dbase = getServletContext().getInitParameter("jdbcConnection");
        dao.open(username_dbase, dbasepsw, dbase);

        Document document = new Document();
        /* Basic PDF Creation inside servlet */

        ArrayList<User> users = dao.gettAllUsers();
        //tithes
        ArrayList<Donation> list = dao.getAllDonations();
        ArrayList<String> projects = dao.getProjects();
        //donaations
        Vector<String> donations = dao.get_donation();

        PdfWriter.getInstance(document, out);

        document.open();
        document.addAuthor("LightHouse Chapel International");
        document.addCreationDate();
        document.addCreator("lci.com");
        document.addTitle("USER INFORMATION SUMMARY");
        document.add(new Paragraph("LightHouse Chapel International"));

        document.add(new Paragraph(" "));
        document.add(new Paragraph("INFORMATION SUMMARY"));
        document.add(new Paragraph(" "));

        document.add(new Paragraph("=========== TITHES ==============="));
        document.add(new Paragraph(" "));

        document.add(new Paragraph(" "));
        document.add(new Paragraph("Amount " + "                  " + "Date "));
        document.add(new Paragraph(""));

        double total = 0.00;
        for (int x = 0; x < list.size(); ++x) {
            total += list.get(x).getAmount();
            document.add(new Paragraph(x + " " + list.get(x).getAmount() + "   " + list.get(x).getDate()));
        }

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

        document.add(new Paragraph(" "));
        document.add(new Paragraph("============ USERS ==========="));

        document.add(new Paragraph(" "));
        document.add(new Paragraph("   NAME     " + "   SURNAME   " + "  ACCOUNT NUMBER  "));
        for (User user : users) {
            document.add(new Paragraph("  " + user.getName() + "  " + "  " + user.getSurname() + "  " + "  "
                    + user.getAccountNumber()));
        }

        document.add(new Paragraph(" "));
        document.add(new Paragraph("============ PROJECTS ==========="));

        document.add(new Paragraph(" "));
        document.add(new Paragraph("   NAME     " + "   NUMBER   " + "  COST  "));
        for (int x = 0; x < projects.size(); ++x) {
            String[] data = projects.get(x).split("@");
            document.add(new Paragraph("  " + data[1] + "  " + "  " + data[0] + "  " + "  " + data[4]));
        }

        document.close();
    } catch (Exception ex) {
        Logger.getLogger(PrintAll.class.getName()).log(Level.SEVERE, null, ex);
    }

}

From source file:PrintTitheReport.java

/**
 * Processes requests for both HTTP <code>GET</code> and <code>POST</code>
 * methods.//  w  w  w.  j ava 2 s .  c  o  m
 *
 * @param request servlet request
 * @param response servlet response
 * @throws ServletException if a servlet-specific error occurs
 * @throws IOException if an I/O error occurs
 */
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {

    try {
        response.setContentType("Invoice.pdf");
        //Get the output stream for writing PDF object
        OutputStream out = response.getOutputStream();
        SystemDao dao = new SystemDao();

        String username_dbase = getServletContext().getInitParameter("username");
        String dbasepsw = getServletContext().getInitParameter("password");
        String dbase = getServletContext().getInitParameter("jdbcConnection");
        dao.open(username_dbase, dbasepsw, dbase);

        Document document = new Document();
        /* Basic PDF Creation inside servlet */

        ArrayList<User> users = dao.gettAllUsers();
        //tithes
        ArrayList<Donation> list = dao.getAllDonations();
        ArrayList<String> projects = dao.getProjects();

        PdfWriter.getInstance(document, out);

        document.open();
        document.addAuthor("LightHouse Chapel International");
        document.addCreationDate();
        document.addCreator("lci.com");

        document.add(new Paragraph("=========== TITHES ==============="));
        document.add(new Paragraph(" "));
        document.add(new Paragraph(" "));
        document.add(new Paragraph(" "));
        document.add(new Paragraph("Amount " + "                  " + "Date "));
        document.add(new Paragraph(""));
        document.add(new Paragraph(""));

        double total = 0.00;
        for (int x = 0; x < list.size(); ++x) {
            total += list.get(x).getAmount();

            document.add(new Paragraph(
                    (1 + x) + " " + list.get(x).getAmount() + "                  " + list.get(x).getDate()));
        }
        document.add(new Paragraph(""));
        document.add(new Paragraph(""));
        document.add(new Paragraph(""));
        document.add(new Paragraph(""));
        document.add(new Paragraph(""));
        document.add(new Paragraph(""));
        document.add(new Paragraph("Total Number of people who paid tithe :   " + list.size()));
        document.close();

    } catch (Exception ex) {
        response.sendRedirect("systemError.jsp");
    }

}

From source file:PrintingServlet.java

/**
 * Processes requests for both HTTP <code>GET</code> and <code>POST</code>
 * methods./*  ww w .ja va  2 s.c  o  m*/
 *
 * @param request servlet request
 * @param response servlet response
 * @throws ServletException if a servlet-specific error occurs
 * @throws IOException if an I/O error occurs
 */
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException, DocumentException {

    try {
        response.setContentType("Invoice.pdf");
        //Get the output stream for writing PDF object
        OutputStream out = response.getOutputStream();
        SystemDao dao = new SystemDao();

        String username_dbase = getServletContext().getInitParameter("username");
        String dbasepsw = getServletContext().getInitParameter("password");
        String dbase = getServletContext().getInitParameter("jdbcConnection");
        dao.open(username_dbase, dbasepsw, dbase);

        Document document = new Document();
        /* Basic PDF Creation inside servlet */

        ArrayList<User> users = dao.gettAllUsers();
        //tithes
        ArrayList<Donation> list = dao.getAllDonations();
        ArrayList<String> projects = dao.getProjects();
        //donaations
        Vector<String> donations = dao.get_donation();

        PdfWriter.getInstance(document, out);

        document.open();
        document.addAuthor("LightHouse Chapel International");
        document.addCreationDate();
        document.addCreator("lci.com");
        document.addTitle("USER INFORMATION SUMMARY");
        document.add(new Paragraph("LightHouse Chapel International"));
        document.add(new Paragraph(" "));
        document.add(new Paragraph(" "));
        document.add(new Paragraph("INFORMATION SUMMARY"));
        document.add(new Paragraph(" "));
        document.add(new Paragraph(" "));
        document.add(new Paragraph("=========== TITHES ==============="));
        document.add(new Paragraph(" "));
        document.add(new Paragraph(" "));
        document.add(new Paragraph(" "));
        document.add(new Paragraph("Amount " + "                  " + "Date "));
        document.add(new Paragraph(""));
        document.add(new Paragraph(""));

        double total = 0.00;
        for (int x = 0; x < list.size(); ++x) {
            total += list.get(x).getAmount();
            document.add(new Paragraph(x + " " + list.get(x).getAmount() + "   " + list.get(x).getDate()));
        }

        document.add(new Paragraph(" "));
        document.add(new Paragraph(" "));
        document.add(new Paragraph(" "));
        document.add(new Paragraph("============ USERS ==========="));
        document.add(new Paragraph(" "));
        document.add(new Paragraph(" "));
        document.add(new Paragraph("   NAME     " + "   SURNAME   " + "  ACCOUNT NUMBER  "));
        for (User user : users) {
            document.add(new Paragraph("  " + user.getName() + "  " + "  " + user.getSurname() + "  " + "  "
                    + user.getAccountNumber()));
        }

        document.add(new Paragraph(" "));
        document.add(new Paragraph(" "));
        document.add(new Paragraph(" "));
        document.add(new Paragraph("============ PROJECTS ==========="));
        document.add(new Paragraph(" "));
        document.add(new Paragraph(" "));
        document.add(new Paragraph("   NAME     " + "   NUMBER   " + "  COST  "));
        for (int x = 0; x < projects.size(); ++x) {
            String[] data = projects.get(x).split("@");
            document.add(new Paragraph("  " + data[1] + "  " + "  " + data[0] + "  " + "  " + data[4]));
        }
    } catch (SQLException ex) {
        response.sendRedirect("systemError.jsp");
    } catch (ClassNotFoundException ex) {
        response.sendRedirect("systemError.jsp");
    }
}

From source file:PrintDonations.java

/**
 * Processes requests for both HTTP <code>GET</code> and <code>POST</code>
 * methods.//w ww .  j ava 2 s . c  om
 *
 * @param request servlet request
 * @param response servlet response
 * @throws ServletException if a servlet-specific error occurs
 * @throws IOException if an I/O error occurs
 */
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
    try {
        response.setContentType("Invoice.pdf");
        //Get the output stream for writing PDF object
        OutputStream out = response.getOutputStream();
        SystemDao dao = new SystemDao();

        String username_dbase = getServletContext().getInitParameter("username");
        String dbasepsw = getServletContext().getInitParameter("password");
        String dbase = getServletContext().getInitParameter("jdbcConnection");
        dao.open(username_dbase, dbasepsw, dbase);

        Document document = new Document();
        /* Basic PDF Creation inside servlet */

        ArrayList<User> users = dao.gettAllUsers();
        //tithes
        ArrayList<Donation> list = dao.getAllDonations();
        ArrayList<String> projects = dao.getProjects();
        //donaations
        Vector<String> donations = dao.get_donation();

        PdfWriter.getInstance(document, out);

        document.open();
        document.addAuthor("LightHouse Chapel International");
        document.addCreationDate();
        document.addCreator("lci.com");

        document.add(new Paragraph(" "));
        document.add(new Paragraph("============ PROJECTS ==========="));
        document.add(new Paragraph(" "));
        document.add(new Paragraph(" "));
        document.add(new Paragraph("NAME" + "                  " + "NUMBER" + "                  " + "COST"));
        for (int x = 0; x < projects.size(); ++x) {
            String[] data = projects.get(x).split("@");
            document.add(new Paragraph(
                    "  " + data[1] + "                  " + data[0] + "                  " + data[4]));
        }
        document.add(new Paragraph(" "));
        document.add(new Paragraph(" "));
        document.add(new Paragraph(" Total Projects : " + projects.size()));
        document.add(new Paragraph(" "));
        document.close();
    } catch (Exception ex) {
        response.sendRedirect("systemError.jsp");
    }
}

From source file:CrearPdf.java

private void addMetaData(Document document) {
    document.addTitle("Mi empresa");
    document.addSubject("mi direccion");
    document.addKeywords("Java, PDF, iText");
    document.addAuthor(autor);//  ww  w  .  j a va  2s . c o  m
    document.addCreator(fecha);
}

From source file:PrintMaleMembers.java

/**
 * Processes requests for both HTTP <code>GET</code> and <code>POST</code>
 * methods./*  www . j  av a  2  s  .co  m*/
 *
 * @param request servlet request
 * @param response servlet response
 * @throws ServletException if a servlet-specific error occurs
 * @throws IOException if an I/O error occurs
 */
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
    try {
        response.setContentType("Invoice.pdf");
        //Get the output stream for writing PDF object
        OutputStream out = response.getOutputStream();
        SystemDao dao = new SystemDao();

        String username_dbase = getServletContext().getInitParameter("username");
        String dbasepsw = getServletContext().getInitParameter("password");
        String dbase = getServletContext().getInitParameter("jdbcConnection");
        dao.open(username_dbase, dbasepsw, dbase);

        Document document = new Document();
        /* Basic PDF Creation inside servlet */

        ArrayList<User> users = dao.gettAllUsers();
        //tithes
        ArrayList<Donation> list = dao.getAllDonations();
        ArrayList<String> projects = dao.getProjects();
        //donaations
        Vector<String> donations = dao.get_donation();

        PdfWriter.getInstance(document, out);

        document.open();
        document.addAuthor("LightHouse Chapel International");
        document.addCreationDate();
        document.addCreator("lci.com");
        document.addTitle("USER INFORMATION SUMMARY");

        document.add(new Paragraph(" "));
        document.add(new Paragraph("============ USERS ==========="));
        document.add(new Paragraph(" "));
        document.add(new Paragraph(" "));
        document.add(new Paragraph("   NAME     " + "                  " + "   SURNAME   "
                + "                  " + "  ACCOUNT NUMBER  "));
        for (User user : users) {
            document.add(new Paragraph("  " + user.getName() + "                  " + user.getSurname()
                    + "                  " + user.getEmail()));
        }
        document.add(new Paragraph(" "));
        document.add(new Paragraph(" "));
        document.add(new Paragraph(" Total Users : " + users.size()));
        document.add(new Paragraph(" "));
        document.close();
    } catch (Exception ex) {
        response.sendRedirect("systemError.jsp");
    }
}