Example usage for com.itextpdf.text Chunk NEWLINE

List of usage examples for com.itextpdf.text Chunk NEWLINE

Introduction

In this page you can find the example usage for com.itextpdf.text Chunk NEWLINE.

Prototype

Chunk NEWLINE

To view the source code for com.itextpdf.text Chunk NEWLINE.

Click Source Link

Document

This is a Chunk containing a newline.

Usage

From source file:fll.web.report.FinalComputedScores.java

License:Open Source License

private PdfPTable createHeader(final String challengeTitle, final String tournamentName,
        final String division) {
    // initialization of the header table
    final PdfPTable header = new PdfPTable(2);

    final Phrase p = new Phrase();
    p.add(new Chunk(challengeTitle, TIMES_12PT_NORMAL));
    p.add(Chunk.NEWLINE);
    p.add(new Chunk("Final Computed Scores", TIMES_12PT_NORMAL));
    header.getDefaultCell().setBorderWidth(0);
    header.addCell(p);//  w  w w.  j  ava2  s  . c om
    header.getDefaultCell().setHorizontalAlignment(com.itextpdf.text.Element.ALIGN_RIGHT);

    final Phrase p2 = new Phrase();
    p2.add(new Chunk("Tournament: " + tournamentName, TIMES_12PT_NORMAL));
    p2.add(Chunk.NEWLINE);
    p2.add(new Chunk("Award Group: " + division, TIMES_12PT_NORMAL));
    header.addCell(p2);

    return header;
}

From source file:fll.web.report.finalist.AbstractFinalistSchedule.java

License:Open Source License

/**
 * Create a page for the specified category.
 * /*from   ww  w.  jav a2 s  . c o m*/
 * @throws DocumentException
 * @throws SQLException
 */
private void createCategoryPage(final Document document, final Connection connection, final String category,
        final String room, final FinalistSchedule schedule) throws DocumentException, SQLException {
    // header name
    final Paragraph para = new Paragraph();
    para.add(Chunk.NEWLINE);

    para.add(new Chunk(String.format("Finalist schedule for %s", category), TITLE_FONT));
    para.add(Chunk.NEWLINE);
    if (null != room && !"".equals(room)) {
        para.add(new Chunk(String.format("Room: %s", room), TITLE_FONT));
    }
    document.add(para);

    final PdfPTable schedTable = new PdfPTable(new float[] { 12.5f, 12.5f, 37.5f, 37.5f });
    schedTable.setWidthPercentage(100);
    schedTable.getDefaultCell().setBorder(0);
    schedTable.getDefaultCell().enableBorderSide(Rectangle.BOTTOM);
    schedTable.getDefaultCell().setHorizontalAlignment(Element.ALIGN_CENTER);

    schedTable.addCell(new Phrase("Time", SCHEDULE_HEADER_FONT));

    schedTable.addCell(new Phrase("Team #", SCHEDULE_HEADER_FONT));

    schedTable.addCell(new Phrase("Team Name", SCHEDULE_HEADER_FONT));

    schedTable.addCell(new Phrase("Organization", SCHEDULE_HEADER_FONT));

    // foreach information output
    for (final FinalistDBRow row : schedule.getScheduleForCategory(category)) {
        // time, number, name, organization
        schedTable.addCell(new Phrase(String.format("%d:%02d", row.getHour(), row.getMinute()), SCHEDULE_FONT));

        final Team team = Team.getTeamFromDatabase(connection, row.getTeamNumber());
        schedTable.addCell(new Phrase(String.valueOf(team.getTeamNumber()), SCHEDULE_FONT));

        schedTable.addCell(new Phrase(team.getTeamName(), SCHEDULE_FONT));

        schedTable.addCell(new Phrase(team.getOrganization(), SCHEDULE_FONT));

    }
    document.add(schedTable);

    document.add(Chunk.NEXTPAGE);
}

From source file:fll.web.report.finalist.TeamFinalistSchedule.java

License:Open Source License

