Example usage for com.itextpdf.text FontFactory HELVETICA

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

Introduction

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

Prototype

String HELVETICA

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

Click Source Link

Document

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

Usage

From source file:be.mxs.common.util.pdf.general.dossierCreators.StaffDossierPDFCreator.java

private void addDisciplinaryRecordDetails(PdfPTable table, DisciplinaryRecord disRec) {
    if (disRec.followUp.length() > 0) {
        PdfPTable detailsTable = new PdfPTable(10);
        detailsTable.setWidthPercentage(100);

        // follow-up in grey and italic
        //detailsTable.addCell(createValueCell(disRec.followUp.replaceAll("\r\n"," "),10));
        Font font = FontFactory.getFont(FontFactory.HELVETICA, 7, Font.ITALIC);
        font.setColor(BaseColor.GRAY);//from w ww.  ja v  a  2s .c  om
        cell = new PdfPCell(new Paragraph(disRec.followUp.replaceAll("\r\n", " "), font));
        cell.setColspan(10);
        cell.setBorder(PdfPCell.BOX);
        cell.setBorderColor(innerBorderColor);
        cell.setVerticalAlignment(PdfPCell.ALIGN_TOP);
        cell.setHorizontalAlignment(PdfPCell.ALIGN_LEFT);
        detailsTable.addCell(cell);

        table.addCell(createCell(new PdfPCell(detailsTable), table.getNumberOfColumns(), PdfPCell.ALIGN_CENTER,
                PdfPCell.BOX));
    }
}

From source file:be.mxs.common.util.pdf.general.dossierCreators.StaffDossierPDFCreator.java

private void addLeaveDetails(PdfPTable table, Leave leave) {
    if (leave.comment.length() > 0) {
        PdfPTable detailsTable = new PdfPTable(10);
        detailsTable.setWidthPercentage(100);

        // follow-up in grey and italic
        //detailsTable.addCell(createValueCell(leave.comment.replaceAll("\r\n"," "),10));
        Font font = FontFactory.getFont(FontFactory.HELVETICA, 7, Font.ITALIC);
        font.setColor(BaseColor.GRAY);/*from   ww  w .  j  av  a 2 s.c o m*/
        cell = new PdfPCell(new Paragraph(leave.comment.replaceAll("\r\n", " "), font));
        cell.setColspan(10);
        cell.setBorder(PdfPCell.BOX);
        cell.setBorderColor(innerBorderColor);
        cell.setVerticalAlignment(PdfPCell.ALIGN_TOP);
        cell.setHorizontalAlignment(PdfPCell.ALIGN_LEFT);
        detailsTable.addCell(cell);

        table.addCell(createCell(new PdfPCell(detailsTable), table.getNumberOfColumns(), PdfPCell.ALIGN_CENTER,
                PdfPCell.BOX));
    }
}

From source file:be.mxs.common.util.pdf.general.dossierCreators.StaffDossierPDFCreator.java

private void addCareerDetails(PdfPTable table, Career career) {
    if (career.comment.length() > 0) {
        PdfPTable detailsTable = new PdfPTable(10);
        detailsTable.setWidthPercentage(100);

        // comment in grey and italic
        //detailsTable.addCell(createValueCell(career.comment.replaceAll("\r\n"," "),10));
        Font font = FontFactory.getFont(FontFactory.HELVETICA, 7, Font.ITALIC);
        font.setColor(BaseColor.GRAY);// w  w w. j  av a  2  s  .co m
        cell = new PdfPCell(new Paragraph(career.comment.replaceAll("\r\n", " "), font));
        cell.setColspan(10);
        cell.setBorder(PdfPCell.BOX);
        cell.setBorderColor(innerBorderColor);
        cell.setVerticalAlignment(PdfPCell.ALIGN_TOP);
        cell.setHorizontalAlignment(PdfPCell.ALIGN_LEFT);
        detailsTable.addCell(cell);

        table.addCell(createCell(new PdfPCell(detailsTable), table.getNumberOfColumns(), PdfPCell.ALIGN_CENTER,
                PdfPCell.BOX));
    }
}

