This is a migrated thread and some comments may be shown as answers.

Problem with styling page number in the exported document.

1 Answer 54 Views
RichTextBox
This is a migrated thread and some comments may be shown as answers.
john
Top achievements
Rank 1
john asked on 29 Sep 2015, 10:00 AM

Hi,

I'm styling page number in the footer section like this:

            var fontSize = 11d;
            var paragraph = new Paragraph();

            var page = new PageField { DisplayMode = FieldDisplayMode.Result };
            var pageStart = new FieldRangeStart { Field = page };
            var pageEnd = new FieldRangeEnd { Start = pageStart };

            paragraph.Inlines.Add(pageStart);
            paragraph.Inlines.Add(new Span("_") { FontSize = fontSize   // span that is replaced by actual page number with setted font size
            paragraph.Inlines.Add(pageEnd);

In the silverlight application this page number looks fine, font size is the same as in code.

Problem occurs when exporting RadDocument to word document. In this scenario font-size of the page number in the footer is altered to 12 (I think it's default value). After exporting to word document, if you try to export to for example pdf, font-size is bugged too. 

Any ideas how to solve this problem?

1 Answer, 1 is accepted

Sort by
0
Tanya
Telerik team
answered on 02 Oct 2015, 07:24 AM
Hi John,

The approach you are using actually doesn't always work as expected. I could suggest you to use the RadDocumentEditor class when you make changes in a RadDocument as it provides a better API and performs important updates after the modifications. In the snippet below you could check how I changed the code you sent us to use the mentioned API:
this.radRichTextBox.Document.Sections.First.Footers.Default.Body = new RadDocument();
RadDocumentEditor editor = new RadDocumentEditor(this.radRichTextBox.Document.Sections.First.Footers.Default.Body);
var fontSize = 11d;
 
editor.InsertParagraph();
 
var page = new PageField { DisplayMode = FieldDisplayMode.Result };
editor.ChangeFontSize(fontSize);
editor.InsertField(page);

Hope this is helpful.

Regards,
Tanya
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
RichTextBox
Asked by
john
Top achievements
Rank 1
Answers by
Tanya
Telerik team
Share this question
or