Example usage for com.itextpdf.text Phrase Phrase

List of usage examples for com.itextpdf.text Phrase Phrase

Introduction

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

Prototype

public Phrase(final float leading, final String string) 

Source Link

Document

Constructs a Phrase with a certain leading and a certain String.

Usage

From source file:com.softwaremagico.tm.pdf.complete.events.PartyFooterEvent.java

License:Open Source License

/**
 * Adds a footer to every page/*from   ww  w .  j a v a  2  s. c om*/
 *
 * @see com.itextpdf.text.pdf.PdfPageEventHelper#onEndPage(com.itextpdf.text.pdf.PdfWriter,
 *      com.itextpdf.text.Document)
 */
@Override
public void onEndPage(PdfWriter writer, Document document) {
    PdfContentByte cb = writer.getDirectContent();
    Phrase footer = new Phrase(
            party.getPartyName() + " - Created using 'Think Machine'"
                    + (Version.getVersion() != null ? " v" + Version.getVersion() : ""),
            new Font(FadingSunsTheme.getFooterFont(), FadingSunsTheme.FOOTER_FONT_SIZE));
    ColumnText.showTextAligned(cb, Element.ALIGN_CENTER, footer,
            (document.right() - document.left()) / 2 + document.leftMargin(), document.bottom() + bottomMargin,
            0);
}

From source file:com.softwaremagico.tm.pdf.complete.skills.CounterTable.java

License:Open Source License

protected PdfPCell createValue(String text, Font font, int alignment) {
    Phrase content = new Phrase(text, font);
    PdfPCell circleCell = new PdfPCell(content);
    // Not putting correctly the "o" at the center of the cell.
    // http://stackoverflow.com/questions/5554553/itext-pdftable-cell-vertical-alignment
    circleCell.setPaddingTop(-4f);/*from  w w w.j  a  v a 2 s .c  o m*/
    circleCell.setHorizontalAlignment(Element.ALIGN_CENTER);
    circleCell.setVerticalAlignment(alignment);
    circleCell.setBorder(0);
    // Some position corrections.
    circleCell.setMinimumHeight((MainSkillsTableFactory.HEIGHT / CIRCLES) + 1.3f);
    return circleCell;
}

From source file:com.softwaremagico.tm.pdf.complete.skills.occultism.OccultismTable.java

License:Open Source License

private PdfPCell createContent(CharacterPlayer characterPlayer, String language)
        throws InvalidXmlElementException {
    float[] widths = { 3f, 1f, 1f, 3f };
    PdfPTable table = new PdfPTable(widths);
    BaseElement.setTablePropierties(table);
    table.getDefaultCell().setBorder(0);
    table.getDefaultCell().setPadding(0);
    table.getDefaultCell().setVerticalAlignment(Element.ALIGN_MIDDLE);

    for (OccultismType occulstimType : OccultismTypeFactory.getInstance().getElements(language)) {
        PdfPCell psiqueTitleCell = new PdfPCell(new Phrase(occulstimType.getName(),
                new Font(FadingSunsTheme.getLineFont(), FadingSunsTheme.CHARACTERISTICS_LINE_FONT_SIZE)));
        psiqueTitleCell.setBorder(0);// w w  w  .j  av  a2s.c o m
        // psiTitleCell.setMinimumHeight(30);
        psiqueTitleCell.setHorizontalAlignment(Element.ALIGN_RIGHT);
        table.addCell(psiqueTitleCell);

        if (characterPlayer == null) {
            table.addCell(createRectangle());
            table.addCell(createRectangle());
        } else {
            table.addCell(createRectangle(characterPlayer.getPsiqueLevel(occulstimType)));
            table.addCell(createRectangle(characterPlayer.getDarkSideLevel(occulstimType)));
        }

        PdfPCell darkSideTitleCell = new PdfPCell(new Phrase(occulstimType.getDarkSideName(),
                new Font(FadingSunsTheme.getLineFont(), FadingSunsTheme.CHARACTERISTICS_LINE_FONT_SIZE)));
        darkSideTitleCell.setBorder(0);
        darkSideTitleCell.setHorizontalAlignment(Element.ALIGN_LEFT);
        table.addCell(darkSideTitleCell);

    }

    PdfPCell cell = new PdfPCell();
    cell.addElement(table);
    cell.setPadding(0);
    BaseElement.setCellProperties(cell);

    return cell;
}

