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

Make text range invisible for printing

1 Answer 64 Views
RichTextBox
This is a migrated thread and some comments may be shown as answers.
Marcílio
Top achievements
Rank 1
Marcílio asked on 22 May 2018, 05:37 PM
Its possible a read only text range turn invisible for printing? That is, a read only text range followed by a editable range. And, when sent to printer, print only the editable part (the read only part leave just a white space on the printed page).

Is that possible with the RadRichTextBox?

1 Answer, 1 is accepted

Sort by
0
Boby
Telerik team
answered on 23 May 2018, 10:00 AM
Hi,

One option would be to intercept the printing command, apply transparent fore color to parts of the document, print, and then undo the change, for example:
this.radRichTextBox.CommandExecuting += (sender, e) =>
{
    if (e.Command is PrintCommand)
    {
        var rangeStart = this.radRichTextBox.Document.EnumerateChildrenOfType<PermissionRangeStart>().First();
 
        this.radRichTextBox.BeginUndoGroup();
        this.radRichTextBox.Document.Selection.SelectAnnotationRange(rangeStart);
        this.radRichTextBox.ChangeTextForeColor(Colors.Transparent);
        this.radRichTextBox.EndUndoGroup();
    }
};
 
this.radRichTextBox.CommandExecuted += (sender, e) =>
{
    if (e.Command is PrintCommand)
    {
        this.radRichTextBox.Undo();
    }
};


Regards,
Boby
Progress Telerik
Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which allow you to write beautiful native mobile apps using a single shared C# codebase.
Tags
RichTextBox
Asked by
Marcílio
Top achievements
Rank 1
Answers by
Boby
Telerik team
Share this question
or