Example usage for com.itextpdf.text.pdf PdfPCell setHorizontalAlignment

List of usage examples for com.itextpdf.text.pdf PdfPCell setHorizontalAlignment

Introduction

In this page you can find the example usage for com.itextpdf.text.pdf PdfPCell setHorizontalAlignment.

Prototype

public void setHorizontalAlignment(int horizontalAlignment) 

Source Link

Document

Sets the horizontal alignment for the cell.

Usage

From source file:org.agmip.ui.afsirs.util.AFSIRSUtils.java

private void addParagraphToTableSoilName(PdfPTable t, String key, String value) {
    PdfPCell c;
    Paragraph p = new Paragraph();

    Chunk keyChunk = new Chunk(key, BLACK_NORMAL);
    Chunk valChunk = new Chunk(value, BLACK_BOLD);

    p.add(keyChunk);// w  w  w. j  a  v a  2 s  .  c  o  m
    p.add(valChunk);

    c = new PdfPCell(p);
    c.setHorizontalAlignment(Element.ALIGN_CENTER);
    c.setBorder(0);
    t.addCell(c);
}

From source file:org.agmip.ui.afsirs.util.AFSIRSUtils.java

private void addUserDetails(PdfPTable t, String key, String value) {
    PdfPCell c;
    Paragraph p = new Paragraph();

    Chunk keyChunk = new Chunk(key, BLACK_NORMAL);
    Chunk valChunk = new Chunk(value, BLACK_BOLD);

    p.add(keyChunk);// w  w  w  .j a  v a 2s.  c  om
    p.add(valChunk);

    c = new PdfPCell(p);
    c.setHorizontalAlignment(Element.ALIGN_LEFT);
    c.setBorder(0);
    t.addCell(c);
}

From source file:org.agmip.ui.afsirs.util.AFSIRSUtils.java

private void designTableTitleCell(PdfPTable table, String str) {
    PdfPCell cell;
    // we add a c with colspan 3
    cell = new PdfPCell(new Phrase(str, BLUE_NORMAL));
    cell.setHorizontalAlignment(Element.ALIGN_CENTER);
    cell.setBackgroundColor(BaseColor.ORANGE);
    cell.setColspan(14);//from  www  . ja  v a 2s .  co  m
    table.addCell(cell);
}

From source file:org.agmip.ui.afsirs.util.AFSIRSUtils.java

private void designRowTitleCell(PdfPTable table, String str) {
    PdfPCell cell;
    // we add a c with colspan 3
    cell = new PdfPCell(new Phrase(str, BLUE_NORMAL));
    cell.setHorizontalAlignment(Element.ALIGN_CENTER);
    cell.setBackgroundColor(BaseColor.ORANGE);
    //cell.setColspan(14);
    table.addCell(cell);//from w ww .j a  v  a  2 s  .  c  o m
}

From source file:org.agmip.ui.afsirs.util.AFSIRSUtils.java

private void designTableHeaderRowCell(PdfPTable table, String str) {
    PdfPCell cell;
    // we add a c with colspan 3
    cell = new PdfPCell(new Phrase(str, BLUE_NORMAL));
    cell.setHorizontalAlignment(Element.ALIGN_CENTER);
    cell.setBackgroundColor(BaseColor.ORANGE);
    //cell.setColspan(14);
    table.addCell(cell);//from   w  ww .j  av a2s  .co  m
}

From source file:org.agmip.ui.afsirs.util.AFSIRSUtils.java

private void designDataCell(PdfPTable table, String str) {
    PdfPCell cell;
    // we add a c with colspan 3
    cell = new PdfPCell(new Phrase(str, BLACK_NORMAL));
    cell.setHorizontalAlignment(Element.ALIGN_CENTER);
    cell.setBackgroundColor(BaseColor.CYAN);
    //cell.setColspan(14);
    table.addCell(cell);//from   w  w w .  j av  a  2s .com
}

From source file:org.bonitasoft.studio.migration.utils.PDFMigrationReportWriter.java

License:Open Source License

