Java Code Examples for com.lowagie.text.Phrase#size()

The following examples show how to use com.lowagie.text.Phrase#size() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RtfPhrase.java    From itext2 with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * Constructs a new RtfPhrase for the RtfDocument with the given Phrase
 * 
 * @param doc The RtfDocument this RtfPhrase belongs to
 * @param phrase The Phrase this RtfPhrase is based on
 */
public RtfPhrase(RtfDocument doc, Phrase phrase) {
    super(doc);
    
    if(phrase == null) {
        return;
    }
    
    if(phrase.hasLeading()) {
        this.lineLeading = (int) (phrase.getLeading() * RtfElement.TWIPS_FACTOR);
    } else {
        this.lineLeading = 0;
    }
    
    RtfFont phraseFont = new RtfFont(null, phrase.getFont());
    for(int i = 0; i < phrase.size(); i++) {
        Element chunk = (Element) phrase.get(i);
        if(chunk instanceof Chunk) {
            ((Chunk) chunk).setFont(phraseFont.difference(((Chunk) chunk).getFont()));
        }
        try {
            RtfBasicElement[] rtfElements = doc.getMapper().mapElement(chunk);
            for(int j = 0; j < rtfElements.length; j++) {
                chunks.add(rtfElements[j]);
            }
        } catch(DocumentException de) {
        }
    }
}
 
Example 2
Source File: TextField.java    From gcs with Mozilla Public License 2.0 4 votes vote down vote up
private static void changeFontSize(Phrase p, float size) {
    for (int k = 0; k < p.size(); ++k)
        ((Chunk)p.get(k)).getFont().setSize(size);
}
 
Example 3
Source File: TextField.java    From itext2 with GNU Lesser General Public License v3.0 4 votes vote down vote up
private static void changeFontSize(Phrase p, float size) {
    for (int k = 0; k < p.size(); ++k)
        ((Chunk)p.get(k)).getFont().setSize(size);
}