RadRichTextBox printing issue

6 posts, 1 answers
  1. Soufiane
    Soufiane avatar
    1 posts
    Member since:
    Sep 2012

    Posted 03 Sep 2012 Link to this post

    Hello,

     

    We are using RadControls for WPF Q3 2011.2.712.40 Runtime version v4.0.30319 and we are facing a problem with printing using RadRichTextBox control.

     

    The code using to print (as shown on your Website) is :

     

    Telerik.Windows.Documents.UI.PrintSettings printSettings = new Telerik.Windows.Documents.UI.PrintSettings();

    printSettings.PrintMode = Telerik.Windows.Documents.UI.PrintMode.Native;

    printSettings.PrintScaling = Telerik.Windows.Documents.UI.PrintScaling.None;

    MyRichTextBox.Print(printSettings);

     

    And I’m getting the following error :

     

       at Telerik.Windows.Documents.UI.HeaderFooterPresenterBase.UpdateBody() in c:\TB\102\WPF_Scrum\Release_WPF_40\Sources\Development\Documents\UI\HeaderFooterPresenterBase.cs:line 338

       at Telerik.Windows.Documents.UI.HeaderFooterPresenterBase.OnApplyTemplate() in c:\TB\102\WPF_Scrum\Release_WPF_40\Sources\Development\Documents\UI\HeaderFooterPresenterBase.cs:line 417

       at System.Windows.FrameworkElement.ApplyTemplate()

       at System.Windows.FrameworkElement.MeasureCore(Size availableSize)

       at System.Windows.UIElement.Measure(Size availableSize)

       at System.Windows.Controls.Grid.MeasureCell(Int32 cell, Boolean forceInfinityV)

       at System.Windows.Controls.Grid.MeasureCellsGroup(Int32 cellsHead, Size referenceSize, Boolean ignoreDesiredSizeU, Boolean forceInfinityV)

       at System.Windows.Controls.Grid.MeasureOverride(Size constraint)

       at System.Windows.FrameworkElement.MeasureCore(Size availableSize)

       at System.Windows.UIElement.Measure(Size availableSize)

       at MS.Internal.Helper.MeasureElementWithSingleChild(UIElement element, Size constraint)

       at System.Windows.Controls.ContentPresenter.MeasureOverride(Size constraint)

       at System.Windows.FrameworkElement.MeasureCore(Size availableSize)

       at System.Windows.UIElement.Measure(Size availableSize)

       at System.Windows.Controls.Control.MeasureOverride(Size constraint)

       at System.Windows.FrameworkElement.MeasureCore(Size availableSize)

       at System.Windows.UIElement.Measure(Size availableSize)

       at System.Windows.Controls.Canvas.MeasureOverride(Size constraint)

       at System.Windows.FrameworkElement.MeasureCore(Size availableSize)

       at System.Windows.UIElement.Measure(Size availableSize)

       at Telerik.Windows.Documents.UI.DocumentPrintPresenter.MeasureOverride(Size availableSize) in c:\TB\102\WPF_Scrum\Release_WPF_40\Sources\Development\Documents\UI\DocumentPrintPresenter.cs:line 455

       at System.Windows.FrameworkElement.MeasureCore(Size availableSize)

       at System.Windows.UIElement.Measure(Size availableSize)

       at MS.Internal.Helper.MeasureElementWithSingleChild(UIElement element, Size constraint)

       at System.Windows.Controls.ContentPresenter.MeasureOverride(Size constraint)

       at System.Windows.FrameworkElement.MeasureCore(Size availableSize)

       at System.Windows.UIElement.Measure(Size availableSize)

       at System.Windows.ContextLayoutManager.UpdateLayout()

       at System.Windows.UIElement.UpdateLayout()

       at Telerik.Windows.Documents.UI.DocumentPrintPresenter.UpdateEditorLayout() in c:\TB\102\WPF_Scrum\Release_WPF_40\Sources\Development\Documents\UI\DocumentPrintPresenter.cs:line 308

       at Telerik.Windows.Documents.UI.DocumentPrintPresenter.DoOnDocumentChanged() in c:\TB\102\WPF_Scrum\Release_WPF_40\Sources\Development\Documents\UI\DocumentPrintPresenter.cs:line 301

       at Telerik.Windows.Documents.UI.DocumentPrintPresenter.OnOwnerChanged() in c:\TB\102\WPF_Scrum\Release_WPF_40\Sources\Development\Documents\UI\DocumentPrintPresenter.cs:line 283

       at Telerik.Windows.Documents.UI.DocumentPrintPresenter.set_Owner(RadRichTextBox value) in c:\TB\102\WPF_Scrum\Release_WPF_40\Sources\Development\Documents\UI\DocumentPrintPresenter.cs:line 102

       at Telerik.Windows.Controls.RadRichTextBox.InitActiveEditorPresenter() in c:\TB\102\WPF_Scrum\Release_WPF_40\Sources\Development\Documents\UI\RadRichTextBox.cs:line 2862

       at Telerik.Windows.Controls.RadRichTextBox.set_ActiveEditorPresenter(IDocumentEditorPresenter value) in c:\TB\102\WPF_Scrum\Release_WPF_40\Sources\Development\Documents\UI\RadRichTextBox.cs:line 1010

       at Telerik.Windows.Controls.RadRichTextBox.<>c__DisplayClass22.<Print>b__20(Object o, EventArgs e) in c:\TB\102\WPF_Scrum\Release_WPF_40\Sources\Development\Documents\UI\RadRichTextBox.cs:line 2391

       at Telerik.Windows.Documents.UI.DocumentPrintPresenter.OnPrintingStarted() in c:\TB\102\WPF_Scrum\Release_WPF_40\Sources\Development\Documents\UI\DocumentPrintPresenter.cs:line 702

       at Telerik.Windows.Documents.UI.DocumentPrintPresenter.Print() in c:\TB\102\WPF_Scrum\Release_WPF_40\Sources\Development\Documents\UI\DocumentPrintPresenter.cs:line 654

       at Telerik.Windows.Controls.RadRichTextBox.Print(PrintSettings printSettings) in c:\TB\102\WPF_Scrum\Release_WPF_40\Sources\Development\Documents\UI\RadRichTextBox.cs:line 2411

       at Optivia.WpfClient.Views.UserControls.CourrierType.UpdateCourrierTypeViewModel.ExportCourrierType(RadRichTextBoxBindable RTB) in C:\Projects\Eurovia_SSO\Optivia\Code\Optivia.WpfClient\Views\UserControls\CourrierType\UpdateCourrierTypeViewModel.cs:line 200

       at GalaSoft.MvvmLight.Command.RelayCommand`1.Execute(Object parameter)

       at MS.Internal.Commands.CommandHelpers.CriticalExecuteCommandSource(ICommandSource commandSource, Boolean userInitiated)

       at System.Windows.Controls.Primitives.ButtonBase.OnClick()

       at System.Windows.Controls.Button.OnClick()

       at Telerik.Windows.Controls.RadButton.OnClick() in c:\TB\102\WPF_Scrum\Release_WPF_40\Sources\Development\Core\Controls\Buttons\RadButton.cs:line 357

       at System.Windows.Controls.Primitives.ButtonBase.OnMouseLeftButtonUp(MouseButtonEventArgs e)

       at System.Windows.UIElement.OnMouseLeftButtonUpThunk(Object sender, MouseButtonEventArgs e)

       at System.Windows.Input.MouseButtonEventArgs.InvokeEventHandler(Delegate genericHandler, Object genericTarget)

       at System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target)

       at System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs)

       at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)

       at System.Windows.UIElement.ReRaiseEventAs(DependencyObject sender, RoutedEventArgs args, RoutedEvent newEvent)

       at System.Windows.UIElement.OnMouseUpThunk(Object sender, MouseButtonEventArgs e)

       at System.Windows.Input.MouseButtonEventArgs.InvokeEventHandler(Delegate genericHandler, Object genericTarget)

       at System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target)

       at System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs)

       at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)

       at System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args)

       at System.Windows.UIElement.RaiseTrustedEvent(RoutedEventArgs args)

       at System.Windows.UIElement.RaiseEvent(RoutedEventArgs args, Boolean trusted)

       at System.Windows.Input.InputManager.ProcessStagingArea()

       at System.Windows.Input.InputManager.ProcessInput(InputEventArgs input)

       at System.Windows.Input.InputProviderSite.ReportInput(InputReport inputReport)

       at System.Windows.Interop.HwndMouseInputProvider.ReportInput(IntPtr hwnd, InputMode mode, Int32 timestamp, RawMouseActions actions, Int32 x, Int32 y, Int32 wheel)

       at System.Windows.Interop.HwndMouseInputProvider.FilterMessage(IntPtr hwnd, WindowMessage msg, IntPtr wParam, IntPtr lParam, Boolean& handled)

       at System.Windows.Interop.HwndSource.InputFilterMessage(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)

       at MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)

       at MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)

       at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)

       at MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs, Delegate catchHandler)

     

    The print screen attached gives you a visual description of the error we are getting.

     

    We had tried to pass by HTML to do the job, but, and for client desire reason, we must pass by the control printing tool.

     

    Thank you so much for your time.

     

    Best regards

  2. Answer
    Boby
    Admin
    Boby avatar
    595 posts

    Posted 04 Sep 2012 Link to this post

    Hello Soufiane,

    Unfortunately there was a bug with native printing, which was introduced at a very late stage of development and passed in the final release build for the Q2 official release (2011.2.712).
    The good news is that we fixed it immediately in a subsequent internal build. If you upgrade to the Q2 SP1 (2011.2.920), the issue will no longer be present.
    If you have other questions, do not hesitate to contact us again.



    Greetings,
    Boby
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

  3. UI for WPF is Visual Studio 2017 Ready
  4. muhammad
    muhammad avatar
    28 posts
    Member since:
    Jul 2010

    Posted 05 Sep 2012 Link to this post

    Hi Boby,
                I have found a bug in latest release version 2012.2.725.40 as well with printing. I have checked the source code and in code before running the native print command its executing a check which is wrong its doing some not false value to false value check which produces opposite result as expected to execute the print command. Because of this scenario it fails if you press print button from printing dialog box, but it runs and start printing when you press cancel from dialog box. Can you please suggest the release time for the new version with fixes for version 2012.2.725.40 thanks.


    Regards.
  5. Petya
    Admin
    Petya avatar
    975 posts

    Posted 05 Sep 2012 Link to this post

    Hello Muhammad,

    Actually Boby has mixed up the versions in his reply.

    The printing works correctly in 2012 Q2 (2012.2 607), but is broken in 2012 Q2 SP1 (2012.2 725). The fix was made in the first internal build after the service pack and if you update to the LIB (latest internal build) everything should work as expected.

    The fix will also be available in the upcoming in less than two weeks SP2.

    Greetings,
    Petya
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

  6. Waut
    Waut avatar
    9 posts
    Member since:
    Jan 2013

    Posted 31 Jul 2013 Link to this post

    Sorry to bump this post, but I've got the 2012.3.1203.40 and this bug still manifests itself. I do need to print without user input. 

    This is my current code:
    _radRichTextBox.Document = RadDocument;
                var printSettings = new PrintSettings
                    {
                        PrintMode = PrintMode.Native,
                        PrintScaling = PrintScaling.None
                    };
                _radRichTextBox.Print(printSettings);

    and I get this error:
  7. Iva Toteva
    Admin
    Iva Toteva avatar
    1319 posts

    Posted 02 Aug 2013 Link to this post

    Hello Waut,

    I tried the version you have specified as the one you use and there was no problem printing the document. 

    However, if you have not added the RichTextBox to the visual tree or you have added it, but its Loaded event has not been fired yet, a NullReferenceException will indeed be thrown in the Print method of the control. RadRichTextBox requires that it is shown on the page during printing (in all versions of the control). It may be in a Grid row with Height="0", but it cannot have its Visibility set to "Collapsed". This said, if you add _richTextBox to the page shown when printing is initiated, there should be no problem printing the document.

    I hope this solves the issue.

    Regards,
    Iva Toteva
    Telerik
    TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WPF.
    Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
    Sign up for Free application insights >>
Back to Top
UI for WPF is Visual Studio 2017 Ready