
Dhaval patel
Top achievements
Rank 1
Dhaval patel
asked on 17 Oct 2011, 02:13 PM
Hello,
I prepare data by RadDocument and assign to RadRichTextBox(RadRichTextBox.1Document).
and then give it to print.
Is it possible to give page number to printed document.
also to export to PDF?
Thanks in advance...
I prepare data by RadDocument and assign to RadRichTextBox(RadRichTextBox.1Document).
and then give it to print.
Is it possible to give page number to printed document.
also to export to PDF?
Thanks in advance...
10 Answers, 1 is accepted
0

Maulik
Top achievements
Rank 1
answered on 18 Oct 2011, 07:48 AM
Even i want to know that stuff :) Waiting for reply!
0

Dhaval patel
Top achievements
Rank 1
answered on 18 Oct 2011, 12:42 PM
Please help me !!!!! :(
0
Hello Dhaval Patel,
You can add page fields programmatically as described in this forum.
The page numbers inserted in this way will also be exported to PDF correctly.
Kind regards,
Iva Toteva
the Telerik team
You can add page fields programmatically as described in this forum.
The page numbers inserted in this way will also be exported to PDF correctly.
Kind regards,
Iva Toteva
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>
0

Dhaval patel
Top achievements
Rank 1
answered on 21 Oct 2011, 12:23 PM
Hello,
thanks for reply :)
I have tried to give page number as you said,
1. create new Class for
thanks for reply :)
I have tried to give page number as you said,
1. create new Class for
PagesNumberField.
2.Override method
GetResultFragment.
protected
override
DocumentFragment GetResultFragment()
{
int
pageNumber = 0;
int
pagesCount = 0;
if
(
this
.Document !=
null
)
{
DocumentPosition position =
new
DocumentPosition(
this
.Document);
position.MoveToStartOfDocumentElement(
this
.FieldStart);
SectionLayoutBox sectionBox = position.GetCurrentSectionBox();
pageNumber = sectionBox.PageNumber;
pagesCount = DocumentStructureCollection.GetChildrenCount(
this
.Document.DocumentLayoutBox);
}
string
resultString =
"Page "
+ pageNumber +
" of "
+ pagesCount;
return
base
.CreateFragmentFromText(resultString);
}
but it gives always
pagesCount
= 1 only..
so it print like Page 1 of 1, Page 2 of 1, Page 3 of 1..........
I prepare RedDocument by adding different sections for chart,grid and other information.
Thanks in advance
0
Hello Dhaval Patel,
This custom field with pages count won't work in headers and footers, as stated in the original thread. We will implement such field in the future, but until then your only option is to insert the total pages number as text.
Boby
the Telerik team
This custom field with pages count won't work in headers and footers, as stated in the original thread. We will implement such field in the future, but until then your only option is to insert the total pages number as text.
Don't hesitate to contact us if you have other questions.
Kind regards,Boby
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>
0

Jonathan
Top achievements
Rank 1
answered on 15 Aug 2012, 11:53 PM
Hello team:
Is this still the case that these custom fields do not work in headers and footers?
Thanks!
Jonathan
Is this still the case that these custom fields do not work in headers and footers?
Thanks!
Jonathan
0
Hi Jonathan,
Custom fields can be inserted in the header or footer. The particular implementation of a field containing the count of pages that Boby refered to had a limitation, which prevented that.
Please, do not hesitate to contact us if you have additional questions or comments. All the best,
Petya
the Telerik team
Custom fields can be inserted in the header or footer. The particular implementation of a field containing the count of pages that Boby refered to had a limitation, which prevented that.
However, I'm happy to inform you that RadRichTextBox already exposes a field with pages count. This is NumPagesField and it can also be inserted in the header or footer. Here is a snippet that shows how to do that:
radRichTextBox1.Document.Sections.First.Footers.Default.Body.InsertField(
new
NumPagesField(), FieldDisplayMode.Result);
Please, do not hesitate to contact us if you have additional questions or comments. All the best,
Petya
the Telerik team
Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.
0

Patrick
Top achievements
Rank 2
answered on 06 Sep 2012, 02:02 PM
Hi,
The code "
So, to resume, I want to insert the field at the cursor position. If it is in the footer or header section, I want it there.
Thanks a lot,
Patrick
The code "
radRichTextBox1.Document.Sections.First.Footers.Default.Body.InsertField(
new
NumPagesField(), FieldDisplayMode.Result);
", effectively, put the total pages of the document. The issue that I'm facing is, if I want to map the code with a button and the document is in the footer or header section, it won't put the field in the header/footer cursor position but in the current document position. Here is my snippet:Private
Sub
RRbtnInsertTotalPages_Click(sender
As
System.
Object
, e
As
System.Windows.RoutedEventArgs)
Handles
RRbtnInsertTotalPages.Click
If
editor.IsInHeaderFooterEditMode
Then
Dim
CP
As
Telerik.Windows.Documents.DocumentPosition =
New
DocumentPosition(
Me
.editor.Document.CaretPosition)
CP.GetCurrentSectionBox.GetFooter.Body.InsertField(
New
NumPagesField(), FieldDisplayMode.Result)
Else
editor.Document.InsertField(
New
NumPagesField, FieldDisplayMode.Code)
End
If
End
Sub
So, to resume, I want to insert the field at the cursor position. If it is in the footer or header section, I want it there.
Thanks a lot,
Patrick
0
Hello Patrick,
You can use the ActiveDocumentEditor property in order to insert NumPagesField at the caret position.
I hope this answers your question!
Regards,
Petya
the Telerik team
You can use the ActiveDocumentEditor property in order to insert NumPagesField at the caret position.
editor.ActiveDocumentEditor.InsertField(
New
NumPagesField(), FieldDisplayMode.Result)
I hope this answers your question!
Regards,
Petya
the Telerik team
Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.
0

Patrick
Top achievements
Rank 2
answered on 11 Sep 2012, 08:50 PM
Thanks. It works fine!