protected void processRequest(final HttpServletRequest request, final HttpServletResponse response,
        final ServletContext application, final HttpSession session) throws IOException, ServletException {

    Connection connection = null;
    try {/*w w w  . j  a  va 2s.  com*/
        final DataSource datasource = ApplicationAttributes.getDataSource(application);
        connection = datasource.getConnection();

        final ChallengeDescription challengeDescription = ApplicationAttributes
                .getChallengeDescription(application);

        // create simple doc and write to a ByteArrayOutputStream
        final Document document = new Document(PageSize.LETTER);
        final ByteArrayOutputStream baos = new ByteArrayOutputStream();
        final PdfWriter writer = PdfWriter.getInstance(document, baos);
        writer.setPageEvent(new ReportPageEventHandler(HEADER_FONT, "Finalist Callback Schedule",
                challengeDescription.getTitle(), Queries.getCurrentTournamentName(connection)));

        document.open();

        document.addTitle("Ranking Report");

        // add content
        final int currentTournament = Queries.getCurrentTournament(connection);

        final Collection<String> divisions = FinalistSchedule.getAllDivisions(connection, currentTournament);
        final Collection<FinalistSchedule> schedules = new LinkedList<FinalistSchedule>();
        for (final String division : divisions) {
            final FinalistSchedule schedule = new FinalistSchedule(connection, currentTournament, division);
            schedules.add(schedule);
        }

        final Map<Integer, TournamentTeam> tournamentTeams = Queries.getTournamentTeams(connection,
                currentTournament);
        final List<Integer> teamNumbers = new LinkedList<Integer>(tournamentTeams.keySet());
        Collections.sort(teamNumbers);

        for (final int teamNum : teamNumbers) {
            final TournamentTeam team = tournamentTeams.get(teamNum);

            for (final FinalistSchedule schedule : schedules) {
                final List<FinalistDBRow> finalistTimes = schedule.getScheduleForTeam(teamNum);
                final Map<String, String> rooms = schedule.getRooms();

                if (!finalistTimes.isEmpty()) {

                    final Paragraph para = new Paragraph();
                    para.add(Chunk.NEWLINE);
                    para.add(new Chunk("Finalist times for Team " + teamNum, TITLE_FONT));
                    para.add(Chunk.NEWLINE);
                    para.add(new Chunk(team.getTeamName() + " / " + team.getOrganization(), TITLE_FONT));
                    para.add(Chunk.NEWLINE);
                    para.add(new Chunk("Award Group: " + team.getAwardGroup(), TITLE_FONT));
                    para.add(Chunk.NEWLINE);
                    para.add(Chunk.NEWLINE);

                    final PdfPTable table = new PdfPTable(3);
                    // table.getDefaultCell().setBorder(0);
                    table.setWidthPercentage(100);

                    table.addCell(new Phrase(new Chunk("Time", HEADER_FONT)));
                    table.addCell(new Phrase(new Chunk("Room", HEADER_FONT)));
                    table.addCell(new Phrase(new Chunk("Category", HEADER_FONT)));

                    for (final FinalistDBRow row : finalistTimes) {
                        final String categoryName = row.getCategoryName();
                        String room = rooms.get(categoryName);
                        if (null == room) {
                            room = "";
                        }

                        table.addCell(new Phrase(String.format("%d:%02d", row.getHour(), row.getMinute()),
                                VALUE_FONT));
                        table.addCell(new Phrase(new Chunk(room, VALUE_FONT)));
                        table.addCell(new Phrase(new Chunk(categoryName, VALUE_FONT)));

                    } // foreach row

                    para.add(table);

                    document.add(para);
                    document.add(Chunk.NEXTPAGE);

                } // non-empty list of teams

            } // foreach schedule

        } // foreach team

        document.close();

        // setting some response headers
        response.setHeader("Expires", "0");
        response.setHeader("Cache-Control", "must-revalidate, post-check=0, pre-check=0");
        response.setHeader("Pragma", "public");
        // setting the content type
        response.setContentType("application/pdf");
        response.setHeader("Content-Disposition", "filename=teamFinalistSchedule.pdf");
        // the content length is needed for MSIE!!!
        response.setContentLength(baos.size());
        // write ByteArrayOutputStream to the ServletOutputStream
        final ServletOutputStream out = response.getOutputStream();
        baos.writeTo(out);
        out.flush();

    } catch (final SQLException e) {
        LOG.error(e, e);
        throw new RuntimeException(e);
    } catch (final DocumentException e) {
        LOG.error(e, e);
        throw new RuntimeException(e);
    } finally {
        SQLFunctions.close(connection);
    }
}

