Ejemplo n.º 1
0
        /**
         * Constructs a RtfHeaderFooter based on a HeaderFooter with a certain type and displayAt
         * location. For internal use only.
         *
         * @param doc The RtfDocument this RtfHeaderFooter belongs to
         * @param headerFooter The HeaderFooter to base this RtfHeaderFooter on
         * @param type The type of RtfHeaderFooter
         * @param displayAt The display location of this RtfHeaderFooter
         */
        protected internal RtfHeaderFooter(RtfDocument doc, HeaderFooter headerFooter, int type, int displayAt) : base(new Phrase(""), false)
        {
            this.document  = doc;
            this.type      = type;
            this.displayAt = displayAt;
            Paragraph par = new Paragraph();

            par.Alignment = headerFooter.Alignment;
            if (headerFooter.Before != null)
            {
                par.Add(headerFooter.Before);
            }
            if (headerFooter.IsNumbered())
            {
                par.Add(new FD.RtfPageNumber(this.document));
            }
            if (headerFooter.After != null)
            {
                par.Add(headerFooter.After);
            }
            try {
                this.content = new Object[1];
                if (this.document != null)
                {
                    this.content[0] = this.document.GetMapper().MapElement(par);
                    ((IRtfBasicElement)this.content[0]).SetInHeader(true);
                }
                else
                {
                    this.content[0] = par;
                }
            } catch (DocumentException) {
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Constructs a RtfHeaderFooter for a HeaderFooter.
        /// </summary>
        /// <param name="doc">The RtfDocument this RtfHeaderFooter belongs to</param>
        /// <param name="headerFooter">The HeaderFooter to base this RtfHeaderFooter on</param>
        protected internal RtfHeaderFooter(RtfDocument doc, HeaderFooter headerFooter) : base(new Phrase(""), false)
        {
            _document = doc;
            Paragraph par = new Paragraph();

            par.Alignment = headerFooter.Alignment;
            if (headerFooter.Before != null)
            {
                par.Add(headerFooter.Before);
            }
            if (headerFooter.IsNumbered())
            {
                par.Add(new FD.RtfPageNumber(_document));
            }
            if (headerFooter.After != null)
            {
                par.Add(headerFooter.After);
            }
            try
            {
                _content    = new object[1];
                _content[0] = doc.GetMapper().MapElement(par)[0];
                ((IRtfBasicElement)_content[0]).SetInHeader(true);
            }
            catch (DocumentException)
            {
            }
        }
        /// <summary>
        /// Constructs a RtfHeaderFooter based on a HeaderFooter with a certain type and displayAt
        /// location. For internal use only.
        /// </summary>
        /// <param name="doc">The RtfDocument this RtfHeaderFooter belongs to</param>
        /// <param name="headerFooter">The HeaderFooter to base this RtfHeaderFooter on</param>
        /// <param name="type">The type of RtfHeaderFooter</param>
        /// <param name="displayAt">The display location of this RtfHeaderFooter</param>
        protected internal RtfHeaderFooter(RtfDocument doc, HeaderFooter headerFooter, int type, int displayAt) : base(new Phrase(""), false)
        {
            _document  = doc;
            _type      = type;
            _displayAt = displayAt;
            var par = new Paragraph
            {
                Alignment = headerFooter.Alignment
            };

            if (headerFooter.Before != null)
            {
                par.Add(headerFooter.Before);
            }
            if (headerFooter.IsNumbered())
            {
                par.Add(new FD.RtfPageNumber(_document));
            }
            if (headerFooter.After != null)
            {
                par.Add(headerFooter.After);
            }
            try
            {
                _content = new object[1];
                if (_document != null)
                {
                    _content[0] = _document.GetMapper().MapElement(par)[0];
                    ((IRtfBasicElement)_content[0]).SetInHeader(true);
                }
                else
                {
                    _content[0] = par;
                }
            }
            catch (DocumentException)
            {
            }
        }