Problems printing RichTextBox with SL5 native printing

4 posts, 0 answers
  1. Roberth Klemetsen
    Roberth Klemetsen avatar
    4 posts
    Member since:
    Nov 2009

    Posted 10 Feb 2012 Link to this post

    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
  2. Boby
    Admin
    Boby avatar
    686 posts

    Posted 14 Feb 2012 Link to this post

    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 >>
  3. Roberth Klemetsen
    Roberth Klemetsen avatar
    4 posts
    Member since:
    Nov 2009

    Posted 15 Feb 2012 Link to this post

    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.


  4. Boby
    Admin
    Boby avatar
    686 posts

    Posted 17 Feb 2012 Link to this post

    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 >>
Back to Top