PrintDocument.PrintPage event analogy in TELERIK

2 posts, 0 answers
  1. kity
    kity avatar
    71 posts
    Member since:
    Mar 2012

    Posted 05 Sep 2014 Link to this post

    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;
                };

    ...
  2. kity
    kity avatar
    71 posts
    Member since:
    Mar 2012

    Posted 05 Sep 2014 in reply to kity Link to this post

    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);
    }


  3. DevCraft banner
Back to Top