Inheritance: iTextSharp.text.rtf.RtfAddableElement
Example #1
0
 /**
  * Adds a RtfTab to the list of grouped tabs.
  *
  * @param tab The RtfTab to add.
  */
 public void Add(RtfTab tab)
 {
     this.tabs.Add(tab);
 }
Example #2
0
 /**
 * Adds a RtfTab to the list of grouped tabs.
 * 
 * @param tab The RtfTab to add.
 */
 public void Add(RtfTab tab) {
     this.tabs.Add(tab);
 }
Example #3
0
        /**
        * Takes an Element subclass and returns an array of RtfBasicElement
        * subclasses, that contained the mapped RTF equivalent to the Element
        * passed in.
        * 
        * @param element The Element to wrap
        * @return An array of RtfBasicElement wrapping the Element
        * @throws DocumentException
        */
        public IRtfBasicElement[] MapElement(IElement element) {
            ArrayList rtfElements = new ArrayList();

            if (element is IRtfBasicElement) {
                IRtfBasicElement rtfElement = (IRtfBasicElement) element;
                rtfElement.SetRtfDocument(this.rtfDoc);
                return new IRtfBasicElement[]{rtfElement};
            }
            switch (element.Type) {
                case Element.CHUNK:
                    Chunk chunk = (Chunk) element;
                    if (chunk.HasAttributes()) {
                        if (chunk.Attributes.ContainsKey(Chunk.IMAGE)) {
                            rtfElements.Add(new RtfImage(rtfDoc, chunk.GetImage()));
                        } else if (chunk.Attributes.ContainsKey(Chunk.NEWPAGE)) {
                            rtfElements.Add(new RtfNewPage(rtfDoc));
                        } else if (chunk.Attributes.ContainsKey(Chunk.TAB)) {
                            float tabPos = (float) ((Object[]) chunk.Attributes[Chunk.TAB])[1];
                            RtfTab tab = new RtfTab(tabPos, RtfTab.TAB_LEFT_ALIGN);
                            tab.SetRtfDocument(rtfDoc);
                            rtfElements.Add(tab);
                            rtfElements.Add(new RtfChunk(rtfDoc, new Chunk("\t")));
                        } else {
                            rtfElements.Add(new RtfChunk(rtfDoc, (Chunk) element));
                        }
                    } else {
                        rtfElements.Add(new RtfChunk(rtfDoc, (Chunk) element));
                    }
                    break;
                case Element.PHRASE:
                    rtfElements.Add(new RtfPhrase(rtfDoc, (Phrase) element));
                    break;
                case Element.PARAGRAPH:
                    rtfElements.Add(new RtfParagraph(rtfDoc, (Paragraph) element));
                    break;
                case Element.ANCHOR:
                    rtfElements.Add(new RtfAnchor(rtfDoc, (Anchor) element));
                    break;
                case Element.ANNOTATION:
                    rtfElements.Add(new RtfAnnotation(rtfDoc, (Annotation) element));
                    break;
                case Element.IMGRAW:
                case Element.IMGTEMPLATE:
                case Element.JPEG:
                    rtfElements.Add(new RtfImage(rtfDoc, (Image) element));
                    break;
                case Element.AUTHOR: 
                case Element.SUBJECT:
                case Element.KEYWORDS:
                case Element.TITLE:
                case Element.PRODUCER:
                case Element.CREATIONDATE:
                    rtfElements.Add(new RtfInfoElement(rtfDoc, (Meta) element));
                    break;
                case Element.LIST:
                    rtfElements.Add(new RtfList(rtfDoc, (List) element));
                    break;
                case Element.LISTITEM:
                    rtfElements.Add(new RtfListItem(rtfDoc, (ListItem) element));
                    break;
                case Element.SECTION:
                    rtfElements.Add(new RtfSection(rtfDoc, (Section) element));
                    break;
                case Element.CHAPTER:
                    rtfElements.Add(new RtfChapter(rtfDoc, (Chapter) element));
                    break;
                case Element.TABLE:
                    try {
                        rtfElements.Add(new RtfTable(rtfDoc, (Table) element));
                    }
                    catch (InvalidCastException) {
                        rtfElements.Add(new RtfTable(rtfDoc, ((SimpleTable) element).CreateTable()));
                    }
                    break;
                case Element.PTABLE:
                    try {
                        rtfElements.Add(new RtfTable(rtfDoc, (PdfPTable) element));
                    }
                    catch(InvalidCastException) {
                        rtfElements.Add(new RtfTable(rtfDoc, ((SimpleTable) element).CreateTable()));
                    }
                    break;
            }
            
            return (IRtfBasicElement[]) rtfElements.ToArray(typeof(IRtfBasicElement));
        }
 /// <summary>
 /// Adds a RtfTab to the list of grouped tabs.
 /// </summary>
 /// <param name="tab">The RtfTab to add.</param>
 public void Add(RtfTab tab)
 {
     _tabs.Add(tab);
 }