From source file:fll.web.report.PerformanceScoreReport.java

License:Open Source License

@Override
protected void processRequest(HttpServletRequest request, HttpServletResponse response,
        ServletContext application, HttpSession session) throws IOException, ServletException {
    Connection connection = null;
    try {/*from   ww  w .jav  a 2  s  .  c om*/
        final DataSource datasource = ApplicationAttributes.getDataSource(application);
        connection = datasource.getConnection();

        final ChallengeDescription challengeDescription = ApplicationAttributes
                .getChallengeDescription(application);

        final int tournamentId = Queries.getCurrentTournament(connection);
        final Tournament tournament = Tournament.findTournamentByID(connection, tournamentId);
        final int numSeedingRounds = TournamentParameters.getNumSeedingRounds(connection,
                tournament.getTournamentID());

        // create simple doc and write to a ByteArrayOutputStream
        final Document document = new Document(PageSize.LETTER, 36, 36, 72, 36);
        final ByteArrayOutputStream baos = new ByteArrayOutputStream();
        final PdfWriter writer = PdfWriter.getInstance(document, baos);
        final PerformanceScoreReportPageEventHandler headerHandler = new PerformanceScoreReportPageEventHandler(
                HEADER_FONT, REPORT_TITLE, challengeDescription.getTitle(), tournament.getName());
        writer.setPageEvent(headerHandler);

        document.open();

        document.addTitle(REPORT_TITLE);

        final Map<Integer, TournamentTeam> teams = Queries.getTournamentTeams(connection);
        if (teams.isEmpty()) {
            final Paragraph para = new Paragraph();
            para.add(Chunk.NEWLINE);
            para.add(new Chunk("No teams in the tournament."));
            document.add(para);
        } else {
            for (Map.Entry<Integer, TournamentTeam> entry : teams.entrySet()) {
                headerHandler.setTeamInfo(entry.getValue());

                outputTeam(connection, document, tournament, challengeDescription, numSeedingRounds,
                        entry.getValue());

                document.add(Chunk.NEXTPAGE);
            }
        }

        document.close();

        // setting some response headers
        response.setHeader("Expires", "0");
        response.setHeader("Cache-Control", "must-revalidate, post-check=0, pre-check=0");
        response.setHeader("Pragma", "public");
        // setting the content type
        response.setContentType("application/pdf");
        response.setHeader("Content-Disposition", "filename=performanceScoreReport.pdf");
        // the content length is needed for MSIE!!!
        response.setContentLength(baos.size());
        // write ByteArrayOutputStream to the ServletOutputStream
        final ServletOutputStream out = response.getOutputStream();
        baos.writeTo(out);
        out.flush();

    } catch (final SQLException e) {
        LOG.error(e, e);
        throw new RuntimeException(e);
    } catch (final DocumentException e) {
        LOG.error(e, e);
        throw new RuntimeException(e);
    } finally {
        SQLFunctions.close(connection);
    }
}

From source file:fll.web.report.PerformanceScoreReport.java

License:Open Source License