From source file:be.mxs.common.util.pdf.general.oc.examinations.PDFDrivingLicenseDeclaration.java

private void addQuestionnaire() {
    if (isAtLeastOneQuestionAnswered()) {
        contentTable = new PdfPTable(1);
        table = new PdfPTable(5);

        PdfPTable questions = new PdfPTable(40);

        // header
        questions.addCell(createTitleCell(
                getTran("medwan.common.driving-license-declaration.candidate-questionnaire"), 40));

        // questions
        String questionPrefix = "medwan.common.driving-license-declaration.candidate-questionnaire.question-";
        for (int i = 1; i <= 20; i++) {
            questions = addQuestion(questions, i, getTran(questionPrefix + i),
                    IConstants_PREFIX + "ITEM_TYPE_DLD_Q" + i);
        }//  w  w w . jav a 2s  . co m

        // commitment
        String commPart1 = getTran(
                "medwan.common.driving-license-declaration.candidate-questionnaire.commitment") + " ";
        String commPart2 = getTran(
                "medwan.common.driving-license-declaration.candidate-questionnaire.commitment1");

        cell = new PdfPCell(new Phrase(commPart1 + commPart2, FontFactory.getFont(FontFactory.HELVETICA,
                Math.round((double) 7 * fontSizePercentage / 100.0), Font.BOLD)));
        cell.setColspan(40);
        cell.setBorder(PdfPCell.BOX);
        cell.setBorderColor(innerBorderColor);
        cell.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
        questions.addCell(cell);

        // add content to document
        if (questions.size() > 0) {
            contentTable
                    .addCell(createCell(new PdfPCell(questions), 1, PdfPCell.ALIGN_CENTER, PdfPCell.NO_BORDER));
            tranTable.addCell(createContentCell(contentTable));
        }
    }
}

From source file:be.mxs.common.util.pdf.general.oc.examinations.PDFDrivingLicenseDeclaration.java

private PdfPTable addQuestion(PdfPTable table, int id, String question, String answer) {
    // cel 1 : nr
    cell = new PdfPCell(new Phrase(id + "", FontFactory.getFont(FontFactory.HELVETICA,
            Math.round((double) 7 * fontSizePercentage / 100.0), Font.NORMAL)));
    cell.setColspan(1);/*from  w  w  w  .  ja  v a2s  .  co  m*/
    cell.setBorder(PdfPCell.BOX);
    cell.setBorderColor(innerBorderColor);
    cell.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
    table.addCell(cell);

    // cel 2-38 : question
    cell = new PdfPCell(new Phrase(question, FontFactory.getFont(FontFactory.HELVETICA,
            Math.round((double) 7 * fontSizePercentage / 100.0), Font.NORMAL)));
    cell.setColspan(37);
    cell.setBorder(PdfPCell.BOX);
    cell.setBorderColor(innerBorderColor);
    cell.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
    table.addCell(cell);

    // cel 39 and 40 : answer
    cell = new PdfPCell(new Phrase(getTran(getItemValue(answer)), FontFactory.getFont(FontFactory.HELVETICA,
            Math.round((double) 7 * fontSizePercentage / 100.0), Font.NORMAL)));
    cell.setColspan(2);
    cell.setBorder(PdfPCell.BOX);
    cell.setBorderColor(innerBorderColor);
    cell.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
    table.addCell(cell);

    return table;
}

From source file:be.zenodotus.creatie.GeneratePDF.java

License:Open Source License