private void createTable(Paragraph paragrah) throws MalformedURLException, IOException, DocumentException {
    PdfPTable table = new PdfPTable(6);
    table.setHeaderRows(0);//w ww  .j a v a  2s.co  m
    table.setWidthPercentage(95f);
    PdfPCell c1 = new PdfPCell(new Phrase(Messages.elementType));
    c1.setBackgroundColor(BaseColor.LIGHT_GRAY);
    c1.setHorizontalAlignment(Element.ALIGN_CENTER);
    c1.setVerticalAlignment(Element.ALIGN_CENTER);
    table.addCell(c1);

    c1 = new PdfPCell(new Phrase(Messages.name));
    c1.setBackgroundColor(BaseColor.LIGHT_GRAY);
    c1.setHorizontalAlignment(Element.ALIGN_CENTER);
    c1.setVerticalAlignment(Element.ALIGN_CENTER);
    table.addCell(c1);

    c1 = new PdfPCell(new Phrase(Messages.property));
    c1.setBackgroundColor(BaseColor.LIGHT_GRAY);
    c1.setHorizontalAlignment(Element.ALIGN_CENTER);
    c1.setVerticalAlignment(Element.ALIGN_CENTER);
    table.addCell(c1);

    c1 = new PdfPCell(new Phrase(Messages.information));
    c1.setBackgroundColor(BaseColor.LIGHT_GRAY);
    c1.setHorizontalAlignment(Element.ALIGN_CENTER);
    c1.setVerticalAlignment(Element.ALIGN_CENTER);
    table.addCell(c1);

    c1 = new PdfPCell(new Phrase(Messages.status));
    c1.setBackgroundColor(BaseColor.LIGHT_GRAY);
    c1.setHorizontalAlignment(Element.ALIGN_CENTER);
    c1.setVerticalAlignment(Element.ALIGN_CENTER);
    table.addCell(c1);

    c1 = new PdfPCell(new Phrase(Messages.reviewed));
    c1.setBackgroundColor(BaseColor.LIGHT_GRAY);
    c1.setHorizontalAlignment(Element.ALIGN_CENTER);
    c1.setVerticalAlignment(Element.ALIGN_CENTER);
    table.addCell(c1);

    table.setHeaderRows(1);

    List<Change> changes = report.getChanges();
    if (viewer != null) {
        for (int i = 0; i < changes.size(); i++) {
            addTableRow(table, (Change) viewer.getElementAt(i));
        }
    } else {
        for (Change change : changes) {
            addTableRow(table, change);
        }
    }

    table.setWidths(new int[] { 3, 3, 3, 5, 2, 2 });
    table.setHorizontalAlignment(Element.ALIGN_CENTER);
    table.setComplete(true);

    paragrah.add(table);
}

From source file:org.bonitasoft.studio.migration.utils.PDFMigrationReportWriter.java

License:Open Source License

private void addTableRow(PdfPTable table, Change change)
        throws BadElementException, MalformedURLException, IOException {
    PdfPCell cell = new PdfPCell(new Phrase(change.getElementType()));
    cell.setHorizontalAlignment(Element.ALIGN_LEFT);
    cell.setVerticalAlignment(Element.ALIGN_CENTER);
    table.addCell(cell);/* w w  w. j  a v  a  2  s.c o  m*/

    cell = new PdfPCell(new Phrase(change.getElementName()));
    cell.setHorizontalAlignment(Element.ALIGN_LEFT);
    cell.setVerticalAlignment(Element.ALIGN_CENTER);
    table.addCell(cell);

    cell = new PdfPCell(new Phrase(change.getPropertyName()));
    cell.setHorizontalAlignment(Element.ALIGN_LEFT);
    cell.setVerticalAlignment(Element.ALIGN_CENTER);
    table.addCell(cell);

    cell = new PdfPCell(new Phrase(change.getDescription()));
    cell.setHorizontalAlignment(Element.ALIGN_JUSTIFIED);
    cell.setVerticalAlignment(Element.ALIGN_TOP);
    cell.setPadding(4f);
    table.addCell(cell);

    cell = new PdfPCell(getImageForStatus(change.getStatus()), false);
    cell.setPadding(10f);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER);
    cell.setVerticalAlignment(Element.ALIGN_CENTER);
    table.addCell(cell);

    String reviewed = Messages.no;
    if (change.isReviewed()) {
        reviewed = Messages.yes;
    }
    cell = new PdfPCell(new Phrase(reviewed));
    cell.setHorizontalAlignment(Element.ALIGN_CENTER);
    cell.setVerticalAlignment(Element.ALIGN_CENTER);
    table.addCell(cell);
}

From source file:org.cejug.yougi.web.report.EventAttendeeReport.java

License:Open Source License

public void printReport(List<Attendee> attendees) throws DocumentException {
    float[] columnSizes = { 20, 220, 220, 60 };
    PdfPTable table = new PdfPTable(columnSizes.length);
    table.setLockedWidth(true);// w w w  . jav a2 s.  co  m
    table.setTotalWidth(columnSizes);

    PdfPCell headerCell = new PdfPCell(new Phrase("Yougi"));
    headerCell.setColspan(4);
    headerCell.setBackgroundColor(BaseColor.ORANGE);
    headerCell.setPadding(3);
    table.addCell(headerCell);

    table.getDefaultCell().setBackgroundColor(BaseColor.LIGHT_GRAY);

    PdfPCell checkCell = new PdfPCell(new Phrase(" "));
    checkCell.setBackgroundColor(BaseColor.LIGHT_GRAY);
    table.addCell(checkCell);

    PdfPCell productCell = new PdfPCell(new Phrase("Nome"));
    productCell.setBackgroundColor(BaseColor.LIGHT_GRAY);
    productCell.setVerticalAlignment(Element.ALIGN_BOTTOM);
    table.addCell(productCell);

    PdfPCell currentPurchaseCell = new PdfPCell(new Phrase("Email"));
    currentPurchaseCell.setPadding(3);
    currentPurchaseCell.setHorizontalAlignment(Element.ALIGN_CENTER);
    currentPurchaseCell.setBackgroundColor(BaseColor.LIGHT_GRAY);
    table.addCell(currentPurchaseCell);

    PdfPCell previousPurchaseCell = new PdfPCell(new Phrase("Presente"));
    previousPurchaseCell.setPadding(3);
    previousPurchaseCell.setHorizontalAlignment(Element.ALIGN_CENTER);
    previousPurchaseCell.setBackgroundColor(BaseColor.LIGHT_GRAY);
    table.addCell(previousPurchaseCell);

    table.getDefaultCell().setBackgroundColor(null);
    table.setHeaderRows(2);

    Font font = new Font(Font.FontFamily.HELVETICA, 9);
    int seq = 1;
    for (Attendee attendee : attendees) {
        table.addCell(new Phrase(String.valueOf(seq++), font));

        table.addCell(new Phrase(attendee.getUserAccount().getFullName(), font));

        table.addCell(new Phrase(attendee.getUserAccount().getEmail(), font));

        table.addCell(" ");
    }

    document.add(table);
}