private void outputTeam(final Connection connection, final Document document, final Tournament tournament,
        final ChallengeDescription challenge, final int numSeedingRounds, final TournamentTeam team)
        throws DocumentException, SQLException {
    // output first row for header
    final PdfPTable table = new PdfPTable(numSeedingRounds + 1);
    table.addCell("");
    for (int runNumber = 1; runNumber <= numSeedingRounds; ++runNumber) {

        table.addCell(new Phrase("Run " + runNumber, HEADER_FONT));
    }/*from  w  w  w  .  j  av  a2  s  . co  m*/

    final PerformanceScoreCategory performance = challenge.getPerformance();

    final TeamScore[] scores = getScores(connection, tournament, team, numSeedingRounds);
    for (final AbstractGoal goal : performance.getGoals()) {
        final double bestScore = bestScoreForGoal(scores, goal);

        final StringBuilder goalTitle = new StringBuilder();
        goalTitle.append(goal.getTitle());
        if (goal.isComputed()) {
            goalTitle.append(" (computed)");
        }
        table.addCell(new Phrase(goalTitle.toString(), HEADER_FONT));

        for (final TeamScore score : scores) {
            if (!score.scoreExists() || score.isBye() || score.isNoShow()) {
                table.addCell("");
            } else {
                final double computedValue = goal.getComputedScore(score);

                final StringBuilder cellStr = new StringBuilder();
                if (!goal.isComputed()) {
                    if (goal.isEnumerated()) {
                        final String enumValue = score.getEnumRawScore(goal.getName());
                        boolean found = false;
                        for (final EnumeratedValue ev : goal.getValues()) {
                            if (ev.getValue().equals(enumValue)) {
                                cellStr.append(ev.getTitle() + " -> ");
                                found = true;
                                break;
                            }
                        }
                        if (!found) {
                            LOG.warn("Could not find enumerated title for " + enumValue);
                            cellStr.append(enumValue + " -> ");
                        }
                    } else {
                        if (goal.isYesNo()) {
                            if (FP.greaterThan(score.getRawScore(goal.getName()), 0,
                                    ChallengeParser.INITIAL_VALUE_TOLERANCE)) {
                                cellStr.append("Yes -> ");
                            } else {
                                cellStr.append("No -> ");
                            }
                        } else {
                            final double rawValue = goal.getRawScore(score);
                            cellStr.append(Utilities.NUMBER_FORMAT_INSTANCE.format(rawValue) + " -> ");
                        }
                    } // not enumerated
                } // not computed

                cellStr.append(Utilities.NUMBER_FORMAT_INSTANCE.format(computedValue));
                if (FP.equals(bestScore, computedValue, ChallengeParser.INITIAL_VALUE_TOLERANCE)) {
                    table.addCell(new Phrase(cellStr.toString(), BEST_SCORE_FONT));
                } else {
                    table.addCell(new Phrase(cellStr.toString(), SCORE_FONT));
                }
            } // exists, non-bye, non-no show

        } // foreach score
    } // foreach goal

    // totals
    table.addCell(new Phrase("Total", HEADER_FONT));
    final double bestTotalScore = bestTotalScore(performance, scores);
    for (final TeamScore score : scores) {
        if (!score.scoreExists()) {
            table.addCell("");
        } else if (score.isBye()) {
            table.addCell(new Phrase("Bye", SCORE_FONT));
        } else if (score.isNoShow()) {
            table.addCell(new Phrase("No Show", SCORE_FONT));
        } else {
            final double totalScore = performance.evaluate(score);

            if (FP.equals(bestTotalScore, totalScore, ChallengeParser.INITIAL_VALUE_TOLERANCE)) {
                table.addCell(new Phrase(Utilities.NUMBER_FORMAT_INSTANCE.format(totalScore), BEST_SCORE_FONT));
            } else {
                table.addCell(new Phrase(Utilities.NUMBER_FORMAT_INSTANCE.format(totalScore), SCORE_FONT));
            }
        }

    }

    document.add(table);

    final Paragraph definitionPara = new Paragraph();
    definitionPara.add(Chunk.NEWLINE);
    definitionPara.add(new Chunk("The team's top score for each goal and overall are in bold."));
    document.add(definitionPara);
}

From source file:fll.web.report.PlayoffReport.java