public String vakantieAfdruk(Context context, String name, int jaar) {
    this.context = context;
    PdfWriter w = null;//from   w ww  . j a  v a2  s  .c  o m
    Document d = new Document(PageSize.A4.rotate(), 5, 5, 10, 10);
    d.setPageCount(3);
    String fileName = name;
    String file = name;
    GregorianCalendar datum = new GregorianCalendar();
    datum.set(GregorianCalendar.YEAR, jaar);

    String[] maanden = { "Januari", "Februari", "Maart", "April", "Mei", "Juni", "Juli", "Augustus",
            "September", "Oktober", "November", "December" };
    int[] dagen = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
    VerlofDao dao = new VerlofDao(context);
    FeestdagDao feestdagDao = new FeestdagDao(context);
    WerkdagDao werkdagDao = new WerkdagDao(context);
    File folder = new File(context.getFilesDir(), "pdfs");
    folder.mkdirs();
    if (datum.isLeapYear(jaar)) {
        dagen[1] = 29;
    }
    File temp = null;
    temp = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS),
            "Jacqueline" + jaar + ".pdf");
    fileName = temp.toString();
    try {
        dao.open();
        ArrayList<Verlof> verloflijst = dao.getAlleVerlovenPerJaar(jaar);
        w = PdfWriter.getInstance(d, new FileOutputStream(temp));
        d.open();
        d.addAuthor("Jacqueline Vandenbroecke");
        d.addCreationDate();
        d.addCreator("Verlofplanner");
        d.addTitle("Vakantie " + jaar + " van Jacqueline Vandenbroecke");
        Font standaard = FontFactory.getFont(FontFactory.HELVETICA, 8);
        Font standaardBold = FontFactory.getFont(FontFactory.HELVETICA, 8, Font.BOLD);
        Paragraph gegeven = new Paragraph("Jacqueline Vandenbroecke Verlof " + jaar + "\n", standaardBold);
        gegeven.setAlignment(Paragraph.ALIGN_CENTER);
        d.add(gegeven);

        for (int paginas = 0; paginas < 2; paginas++) {
            int aantal = 0;
            if (paginas == 1) {
                d.newPage();
                aantal = 6;
            }
            PdfPTable table = new PdfPTable(6);
            for (int i = aantal; i < (aantal + 6); i++) {
                PdfPCell cell = new PdfPCell(new Paragraph(maanden[i], standaardBold));
                cell.setBorder(1);
                table.addCell(cell);
            }
            int dag = 1;
            int k = aantal;
            for (int i = aantal; i < (aantal + 6); i++) {
                for (int j = 0; j < 32; j++) {
                    if (k > ((aantal + 6) - 1)) {
                        k = aantal;
                        dag++;
                    }
                    if (dag > dagen[k]) {
                        PdfPCell cell = new PdfPCell(new Paragraph("", standaard));
                        table.addCell(cell);
                        k++;
                    } else {
                        SimpleDateFormat formatterDag = new SimpleDateFormat("dd");
                        SimpleDateFormat formatterWeek = new SimpleDateFormat("EEE");
                        datum.set(jaar, k, dag);
                        PdfPTable dagTabel = new PdfPTable(4);
                        PdfPCell cellDag = new PdfPCell(
                                new Paragraph(formatterDag.format(datum.getTime()), standaard));
                        PdfPCell cellWeek = new PdfPCell(
                                new Paragraph(formatterWeek.format(datum.getTime()), standaard));
                        ArrayList<Verlof> verlof = new ArrayList<Verlof>();
                        for (int z = 0; z < verloflijst.size(); z++) {
                            if (((verloflijst.get(z).getDag() + 1) == dag)
                                    && (verloflijst.get(z).getMaand() == k)) {
                                verlof.add(verloflijst.get(z));

                            }
                        }
                        feestdagDao.open();
                        Feestdag feestdag = feestdagDao.getFeestdag(jaar, datum.get(GregorianCalendar.MONTH),
                                datum.get(GregorianCalendar.DATE));
                        feestdagDao.close();
                        werkdagDao.open();
                        java.util.List<Werkdag> weekend = werkdagDao.getWeekend();
                        werkdagDao.close();
                        String Verlof = "";
                        String uur = "";
                        if (verlof.size() > 0) {
                            if (verlof.size() > 1) {
                                Verlof = verlof.get(0).getVerlofsoort() + "\n" + verlof.get(1).getVerlofsoort();
                                uur = verlof.get(0).getUrental() + "\n" + verlof.get(1).getUrental();
                            } else {
                                Verlof = verlof.get(0).getVerlofsoort();
                                uur = verlof.get(0).getUrental();
                            }

                        }
                        PdfPCell cellVerlof = new PdfPCell(new Paragraph(Verlof, standaard));
                        PdfPCell uren = new PdfPCell(new Paragraph(uur, standaard));
                        if (verlof.size() > 0) {
                            BaseColor kleur = new BaseColor(Color.GRAY);
                            cellVerlof.setBackgroundColor(kleur);
                            uren.setBackgroundColor(kleur);
                            cellDag.setBackgroundColor(kleur);
                            cellWeek.setBackgroundColor(kleur);
                        }
                        for (int z = 0; z < weekend.size(); z++) {
                            if ((formatterWeek.format(datum.getTime())).equals(weekend.get(z).getDag())) {
                                BaseColor kleur = new BaseColor(Color.LTGRAY);
                                cellVerlof.setBackgroundColor(kleur);
                                uren.setBackgroundColor(kleur);
                                cellDag.setBackgroundColor(kleur);
                                cellWeek.setBackgroundColor(kleur);
                            }
                        }
                        if (feestdag != null) {
                            BaseColor kleur = new BaseColor(Color.GREEN);
                            uren.setBackgroundColor(kleur);
                            cellVerlof.setBackgroundColor(kleur);
                            uren.setBackgroundColor(kleur);
                            cellDag.setBackgroundColor(kleur);
                            cellWeek.setBackgroundColor(kleur);
                        }
                        dagTabel.addCell(cellDag);
                        dagTabel.addCell(cellWeek);
                        dagTabel.addCell(cellVerlof);
                        dagTabel.addCell(uren);
                        table.addCell(dagTabel);
                        k++;
                    }
                }

            }
            d.add(table);
            dao.close();
        }
    } catch (Exception ex) {

        ex.printStackTrace();

    } finally {
        d.close();
        w.close();
    }
    return fileName;
}

