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

Problems printing RichTextBox with SL5 native printing

3 Answers 147 Views
RichTextBox
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Roberth Klemetsen
Top achievements
Rank 1
Roberth Klemetsen asked on 10 Feb 2012, 02:27 PM
Hi

I am trying to print a RadRichTextBox inside a usercontrol via Silverlight native printing.
This was working with SL4, but after upgrading to SL5 (also remembered to swap to SL5 telerik dlls.) it crashes.

The difference is the bitmap-way versus the vector-way I guess.
When using the PrintToBitmap()-method in SL5 it works like in SL4.

Is there something that I should be aware of when using vector-print or maybe there is something I am doing wrong?

Thanks for any pointers
Regards

3 Answers, 1 is accepted

Sort by
0
Boby
Telerik team
answered on 14 Feb 2012, 08:34 AM
Hi Robert,
Silverlight 5 vector printing sometimes fails unexpectedly when there are invisible elements in the visual tree. We are already in contact with Microsoft on this case, but meanwhile you can try to remove one of the UI layers that is possibly causing the problem. Just before printing, you could set custom UILayersBuilder to RadRichTextBox:
public class CustomLayersBuilder : UILayersBuilder
{
    protected override void BuildUILayersOverride(IUILayerContainer uiLayerContainer)
    {
        uiLayerContainer.UILayers.Remove(DefaultUILayers.AdornerLayer);
    }
}
 
...
this.radRichTextBox.UILayersBuilder = new CustomLayersBuilder();
this.radRichTextBox.UpdateEditorLayout();
This layers contains the adorner shown when image is selected, and is used for image resizing. If this fits your case, you can permanently remove it with the mentioned technique.
If this doesn't solve your problem, we will appreciate sample project (attached to a support ticket) so we can try to create better workaround for your case.

Don't hesitate to contact us if you have further questions.

Regards,
Boby
the Telerik team
Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
0
Roberth Klemetsen
Top achievements
Rank 1
answered on 15 Feb 2012, 04:08 PM
Hi and thanks for the response.
I tried the technique but it didn't work. I applied it just before assigning the parent control to PageVisual and also when the RichTextBox_Loaded event fired.
Just for fun i also tried removing all the layers defined in the DefaultUILayers class but that did not help either. It seems any pages with the RadRichTextBox will get dropped silently.

However I don't think this really fits my case as there are never any images in the control when printing.
I am just using the rich text box to present a simple html text via the HtmlFormatProvider

I will look into creating a sample project and submitting the support ticket.


0
Boby
Telerik team
answered on 17 Feb 2012, 05:39 PM
Hello Robert,
It looks like you have hit another issue. The problematic layer in your case is DefaultUILayers.SelectionLayer, and if you remove it (with the custom layers builder) before printing start you should be able to print the document. We will log and fix the issue for the next release (2012 Q1 SP1).

All the best,
Boby
the Telerik team
Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
Tags
RichTextBox
Asked by
Roberth Klemetsen
Top achievements
Rank 1
Answers by
Boby
Telerik team
Roberth Klemetsen
Top achievements
Rank 1
Share this question
or