License:Open Source License

/**
 * Create the paragraph for the specified division.
 * /*from  w w  w.j a  v a 2s . c  o  m*/
 * @throws SQLException
 */
private Paragraph processDivision(final Connection connection, final Tournament tournament,
        final String division) throws SQLException {
    PreparedStatement teamPrep = null;
    ResultSet teamResult = null;
    PreparedStatement scorePrep = null;
    ResultSet scoreResult = null;
    try {
        final Paragraph para = new Paragraph();
        para.add(Chunk.NEWLINE);
        para.add(new Chunk("Results for head to head bracket " + division, TITLE_FONT));
        para.add(Chunk.NEWLINE);

        final int maxRun = Playoff.getMaxRunNumber(connection, tournament.getTournamentID(), division);

        if (maxRun < 1) {
            para.add("Cannot determine max run number for this playoff bracket. This is an internal error");
        } else {
            teamPrep = connection.prepareStatement("SELECT Teams.TeamNumber, Teams.TeamName, Teams.Organization" //
                    + " FROM PlayoffData, Teams" //
                    + " WHERE PlayoffData.Tournament = ?" //
                    + " AND PlayoffData.event_division = ?" //
                    + " AND PlayoffData.run_number = ?" //
                    + " AND Teams.TeamNumber = PlayoffData.team"//
                    + " ORDER BY PlayoffData.linenumber" //
            );
            teamPrep.setInt(1, tournament.getTournamentID());
            teamPrep.setString(2, division);

            scorePrep = connection.prepareStatement("SELECT ComputedTotal" //
                    + " FROM Performance" //
                    + " WHERE Tournament = ?" //
                    + " AND TeamNumber = ?" //
                    + " AND RunNumber = ?"//
            );

            // figure out the last teams
            final List<String> lastTeams = new LinkedList<>();

            teamPrep.setInt(3, maxRun - 1);
            scorePrep.setInt(1, tournament.getTournamentID());
            scorePrep.setInt(3, maxRun - 1);
            teamResult = teamPrep.executeQuery();
            while (teamResult.next()) {
                final int teamNumber = teamResult.getInt(1);
                final String teamName = teamResult.getString(2);
                final String organization = teamResult.getString(3);

                scorePrep.setInt(2, teamNumber);
                scoreResult = scorePrep.executeQuery();
                final String scoreStr;
                if (scoreResult.next()) {
                    scoreStr = Utilities.NUMBER_FORMAT_INSTANCE.format(scoreResult.getDouble(1));
                } else {
                    scoreStr = "unknown";
                }

                lastTeams.add(String.format("Team %d from %s - %s with a score of %s", teamNumber, organization,
                        teamName, scoreStr));

                SQLFunctions.close(scoreResult);
                scoreResult = null;
            }
            SQLFunctions.close(teamResult);
            teamResult = null;

            // determine the winners
            int lastTeamsIndex = 0;
            teamPrep.setInt(3, maxRun);
            teamResult = teamPrep.executeQuery();
            while (teamResult.next()) {
                final int teamNumber = teamResult.getInt(1);
                final String teamName = teamResult.getString(2);

                para.add(String.format("Competing for places %d and %d", lastTeamsIndex + 1,
                        lastTeamsIndex + 2));
                para.add(Chunk.NEWLINE);
                if (lastTeamsIndex < lastTeams.size()) {
                    para.add(lastTeams.get(lastTeamsIndex));
                } else {
                    para.add("Internal error, unknown team competing");
                }
                para.add(Chunk.NEWLINE);
                ++lastTeamsIndex;

                if (lastTeamsIndex < lastTeams.size()) {
                    para.add(lastTeams.get(lastTeamsIndex));
                } else {
                    para.add("Internal error, unknown team competing");
                }
                para.add(Chunk.NEWLINE);
                ++lastTeamsIndex;

                para.add(String.format("The winner is team %d - %s", teamNumber, teamName));
                para.add(Chunk.NEWLINE);
                para.add(Chunk.NEWLINE);
            }
        }

        return para;
    } finally {
        SQLFunctions.close(teamResult);
        SQLFunctions.close(teamPrep);
        SQLFunctions.close(scoreResult);
        SQLFunctions.close(scorePrep);
    }
}

