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

PrintDocument.PrintPage event analogy in TELERIK

1 Answer 43 Views
RichTextBox
This is a migrated thread and some comments may be shown as answers.
kity
Top achievements
Rank 2
kity asked on 05 Sep 2014, 10:57 AM
How to do that with telerik with simple direct printing and RadRichTextBox.Printing functionality.


// TELERIK example event - can not find PrintPage event analogy
RadRichTextBox PrintPoorTelerikTextBox;
 
 this.PrintPoorTelerikTextBox.Document = this;
            this.PrintPoorTelerikTextBox.AllowScaling = true;
            this.PrintPoorTelerikTextBox.ChangeSectionPageOrientation(PageOrientation.Landscape);
             
            this.PrintPoorTelerikTextBox.PrintCompleted -= _printEventHandler;
            _printEventHandler = (s, a) =>
            {
                Wave.Platform.PortalFramework.Infrastructure.MessageBox.WaveMessageBox.Info("Report was successfully printed.");
                this.PrintPoorTelerikTextBox.Document = new RadDocument();
            };
            this.PrintPoorTelerikTextBox.PrintCompleted += _printEventHandler; 
             
        
 
            this.PrintPoorTelerikTextBox.PrintStarted+= delegate(object sender, EventArgs e)
            {
                 
            };
 
 
            this.PrintPoorTelerikTextBox.Print(this.PrintOptions);
 
 
 
// none telerik and work very well, hell yeah ;)
--------
PrintDocument pd = new PrintDocument();
            pd.PrintPage += (sender, e) =>
            {
                double scale = 1;
                if (e.PrintableArea.Height < this.PrintPoorTelerikTextBox.ActualHeight)              
                    scale = e.PrintableArea.Height / this.PrintPoorTelerikTextBox.ActualHeight;
                 
                if (e.PrintableArea.Width < this.PrintPoorTelerikTextBox.ActualWidth && e.PrintableArea.Width / this.PrintPoorTelerikTextBox.ActualWidth < scale)               
                    scale = e.PrintableArea.Width / this.PrintPoorTelerikTextBox.ActualWidth;
                 
                if (scale < 1)
                {
                    ScaleTransform scaleTransform = new ScaleTransform();
                    scaleTransform.ScaleX = scale;
                    scaleTransform.ScaleY = scale;
                    this.PrintPoorTelerikTextBox.RenderTransform = scaleTransform;
                }
                e.PageVisual = this.PrintPoorTelerikTextBox;
            };

...

1 Answer, 1 is accepted

Sort by
0
kity
Top achievements
Rank 2
answered on 05 Sep 2014, 11:35 AM
The main problem is that in RadRichTextBox missing acces to  public property of type-PrintDocument and cannot ovveride OnPrintPage(PrintPageEventArgs e);


​public class MyPrint : RadRichTextBox
{                
         protected override void OnPrintPage(PrintPageEventArgs e);
}


Tags
RichTextBox
Asked by
kity
Top achievements
Rank 2
Answers by
kity
Top achievements
Rank 2
Share this question
or