internal void FromPageField(PageField pf)
        {
            this.SetAllNull();

            if (pf.Field != null) this.Field = pf.Field.Value;
            if (pf.Item != null) this.Item = pf.Item.Value;
            if (pf.Hierarchy != null) this.Hierarchy = pf.Hierarchy.Value;
            if (pf.Name != null) this.Name = pf.Name.Value;
            if (pf.Caption != null) this.Caption = pf.Caption.Value;
        }
        internal PageField ToPageField()
        {
            PageField pf = new PageField();
            pf.Field = this.Field;
            if (this.Item != null) pf.Item = this.Item.Value;
            pf.Hierarchy = this.Hierarchy;
            if (this.Name != null && this.Name.Length > 0) pf.Name = this.Name;
            if (this.Caption != null && this.Caption.Length > 0) pf.Caption = this.Caption;

            return pf;
        }
        private void AddPageFooter()
        {
            RadDocument document = new RadDocument();
            Section sectionf = new Section();
            Paragraph paragraphPageField = new Paragraph() { TextAlignment = RadTextAlignment.Right };
            PageField pageField = new PageField() { DisplayMode = FieldDisplayMode.Result };
            FieldRangeStart pageFieldStart = new FieldRangeStart();
            pageFieldStart.Field = pageField;
            FieldRangeEnd pageFieldEnd = new FieldRangeEnd();
            pageFieldEnd.Start = pageFieldStart;

            paragraphPageField.Inlines.Add(pageFieldStart);
            paragraphPageField.Inlines.Add(pageFieldEnd);

            FieldRangeStart numPagesFieldStart = new FieldRangeStart();
            numPagesFieldStart.Field = new NumPagesField() { DisplayMode = FieldDisplayMode.Result };
            FieldRangeEnd numPagesFieldEnd = new FieldRangeEnd();
            numPagesFieldEnd.Start = numPagesFieldStart;

            paragraphPageField.Inlines.Add(new Span("/"));
            paragraphPageField.Inlines.Add(numPagesFieldStart);
            paragraphPageField.Inlines.Add(numPagesFieldEnd);

            sectionf.Blocks.Add(paragraphPageField);
            document.Sections.Add(sectionf);

            Document.Sections.First.Footers.Default.Body = document;

            //Document.Sections.Last.Blocks.AddAfter(Document.Sections.Last.Blocks.Last, paragraphPageField);
            //Document.Sections.Last.Footers.Default.Body.InsertFragment(new DocumentFragment(document));
        }
        private Footer CreateFooter()
        {
            RadDocument footerDocument = new RadDocument();
            RadDocumentEditor editor = new RadDocumentEditor(footerDocument);

            editor.InsertTable(1, 2);
            editor.ChangeStyleName(RadDocumentDefaultStyles.DefaultNormalTableStyleName);

            editor.Document.Selection.SelectAll();

            editor.ChangeFontFamily(new FontFamily("Arial"));
            editor.ChangeForeColor(Color.FromRgb(29, 192, 34));
            editor.ChangeFontSize(Unit.PointToDip(10));

            editor.Document.Selection.Clear();

            editor.Insert("Copyright © 2002-2015 Telerik. All rights reserved.");

            var table = editor.Document.EnumerateChildrenOfType<Table>().FirstOrDefault();

            editor.Document.CaretPosition.MoveToStartOfDocumentElement(table.Rows.First.Cells.Last);
            table.Grid.Columns.Last().PreferredWidth = new TableWidthUnit(20);

            PageField field = new PageField();
            editor.InsertField(field, FieldDisplayMode.Result);
            editor.ChangeParagraphTextAlignment(RadTextAlignment.Right);

            Footer footer = new Footer() { Body = footerDocument };
            return footer;
        }