From source file:fll.web.report.RankingReport.java

License:Open Source License

protected void processRequest(final HttpServletRequest request, final HttpServletResponse response,
        final ServletContext application, final HttpSession session) throws IOException, ServletException {
    if (PromptSummarizeScores.checkIfSummaryUpdated(response, application, session, "/report/RankingReport")) {
        return;//from w ww  . ja  v a2s .co m
    }

    Connection connection = null;
    try {
        final DataSource datasource = ApplicationAttributes.getDataSource(application);
        connection = datasource.getConnection();

        final boolean useQuartiles = GlobalParameters.getUseQuartilesInRankingReport(connection);

        final ChallengeDescription challengeDescription = ApplicationAttributes
                .getChallengeDescription(application);

        // create simple doc and write to a ByteArrayOutputStream
        final Document document = new Document(PageSize.LETTER);
        final ByteArrayOutputStream baos = new ByteArrayOutputStream();
        final PdfWriter writer = PdfWriter.getInstance(document, baos);
        writer.setPageEvent(new ReportPageEventHandler(HEADER_FONT, "Final Computed Rankings",
                challengeDescription.getTitle(), Queries.getCurrentTournamentName(connection)));

        document.open();

        document.addTitle("Ranking Report");

        // add content
        final Map<Integer, TeamRanking> teamRankings = Queries.getTeamRankings(connection,
                challengeDescription);
        final List<Integer> teamNumbers = new LinkedList<Integer>(teamRankings.keySet());
        Collections.sort(teamNumbers);
        final Map<Integer, TournamentTeam> tournamentTeams = Queries.getTournamentTeams(connection);

        for (final int teamNum : teamNumbers) {
            final TournamentTeam team = tournamentTeams.get(teamNum);
            final Paragraph para = new Paragraph();
            para.add(Chunk.NEWLINE);
            para.add(new Chunk("Ranks for Team " + teamNum, TITLE_FONT));
            para.add(Chunk.NEWLINE);
            para.add(new Chunk(team.getTeamName() + " / " + team.getOrganization(), TITLE_FONT));
            para.add(Chunk.NEWLINE);
            para.add(new Chunk("Award Group: " + team.getAwardGroup(), TITLE_FONT));
            para.add(Chunk.NEWLINE);
            para.add(new Chunk(
                    "Each team is ranked in each category in the judging group and award group they were judged in. Performance scores are ranked by division only. Teams may have the same rank if they were tied.",
                    RANK_VALUE_FONT));
            para.add(Chunk.NEWLINE);
            para.add(Chunk.NEWLINE);
            final TeamRanking teamRanks = teamRankings.get(teamNum);

            final List<String> categories = teamRanks.getCategories();
            Collections.sort(categories);

            // pull out performance next
            if (categories.contains(CategoryRank.PERFORMANCE_CATEGORY_NAME)) {
                final String category = CategoryRank.PERFORMANCE_CATEGORY_NAME;
                outputCategory(para, teamRanks, category, useQuartiles);
            }
            para.add(Chunk.NEWLINE);

            for (final String category : categories) {
                if (!CategoryRank.PERFORMANCE_CATEGORY_NAME.equals(category)
                        && !CategoryRank.OVERALL_CATEGORY_NAME.equals(category)) {
                    outputCategory(para, teamRanks, category, useQuartiles);
                }
            }

            document.add(para);

            final Paragraph definitionPara = new Paragraph();
            definitionPara.add(Chunk.NEWLINE);
            definitionPara.add(new Chunk(
                    "The 1st quartile is the top 25% of teams, 2nd quartile is the next 25%, quartiles 3 and 4 are the following 25% groupings of teams."));
            document.add(definitionPara);

            document.add(Chunk.NEXTPAGE);
        }

        document.close();

        // setting some response headers
        response.setHeader("Expires", "0");
        response.setHeader("Cache-Control", "must-revalidate, post-check=0, pre-check=0");
        response.setHeader("Pragma", "public");
        // setting the content type
        response.setContentType("application/pdf");
        response.setHeader("Content-Disposition", "filename=rankingReport.pdf");
        // the content length is needed for MSIE!!!
        response.setContentLength(baos.size());
        // write ByteArrayOutputStream to the ServletOutputStream
        final ServletOutputStream out = response.getOutputStream();
        baos.writeTo(out);
        out.flush();

    } catch (final SQLException e) {
        LOG.error(e, e);
        throw new RuntimeException(e);
    } catch (final DocumentException e) {
        LOG.error(e, e);
        throw new RuntimeException(e);
    } finally {
        SQLFunctions.close(connection);
    }
}