From source file:com.softwaremagico.tm.pdf.small.characteristics.CharacteristicsTableFactory.java

License:Open Source License

public static PdfPTable getCharacteristicsBasicsTable(CharacterPlayer characterPlayer) {
    float[] widths = { 1f, 1f };
    PdfPTable table = new PdfPTable(widths);
    setTablePropierties(table);/*w  w w.  ja  v  a 2s .co m*/
    table.getDefaultCell().setBorder(0);

    Phrase content = new Phrase(getTranslator().getTranslatedText("characteristics"),
            new Font(FadingSunsTheme.getTitleFont(), FadingSunsTheme.CHARACTER_SMALL_TITLE_FONT_SIZE));
    PdfPCell titleCell = new PdfPCell(content);
    setCellProperties(titleCell);
    titleCell.setHorizontalAlignment(Element.ALIGN_CENTER);
    titleCell.setColspan(widths.length);
    titleCell.setFixedHeight(30);
    table.addCell(titleCell);
    table.getDefaultCell().setPadding(0);

    for (CharacteristicType type : CharacteristicType.values()) {
        table.addCell(new CharacteristicsColumn(characterPlayer, type,
                CharacteristicsDefinitionFactory.getInstance().getAll(type, Translator.getLanguage())));
    }

    return table;
}

From source file:com.softwaremagico.tm.pdf.small.counters.CounterTable.java

License:Open Source License

protected PdfPCell createValue(String text, Font font, int alignment) {
    Phrase content = new Phrase(text, font);
    PdfPCell circleCell = new PdfPCell(content);
    // Not putting correctly the "o" at the center of the cell.
    // http://stackoverflow.com/questions/5554553/itext-pdftable-cell-vertical-alignment
    circleCell.setPaddingTop(paddingTop);
    circleCell.setHorizontalAlignment(Element.ALIGN_CENTER);
    circleCell.setVerticalAlignment(alignment);
    circleCell.setBorder(0);/*  w w w  .  ja  va 2s .c o  m*/
    circleCell.setMinimumHeight(20);
    return circleCell;
}

From source file:com.softwaremagico.tm.pdf.small.counters.VitalityTable.java

License:Open Source License

public VitalityTable(CharacterPlayer characterPlayer) {
    super(characterPlayer);

    getDefaultCell().setBorder(0);//  w w w.j  av  a 2 s.  c o  m

    Font font = new Font(FadingSunsTheme.getTitleFont(), FadingSunsTheme.CHARACTER_VITALITY_TITLE_FONT_SIZE);
    Phrase content = new Phrase(getTranslator().getTranslatedText("vitality"), font);
    PdfPCell titleCell = new PdfPCell(content);
    titleCell.setBorder(0);
    titleCell.setPaddingRight(0);
    titleCell.setPaddingTop(paddingTop);
    titleCell.setVerticalAlignment(Element.ALIGN_MIDDLE);
    addCell(titleCell);

    addedCircle = 0;

    for (int i = 0; i < getNumberOfCircles(); i++) {
        addCell(getCircle());
        addedCircle++;
    }

}

From source file:com.softwaremagico.tm.pdf.small.counters.WyrdTable.java

License:Open Source License

public WyrdTable(CharacterPlayer characterPlayer) {
    super(characterPlayer);

    getDefaultCell().setBorder(0);//from  www  .  ja  v  a2s  .c o m

    Font font = new Font(FadingSunsTheme.getTitleFont(), FadingSunsTheme.CHARACTER_VITALITY_TITLE_FONT_SIZE);
    Phrase content = new Phrase(getTranslator().getTranslatedText("wyrd"), font);
    PdfPCell titleCell = new PdfPCell(content);
    titleCell.setBorder(0);
    titleCell.setPaddingTop(paddingTop);
    titleCell.setVerticalAlignment(Element.ALIGN_MIDDLE);
    addCell(titleCell);

    addedCircle = 0;

    for (int i = 0; i < getNumberOfCircles(); i++) {
        addCell(getCircle());
        addedCircle++;
    }

}