From source file:org.cherchgk.actions.tournament.result.show.GetPDFTournamentResultAction.java

License:Apache License

public InputStream getDocument() throws DocumentException, IOException {
    Font normalFont = getNormalFont();
    Font boldFont = getBoldFont();

    ByteArrayOutputStream out = new ByteArrayOutputStream();
    Document document = new Document();
    PdfWriter.getInstance(document, out);
    document.open();/*from ww w .j a  v a  2 s. c o  m*/

    Paragraph tournamentNameParagraph = new Paragraph(tournament.getTitle(), boldFont);
    tournamentNameParagraph.setAlignment(Element.ALIGN_CENTER);
    document.add(tournamentNameParagraph);

    Paragraph tournamentDateParagraph = new Paragraph(tournament.getDateAsString(), boldFont);
    tournamentDateParagraph.setAlignment(Element.ALIGN_CENTER);
    document.add(tournamentDateParagraph);

    if (teamCategory != null) {
        Paragraph teamCategoryParagraph = new Paragraph(teamCategory.getTitle(), boldFont);
        teamCategoryParagraph.setAlignment(Element.ALIGN_CENTER);
        document.add(teamCategoryParagraph);
    }

    int numColumns = 3 + tournamentResult.getRankingAlgorithms().size();
    PdfPTable resultTable = new PdfPTable(numColumns);
    int[] widths = new int[numColumns];
    widths[0] = 1;
    widths[1] = 3;
    for (int i = 2; i < numColumns; i++) {
        widths[i] = 1;
    }
    resultTable.setWidths(widths);
    resultTable.setSpacingBefore(10f);

    PdfPCell cell = new PdfPCell(new Phrase("", boldFont));
    cell.setHorizontalAlignment(Element.ALIGN_CENTER);
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
    cell.setColspan(2);
    cell.setBackgroundColor(BaseColor.LIGHT_GRAY);
    resultTable.addCell(cell);

    for (RankingAlgorithm rankingAlgorithm : tournamentResult.getRankingAlgorithms()) {
        cell = new PdfPCell(new Phrase(rankingAlgorithm.getPointName(), boldFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
        cell.setBackgroundColor(BaseColor.LIGHT_GRAY);
        resultTable.addCell(cell);
    }

    cell = new PdfPCell(new Phrase("?", boldFont));
    cell.setHorizontalAlignment(Element.ALIGN_CENTER);
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
    cell.setBackgroundColor(BaseColor.LIGHT_GRAY);
    resultTable.addCell(cell);

    boolean showTeamCategoryInTable = (teamCategory == null) && !tournament.getTeamCategories().isEmpty();

    for (TournamentResult.TeamResult teamResult : tournamentResult.getTeamResultList()) {
        if (showTeamCategoryInTable) {
            if (teamResult.getTeam().getTeamCategory() != null) {
                cell = new PdfPCell(new Phrase(teamResult.getTeam().getTeamCategory().getTitle(), normalFont));
            } else {
                cell = new PdfPCell(new Phrase("", normalFont));
            }
            resultTable.addCell(cell);
        }
        cell = new PdfPCell(new Phrase(teamResult.getTeam().getName(), normalFont));
        if (!showTeamCategoryInTable) {
            cell.setColspan(2);
        }
        resultTable.addCell(cell);
        for (Map<Team, RankingPoint> m : tournamentResult.getRankingPointsList()) {
            cell = new PdfPCell(new Phrase(m.get(teamResult.getTeam()).toString(), normalFont));
            cell.setHorizontalAlignment(Element.ALIGN_CENTER);
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
            resultTable.addCell(cell);
        }
        cell = new PdfPCell(new Phrase(teamResult.getPlace(), normalFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
        resultTable.addCell(cell);
    }

    document.add(resultTable);
    document.close();

    return new ByteArrayInputStream(out.toByteArray());
}