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

RadRichTextBox printing blank pages..

3 Answers 166 Views
RichTextBox
This is a migrated thread and some comments may be shown as answers.
alino
Top achievements
Rank 1
alino asked on 07 Jun 2011, 08:31 PM
Hi everybody,

I Have a problem of printing RadDocument in the RadRichTextBox. I created dynamically the radDocument in my application and set this radDocument to the Document Proprty of the RadRichTextBox. My RadRichTextBox is in the UserControl I added in the Application Tree before I call print method of the RadRichTexBox. I follow exacty the telerik sample on this page  by using Native print Mode : http://www.telerik.com/community/forums/silverlight/richtextbox/printing-a-raddocument-without-assigning-to-a-radrichtextbox.aspx
The problem is the result of printing is blank pages, but i checked before printing and my RadDocument from RadRichTextBox contains different sections i created. I work around almost a day without solving this issue.
Any idea to overcome my problem ? Thanks!

Best regards.

Alino

3 Answers, 1 is accepted

Sort by
0
Iva Toteva
Telerik team
answered on 09 Jun 2011, 05:05 PM
Hi alino,

The document fails to print with native printing when the rich text box is not in the visual tree at the time when you invoke the print method due to limitations in Silverlight printing. The code in the sample application you have quoted works with the version of the control at the time, because the rich text box is removed from the children of the layout root at printing completed. However, with the latest version of RadRichTextBox, the notifying mechanism has slightly changed.
Provided that you have instantiated a RadRichTextBox called textBox in code-behind and assigned the RadDocument you wish to print to its Document property, you can print it as follows:
private void btnPrint_Click(object sender, RoutedEventArgs e)
{
    this.LayoutRoot.Children.Add(textBox);
    textBox.ApplyTemplate();
    textBox.UpdateEditorLayout();
    textBox.ActiveEditorPresenter = new DocumentPrintPresenter(new PrintSettings());
    textBox.Print("Test Document", PrintMode.Silverlight);
    ((DocumentPrintPresenter)textBox.ActiveEditorPresenter).PrintingCompleted += new EventHandler(MainPage_PrintingCompleted);
}
 
void MainPage_PrintingCompleted(object sender, EventArgs e)
{
    this.LayoutRoot.Children.Remove(textBox);
}

I hope this helps.

Greetings,
Iva
the Telerik team
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 Public Issue Tracking system and vote to affect the priority of the items
0
alino
Top achievements
Rank 1
answered on 10 Jun 2011, 08:31 PM
Hi Iva,

Thank you very much for your support, the way to make it working is to add the richText in the visual tree.
But still silverlight printing is too slow!! If i choose to print  for example one page in  XPS format, the printing is very very slow. Any idea to improve the printing process ?

Thanks.

Alino
0
Iva Toteva
Telerik team
answered on 13 Jun 2011, 09:41 AM
Hello alino,

We have no control over the speed of the native printing. It has been said that the printing will be improved in Silverlight 5, but it is a factor beyond our scope.
As we are aware of this limitation, we have added support for HTML printing that uses the browser to print the document and is much faster. However, with it you don't have much control over the way the document content is allocated between the pages. On the other hand, with HTML printing you don't have the requirement that the rich text box be added to the visual tree. You can test it in the demo in the thread you found originally.

Regards,
Iva
the Telerik team
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 Public Issue Tracking system and vote to affect the priority of the items
Tags
RichTextBox
Asked by
alino
Top achievements
Rank 1
Answers by
Iva Toteva
Telerik team
alino
Top achievements
Rank 1
Share this question
or