From source file:com.softwaremagico.tm.pdf.small.fighting.ArmourTable.java

License:Open Source License

public ArmourTable(CharacterPlayer characterPlayer) {
    super(new float[] { 2.2f, 3 });
    getDefaultCell().setBorder(0);//from  ww  w  .  j av  a  2  s  .co m

    // Armor
    Font font = new Font(FadingSunsTheme.getTitleFont(), FadingSunsTheme.CHARACTER_SMALL_ARMOR_TITLE_FONT_SIZE);
    Phrase content = new Phrase(getTranslator().getTranslatedText("armor"), font);
    PdfPCell titleCell = new PdfPCell(content);
    titleCell.setBorder(0);
    addCell(titleCell);

    PdfPCell nameCell;
    if (characterPlayer == null) {
        nameCell = CustomPdfTable.createEmptyElementLine(GAP, NAME_COLUMN_WIDTH);
    } else if (characterPlayer.getArmour() == null) {
        nameCell = createElementLine("", NAME_COLUMN_WIDTH);
    } else {
        nameCell = createElementLine(characterPlayer.getArmour().getName() + "("
                + characterPlayer.getArmour().getProtection() + "d)", NAME_COLUMN_WIDTH,
                FadingSunsTheme.ARMOUR_CONTENT_FONT_SIZE - 1);
    }
    nameCell.setBorder(0);
    nameCell.setHorizontalAlignment(Element.ALIGN_LEFT);
    addCell(nameCell);

    // Shield
    addCell(getShieldRange(characterPlayer));

    Paragraph paragraph = new Paragraph();
    paragraph.add(new Paragraph(getTranslator().getTranslatedText("shieldHits") + ": ",
            new Font(FadingSunsTheme.getLineFont(), FadingSunsTheme.ARMOUR_CONTENT_FONT_SIZE)));
    if (characterPlayer != null && characterPlayer.getShield() != null) {
        paragraph.add(new Paragraph(characterPlayer.getShield().getHits() + "-",
                new Font(FadingSunsTheme.getHandwrittingFont(),
                        FadingSunsTheme.getHandWrittingFontSize(FadingSunsTheme.ARMOUR_CONTENT_FONT_SIZE))));
    }
    PdfPCell shieldCell = new PdfPCell(paragraph);
    shieldCell.setVerticalAlignment(Element.ALIGN_MIDDLE);
    shieldCell.setBorder(0);
    addCell(shieldCell);
}

From source file:com.solidmaps.webapp.report.EnableCompanyRequerimentFederalPDF.java

private void insertCell(PdfPTable table, String text, Integer colSpan) {

     if (text == null) {
         text = "";
     }//from w w w  .j  a  va  2  s .  co m

     // create a new cell with the specified Text and Font
     PdfPCell cell = new PdfPCell(new Phrase(text.trim(), FONT_PARAGRAPH));
     // set the cell alignment
     // in case there is no text and you wan to create an empty row
     if (text.trim().equalsIgnoreCase("")) {
         cell.setMinimumHeight(10f);
     }

     cell.setHorizontalAlignment(Element.ALIGN_LEFT);
     cell.setColspan(colSpan);
     cell.setPadding(5f);

     // add the call to the table
     table.addCell(cell);
 }

From source file:com.solidmaps.webapp.report.EnableCompanyRequerimentFederalPDF.java

private void insertCellAlteracao(PdfPTable table, String text) {

     if (text == null) {
         text = "";
     }//  ww  w .java  2s  .  co  m

     // create a new cell with the specified Text and Font
     PdfPCell cell = new PdfPCell(new Phrase(text.trim(), FONT_HEADER));
     // set the cell alignment
     // in case there is no text and you wan to create an empty row
     if (text.trim().equalsIgnoreCase("")) {
         cell.setMinimumHeight(10f);
     }

     cell.setHorizontalAlignment(Element.ALIGN_CENTER);
     cell.setColspan(2);
     cell.setBackgroundColor(BaseColor.LIGHT_GRAY);
     cell.setBorderWidth(2);
     cell.setPadding(3f);

     // add the call to the table
     table.addCell(cell);
 }