/** * 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) : base(doc) { if (phrase == null) { return; } if (phrase.HasLeading()) { this.lineLeading = (int) (phrase.Leading * TWIPS_FACTOR); } else { this.lineLeading = 0; } ST.RtfFont phraseFont = new ST.RtfFont(null, phrase.Font); for (int i = 0; i < phrase.Count; i++) { IElement chunk = (IElement) phrase[i]; if (chunk is Chunk) { ((Chunk) chunk).Font = phraseFont.Difference(((Chunk) chunk).Font); } try { IRtfBasicElement[] rtfElements = doc.GetMapper().MapElement(chunk); for (int j = 0; j < rtfElements.Length; j++) { chunks.Add(rtfElements[j]); } } catch (DocumentException) { } } }