From source file:fll.web.report.RankingReport.java

License:Open Source License

private void outputCategory(final Paragraph para, final TeamRanking teamRanks, final String category,
        boolean useQuartiles) {
    para.add(new Chunk(category + ": ", RANK_TITLE_FONT));

    final CategoryRank catRank = teamRanks.getRankForCategory(category);

    final int rank = catRank.getRank();
    if (CategoryRank.NO_SHOW_RANK == rank) {
        para.add(new Chunk("No Show", RANK_VALUE_FONT));
    } else {/*from  ww  w . j a  v a  2s.c  om*/
        final double percentage = (double) rank / catRank.getNumTeams();
        if (useQuartiles) {
            para.add(new Chunk(
                    String.format("%s in %s", convertPercentageToQuartile(percentage), catRank.getGroup()),
                    RANK_VALUE_FONT));
        } else {
            para.add(new Chunk(
                    String.format("%d out of %d teams in %s", rank, catRank.getNumTeams(), catRank.getGroup()),
                    RANK_VALUE_FONT));
        }
    }
    para.add(Chunk.NEWLINE);
}

From source file:gov.nih.nci.firebird.service.registration.AbstractPdfWriterGenerator.java

License:Open Source License

private void addGenerationDate() throws DocumentException {
    Paragraph generationDateParagraph = new Paragraph();
    generationDateParagraph.setFont(VALUE_FONT);
    generationDateParagraph.setAlignment(Paragraph.ALIGN_LEFT);
    generationDateParagraph.add(getFromResources("pdf.generation.date"));
    generationDateParagraph.add(SPACE_CHARACTER);
    generationDateParagraph.add(formatFullDate(new Date()));
    generationDateParagraph.add(Chunk.NEWLINE);
    generationDateParagraph.add(Chunk.NEWLINE);
    document.add(generationDateParagraph);
}

From source file:gov.nih.nci.firebird.service.registration.ProfileContentPdfHelper.java

License:Open Source License

private void addAddress(Address address, PdfPTable table, int index) {
    PdfPTable addressTable = pdfGenerator.createTable(AbstractPdfWriterGenerator.ONE_COLUMN);
    addressTable.addCell(// w w w.  j a va 2  s  .  c  om
            pdfGenerator.createHeaderCell(index + ". " + pdfGenerator.getFromResources(ADDRESS_TITLE_KEY)));

    Paragraph contents = new Paragraph();
    if (getOrganization() != null) {
        contents.add(pdfGenerator.getValueChunk(getOrganization().getName()));
        contents.add(Chunk.NEWLINE);
    }
    if (address != null) {
        addAddressContent(contents, address);
    }
    PdfPCell addressCell = pdfGenerator.createTableCell(contents);
    addressCell.setPaddingLeft(VALUE_CELL_INDENTATION);
    addressTable.addCell(addressCell);
    PdfPCell addressTableCell = pdfGenerator.createCell(addressTable);
    addressTableCell.setPaddingRight(PADDING_RIGHT);
    table.addCell(addressTableCell);
}