Inheritance: iTextSharp.text.rtf.RtfElement
Esempio n. 1
0
 /**
 * Constructs a RtfAnchor based on a RtfField
 * 
 * @param doc The RtfDocument this RtfAnchor belongs to
 * @param anchor The Anchor this RtfAnchor is based on
 */
 public RtfAnchor(RtfDocument doc, Anchor anchor) : base(doc) {
     this.url = anchor.Reference;
     this.content = new RtfPhrase(doc, anchor);
 }
Esempio n. 2
0
        /**
        * Takes an Element subclass and returns the correct IRtfBasicElement
        * subclass, that wraps the Element subclass.
        *
        * @param element The Element to wrap
        * @return A IRtfBasicElement wrapping the Element
        * @throws DocumentException
        */
        public IRtfBasicElement MapElement(IElement element)
        {
            IRtfBasicElement rtfElement = null;

            if (element is IRtfBasicElement) {
                rtfElement = (IRtfBasicElement) element;
                rtfElement.SetRtfDocument(this.rtfDoc);
                return rtfElement;
            }
            switch (element.Type) {
                case Element.CHUNK:
                    if (((Chunk) element).GetImage() != null) {
                        rtfElement = new RtfImage(rtfDoc, ((Chunk) element).GetImage());
                    } else if (((Chunk) element).HasAttributes() && ((Chunk) element).Attributes.ContainsKey(Chunk.NEWPAGE)) {
                        rtfElement = new RtfNewPage(rtfDoc);
                    } else {
                        rtfElement = new RtfChunk(rtfDoc, (Chunk) element);
                    }
                    break;
                case Element.PHRASE:
                    rtfElement = new RtfPhrase(rtfDoc, (Phrase) element);
                    break;
                case Element.PARAGRAPH:
                    rtfElement = new RtfParagraph(rtfDoc, (Paragraph) element);
                    break;
                case Element.ANCHOR:
                    rtfElement = new RtfAnchor(rtfDoc, (Anchor) element);
                    break;
                case Element.ANNOTATION:
                    rtfElement = new RtfAnnotation(rtfDoc, (Annotation) element);
                    break;
                case Element.IMGRAW:
                case Element.IMGTEMPLATE:
                case Element.JPEG:
                    rtfElement = new RtfImage(rtfDoc, (Image) element);
                    break;
                case Element.AUTHOR:
                case Element.SUBJECT:
                case Element.KEYWORDS:
                case Element.TITLE:
                case Element.PRODUCER:
                case Element.CREATIONDATE:
                    rtfElement = new RtfInfoElement(rtfDoc, (Meta) element);
                    break;
                case Element.LIST:
                    rtfElement = new RtfList(rtfDoc, (List) element);
                    break;
                case Element.LISTITEM:
                    rtfElement = new RtfListItem(rtfDoc, (ListItem) element);
                    break;
                case Element.SECTION:
                    rtfElement = new RtfSection(rtfDoc, (Section) element);
                    break;
                case Element.CHAPTER:
                    rtfElement = new RtfChapter(rtfDoc, (Chapter) element);
                    break;
                case Element.TABLE:
                    try {
                        rtfElement = new TB.RtfTable(rtfDoc, (Table) element);
                    }
                    catch (InvalidCastException) {
                        rtfElement = new TB.RtfTable(rtfDoc, ((SimpleTable) element).CreateTable());
                    }
                    break;
            }

            return rtfElement;
        }