From source file:bestdeal.util.genererPdf.java

public static void main(String[] args) {
    // - Paramtres de connexion  la base de donnes
    Connection connection;/*from   w  w  w.  jav a  2  s  . co  m*/
    String[][] data = new String[][] { { " ", " ", " ", " ", " " }, { " ", " ", " ", " ", " " },
            { " ", " ", " ", " ", " " }, };

    try {
        String requete = "select c.nom,c.prenom,c.email,k.nom,k.prenom,k.telephone,k.adresse,k.email,d.id_deal,d.nom_deal,v.quantite,v.prix_unitaire from client c INNER JOIN voucher v on v.id_client=c.id_client INNER JOIN deal d on v.id_deal=d.id_deal INNER JOIN vendeur k on d.id_vendeur=k.id_vendeur";
        connection = MyConnection.getInstance();
        mypdf = new Document(PageSize.A4, 50, 50, 50, 50);
        File di = new File("C:/Voucher");
        File fl[] = di.listFiles();
        try {
            OutputStream file = new FileOutputStream(new File("C:/Voucher\\Voucher.pdf"));
            PdfWriter.getInstance(mypdf, file);

            mypdf.open();
            Statement stm;

            mypdf.addAuthor("Best Deal");
            mypdf.addSubject("Voucher ");
            mypdf.add(new Paragraph("Socite BestDeal"));
            mypdf.add(new Paragraph("Adresse La Chotrana ESPRIT "));
            mypdf.add(new Paragraph("TEL : xx xxx xxx"));
            mypdf.add(new Paragraph("FAX : xx xxx xxx"));
            mypdf.add(new Paragraph(
                    "                                                                                                       "
                            + new Date().toString()));
            mypdf.add(new Paragraph("  "));
            mypdf.add(new Paragraph("                                   " + "Voucher N'01",
                    FontFactory.getFont(FontFactory.HELVETICA, 21, Font.BOLDITALIC)));
            mypdf.add(new Paragraph("  "));

            mypdf.add(new Paragraph("CLIENT :",
                    FontFactory.getFont(FontFactory.TIMES_ROMAN, 13, Font.BOLDITALIC)));
            try {
                stm = connection.createStatement();
                ResultSet rs = stm.executeQuery(requete);

                while (rs.next()) {
                    // add a country to the document as a Chunk
                    //mypdf.add(new Chunk(rs.getString("quantite")));
                    Phrase p = new Phrase("Nom:   ");
                    Phrase p2 = new Phrase(new Chunk(rs.getString("nom")));
                    Paragraph pa = new Paragraph();
                    pa.add(p);
                    pa.add(p2);
                    mypdf.add(pa);

                    Phrase p3 = new Phrase("Prenom:  ");
                    Phrase p4 = new Phrase(new Chunk(rs.getString("prenom")));
                    Paragraph pa1 = new Paragraph();
                    pa1.add(p3);
                    pa1.add(p4);
                    mypdf.add(pa1);

                    Phrase p5 = new Phrase("Adresse:  ");
                    Phrase p6 = new Phrase(new Chunk(rs.getString("adresse")));
                    Paragraph pa2 = new Paragraph();
                    pa2.add(p5);
                    pa2.add(p6);
                    mypdf.add(pa2);

                    Phrase p7 = new Phrase("Tlphone:  ");
                    Phrase p8 = new Phrase(new Chunk(rs.getString("telephone")));
                    Paragraph pa3 = new Paragraph();
                    pa3.add(p7);
                    pa3.add(p8);
                    mypdf.add(pa3);

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

                    mypdf.add(new Paragraph("Vendeur :",
                            FontFactory.getFont(FontFactory.TIMES_ROMAN, 13, Font.BOLDITALIC)));

                    Phrase p9 = new Phrase("Nom:  ");
                    Phrase p10 = new Phrase(new Chunk(rs.getString("nom")));
                    Paragraph pa4 = new Paragraph();
                    pa4.add(p9);
                    pa4.add(p10);
                    mypdf.add(pa4);

                    Phrase p11 = new Phrase("Prnom:  ");
                    Phrase p12 = new Phrase(new Chunk(rs.getString("prenom")));
                    Paragraph pa5 = new Paragraph();
                    pa5.add(p11);
                    pa5.add(p12);
                    mypdf.add(pa5);

                    Phrase p13 = new Phrase("Tlphone:  ");
                    Phrase p14 = new Phrase(new Chunk(rs.getString("telephone")));
                    Paragraph pa6 = new Paragraph();
                    pa6.add(p13);
                    pa6.add(p14);
                    mypdf.add(pa6);

                    Phrase p15 = new Phrase("Adresse:  ");
                    Phrase p16 = new Phrase(new Chunk(rs.getString("adresse")));
                    Paragraph pa7 = new Paragraph();
                    pa7.add(p15);
                    pa7.add(p16);
                    mypdf.add(pa7);

                    Phrase p17 = new Phrase("Email:  ");
                    Phrase p18 = new Phrase(new Chunk(rs.getString("email")));
                    Paragraph pa8 = new Paragraph();
                    pa8.add(p17);
                    pa8.add(p18);
                    mypdf.add(pa8);

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

                    for (int i = 0; i < rs.getRow(); i++) {
                        for (int j = 0; j < data[i].length - 1; j++) {
                            data[i][j] = rs.getString(j + 9);
                            // if (j==3)
                            //     data[i][4]= Float.parseFloat(data[i][3])*Integer.parseInt(data[i][2])+"";
                        }
                    }

                    for (int i = 0; i < rs.getRow(); i++) {
                        float s = Integer.parseInt(data[i][2].trim()) * Float.parseFloat(data[i][3].trim());
                        data[i][4] = s + "";
                    }

                    //mypdf.add(new Phrase("nom"));
                    //mypdf.add(new  Chunk(rs.getString("nom")));
                    //mypdf.add( new Paragraph("nom:", new Chunk(rs.getString("nom"))));
                    //mypdf.add(new Chunk(" "));
                    //Chunk id = new Chunk(rs.getString("id"));
                    // with a background color
                    //id.setBackground(BaseColor.BLACK, 1f, 0.5f, 1f, 1.5f);
                    // and a text rise
                    //id.setTextRise(6);
                    //  mypdf.add(id);
                    mypdf.add(Chunk.NEWLINE);
                }

            } catch (SQLException ex) {
                Logger.getLogger(genererPdf.class.getName()).log(Level.SEVERE, null, ex);
            }
            // mypdf.add(new Paragraph("Nom "));
            //  mypdf.add(new Paragraph("Prenom "));
            // mypdf.add(new Paragraph("Adresse "));
            //mypdf.add(new Paragraph("Tlphone "));

            // mypdf.add(new Paragraph("Nom "));
            // mypdf.add(new Paragraph("Nom de la socit "));
            //  mypdf.add(new Paragraph("Adresse "));
            // mypdf.add(new Paragraph("Tlphone "));
            // mypdf.add(new Paragraph("  "));

            String[] headers = new String[] { "  Id_deal", "   Nom Deal", "   Quantit", "    Prix unitaire",
                    "   Prix total" };
            PdfPTable table = new PdfPTable(headers.length);
            for (int i = 0; i < headers.length; i++) {
                String header = headers[i];
                PdfPCell cell = new PdfPCell();
                cell.setGrayFill(0.9f);
                cell.setPhrase(new Phrase(header.toUpperCase()));
                table.addCell(cell);
            }
            table.completeRow();
            for (int i = 0; i < data.length; i++) {
                for (int j = 0; j < data[i].length; j++) {
                    String datum = data[i][j];
                    PdfPCell cell = new PdfPCell();
                    cell.setPhrase(new Phrase(datum.toUpperCase()));
                    table.addCell(cell);
                }
                table.completeRow();
            }

            mypdf.add(table);
        } catch (FileNotFoundException ex) {
            Logger.getLogger(genererPdf.class.getName()).log(Level.SEVERE, null, ex);
        }

        mypdf.add(new Paragraph(" "));
        mypdf.add(new Paragraph(" "));
        mypdf.add(new Paragraph(
                "Pour toute question concernant cette facture,veuillez contacter Nom,numro de tlphone,adresse de messagerie ",
                FontFactory.getFont(null, 9, Font.NORMAL)));
        mypdf.add(new Paragraph(
                "                                                      Merci pour votre confiance",
                FontFactory.getFont(FontFactory.TIMES_ROMAN, 14, Font.BOLDITALIC)));
        mypdf.add(new Paragraph("      "));
        mypdf.add(new Paragraph("  "));
        mypdf.add(new Paragraph("  "));

        mypdf.close();

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

From source file:bladwin.web.reg.regPDF.java

public void genPed(String loc, regMgr regMgr, dbMgrInterface db) {
    Document document = null;/*ww w .  j av  a  2  s .  c o  m*/
    //String loc = "C:/_bisc/_javaApps/jlData/jvp/CellWidths.pdf";

    //regMgr.getCustomerRegBean().setPdf(loc);
    try {

        document = new Document(PageSize.A4, 30, 30, 30, 30);
        PdfWriter.getInstance(document, new FileOutputStream(loc));
        document.open();
        customerRegBean r = regMgr.getCustomerRegBean();
        customerBean c = regMgr.getCustomerBean();
        customerBean a = new custObj().getcustomerBean(r.getRegCustId(), db);
        mgnLookupBean bean = new mgnLookupObj().getLookupBean(-947, db);
        Paragraph pg;
        pg = new Paragraph(r.getLookupDesc());
        pg.setAlignment(Paragraph.ALIGN_CENTER);
        pg.setFont(FontFactory.getFont(FontFactory.HELVETICA, 12, Font.BOLD));
        document.add(getHeader(r.getLookupDesc()));
        document.add(getHeader("BALDWIN BLAZERS TRACK CLUB"));
        document.add(getHeader("REGISTRATION"));
        pg = new Paragraph("\n\r");
        document.add(pg);
        // -------------------------------------------------------
        document.add(genAthleteInfo(r, a));
        pg = new Paragraph("\n\r");
        document.add(pg);
        document.add(genParentInfo(c));
        pg = new Paragraph("\n\r");
        document.add(pg);
        document.add(genSport(r));
        pg = new Paragraph("\n\r");
        document.add(pg);
        pg = new Paragraph("PARENTS SIGNATURE");
        document.add(pg);
        pg = new Paragraph("\n\r");
        document.add(pg);
        pg = new Paragraph("\n\r");
        document.add(pg);
        pg = new Paragraph("_____________________________________________________________________");
        document.add(pg);
        pg = new Paragraph("\n\r");
        document.add(pg);
        document.add(getHeader(r.getFeeDesc() + "\n\r" + bean.getSubjectBody()));
        // ----------------------------------------------------------------------------

    } catch (DocumentException ex) {
        logger.error("DocumentException", ex);
    } catch (FileNotFoundException ex) {
        logger.error("FileNotFoundException", ex);
    } finally {
        try {
            if (document != null)
                document.close();

            //pdfFileOpen(loc);

        } catch (Exception e) {
            logger.error("FileNotFoundException", e);
        }
    }
}

From source file:bladwin.web.reg.regPDF.java

private Paragraph getHeader(String text) {
    Paragraph pg = new Paragraph(text);
    pg.setAlignment(Paragraph.ALIGN_CENTER);
    pg.setFont(FontFactory.getFont(FontFactory.HELVETICA, 12, Font.BOLD));
    return pg;/* w w  w.ja v a  2s .c  o m*/
}

From source file:bouttime.report.award.AwardInventoryReport.java

License:Open Source License

/**
 * Generate an award report.//  w  w  w  . j a  va  2 s .  c  o m
 * @param dao Dao object to use to retrieve data.
 * @param session Session to generate the report for.
 * @param group Group to generate report for.  This takes precedence, so
 * if not null, then the report will be generated for this group.
 * @return True if the report was generated.
 */
public static boolean doReport(Dao dao) {
    if (!dao.isOpen()) {
        logger.warn("DAO is not open");
        return false;
    }

    if (dao.getMaxAward() == null) {
        logger.warn("Max Award value is NULL");
        return false;
    }

    // step 1: creation of a document-object
    Document document = new Document();

    try {

        // step 2: creation of the writer
        FileOutputStream fos = createOutputFile();
        if (fos == null) {
            return false;
        }
        PdfWriter.getInstance(document, fos);

        // step 3: we open the document
        document.open();

        // step 4: create and add content

        // create and add the header
        Paragraph p1 = new Paragraph(new Paragraph(
                String.format("%s    %s %s, %s", dao.getName(), dao.getMonth(), dao.getDay(), dao.getYear()),
                FontFactory.getFont(FontFactory.HELVETICA, 10)));
        document.add(p1);

        Paragraph p2 = new Paragraph(
                new Paragraph("Award Inventory Report", FontFactory.getFont(FontFactory.HELVETICA, 14)));
        p2.setAlignment(Paragraph.ALIGN_CENTER);
        document.add(p2);

        PdfPTable datatable;
        int[] awardCounts = getAwardCountsForClassDivWeight(dao);
        if (awardCounts != null) {
            Paragraph p3 = new Paragraph(new Paragraph("\nFor class/age division/weight class",
                    FontFactory.getFont(FontFactory.HELVETICA, 11)));
            p3.setAlignment(Paragraph.ALIGN_LEFT);
            document.add(p3);
            datatable = getDataTable(awardCounts, dao.getMaxAward());
            document.add(datatable);
        }

        awardCounts = getAwardCountsForExistingGroups(dao);
        if (awardCounts != null) {
            Paragraph p3 = new Paragraph(
                    new Paragraph("\nFor existing groups", FontFactory.getFont(FontFactory.HELVETICA, 11)));
            p3.setAlignment(Paragraph.ALIGN_LEFT);
            document.add(p3);
            datatable = getDataTable(awardCounts, dao.getMaxAward());
            document.add(datatable);
        }
    } catch (DocumentException de) {
        logger.error("Document Exception", de);
        return false;
    }

    // step 5: we close the document
    document.close();

    return true;
}