Print out content

15 posts, 0 answers
  1. End
    End avatar
    2 posts
    Member since:
    Oct 2012

    Posted 13 Nov 2012 Link to this post

    Hello,

    I am new to Telerik WinControl. I’m using version 2012.3.1017.40.

    I was looking for a control for displaying a chart-diagram in a Windows Forms application. I found the controls “RadChart” and “RadChartView”. Because of the advice of use the control “RadChartView” in your documentation I was making first experiences with this control the last days. As I can see so far, this control seems to be a powerful tool. Having created, configured this control and bound data to it I am looking for the possibility to print out the content of this control. In the documentation I have read that RadChartView does not support the functionality to export its content to a file. I would like to get to know if it is possible to print out the content of a “RadChartView” control anyway.

    Karim el Safadi

  2. Ivan Petrov
    Admin
    Ivan Petrov avatar
    701 posts

    Posted 16 Nov 2012 Link to this post

    Hi Karim,

    Thank you for writing.

    Currently, RadChartView does not support printing as RadGridView and RadScheduler do, but you can still print the control as an image. Please, find attached an example where I paint the control in a Bitmap object and then print this object using a helper class which implements the IPrintable interface. 

    I hope this will be useful. Should you have further questions, I would be glad to help.
     
    All the best,
    Ivan Petrov
    the Telerik team
    Q3’12 of RadControls for WinForms is available for download (see what's new). Get it today.
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Xavier Soares
    Xavier Soares avatar
    39 posts
    Member since:
    Jun 2008

    Posted 03 Dec 2012 Link to this post

    Hello Ivan,

    I've used Your code but, the data that is presented in  the RadPrintDocument isn't sent to the printer. It loads/shows the graph correctly but It does not send it to the printer.

    What's missing me?

    Thank you.
    Best regards,
    Luís Maurício
  5. Ivan Petrov
    Admin
    Ivan Petrov avatar
    701 posts

    Posted 06 Dec 2012 Link to this post

    Hi Luís,

    Thank you for writing.

    There are several things to check out in this situation - your printer connection, drivers, supplies (ink, paper). Try printing a document from another application (e.g. Office Word). Try printing a RadGridView/RadScheduler. In the print dialog check whether you have selected the right printer. If you are trying to print to a file check whether PrintToFile is allowed. 

    I hope this will help. Feel free to write back with any further questions.
     
    Greetings,
    Ivan Petrov
    the Telerik team
    Q3’12 of RadControls for WinForms is available for download (see what's new). Get it today.
  6. erwin
    erwin avatar
    358 posts
    Member since:
    Dec 2006

    Posted 30 Jan 2013 Link to this post

    Hi Ivan,
    returning null in GetSettingsDialog() seems to crash the Application (2012Q3SP1 newest Hotfix)
    Regards
    Erwin
  7. John Westerman
    John Westerman avatar
    5 posts
    Member since:
    Jun 2009

    Posted 31 Jan 2013 Link to this post

    Works great if the Chart is small, but make it fill the screen and try it. The chart does not fit to the page.

    Ideally, I would set the page to landscape and have some AutoFit to the page bounds.

    Could you advise?
  8. Ivan Petrov
    Admin
    Ivan Petrov avatar
    701 posts

    Posted 01 Feb 2013 Link to this post

    Hi Matthew and Erwin,

    Thank you both for writing.

    @Erwin
    Returning null would crash the app if you click on the settings button of the print preview dialog. You should either disable/hide this button or you can provide a custom settings dialog which should inherit Form/RadForm.

    @Matthew
    I have attached a modified version of the project from my first post which scales the chart image to fit in the page bounds.

    If you have further questions, I would be glad to help.

    Kind regards,
    Ivan Petrov
    the Telerik team
    Q3'12 SP1 of RadControls for WinForms is out now. See what's new.
  9. erwin
    erwin avatar
    358 posts
    Member since:
    Dec 2006

    Posted 01 Feb 2013 Link to this post

    Thanks Ivan,

    for those following this thread:

    To print out in Landscape mode, set the RadPrintDocument.Landscape Property to true.
    I've also added a quick hack to try and disable the settings ToolBar Button.
    Additionally I've extended the ChartPrinter Class to take and print a page title.
    private void printButton_Click(object sender, EventArgs e)
          {
              RadPrintDocument document = new RadPrintDocument();
              document.Landscape = true;
              document.AssociatedObject = new ChartPrinter(this.usageChartView,this.Machine.PrintableName + " - Software Usage");
              RadPrintPreviewDialog dialog = new RadPrintPreviewDialog(document);
     
              try
              {
                  // try to disable the print settings button
                  dialog.ToolCommandBar.CommandBarElement.Rows[0].Strips[0].Items[1].Enabled = false;
              }
              catch (Exception)
              {
                  ;
              }
     
              dialog.ShowDialog();
          }

    Regards
    Erwin

     

  10. John Westerman
    John Westerman avatar
    5 posts
    Member since:
    Jun 2009

    Posted 04 Feb 2013 Link to this post

    Thanks all for your help.
    The Chart is now scaling to the page nicely, however referring to the original post, when trying to print to the printer, there is an issue.
    1. Load the Chart onto the document.
    2. Click the [Print] command bar button.
    3. Select the required printer.
    4. Click [Print]

    A dialog saying "Printing 1 of Document" appears, but no printing happens. 

    I have tested the printer by printing to it from other applications and it is working fine.
  11. erwin
    erwin avatar
    358 posts
    Member since:
    Dec 2006

    Posted 04 Feb 2013 Link to this post


    I guess the ChartPrinter IPrintable Implementation EndPrint() function should return true instead of false
    According to the docs, EndPrint() returns false if the printing was cancelled.


    public bool EndPrint(RadPrintDocument sender, PrinterEventArgs args)
    {
        // return false;  -- suspected problem here
        return true;
    }


    Regards
    Erwin
  12. Ivan Petrov
    Admin
    Ivan Petrov avatar
    701 posts

    Posted 06 Feb 2013 Link to this post

    Hello guys,

    Thank you for writing.

    Indeed, the EndPrint method should return true. Thank you Erwin for that point.

    @Matthew: If you are still experiencing issues, please write back with more information on the situation.
     

    Regards,
    Ivan Petrov
    the Telerik team
    Q3'12 SP1 of RadControls for WinForms is out now. See what's new.
  13. John Westerman
    John Westerman avatar
    5 posts
    Member since:
    Jun 2009

    Posted 06 Feb 2013 Link to this post

    Now I feel like a fool
    Yes. Changed the return to True and it works a treat.

    Thank you all!
  14. Ivan Petrov
    Admin
    Ivan Petrov avatar
    701 posts

    Posted 08 Feb 2013 Link to this post

    Hi fellas,

    @Matthew: I am glad we were able to resolve the issue and came out with a working solution that satisfies your needs.

    @Erwin: Thank you for your cooperation. Your Telerik points have been updated.

    If there are further questions that need clarification, do not hesitate to write again.

    Greetings,
    Ivan Petrov
    the Telerik team
    Q3'12 SP1 of RadControls for WinForms is out now. See what's new.
  15. Todd
    Todd avatar
    6 posts
    Member since:
    May 2008

    Posted 12 Nov 2014 Link to this post

    Related to Erwin's  01 Feb 2013 post...

    I am having the same trouble with the print settings button on the RadPrintPreviewDialog, a complete app crash:

    Object not set to an instance of an object...
      at Telerik.WinControls.UI.RadPrintPreviewDialog.OnShowPrintSettingsDialog()\r\n   at Telerik.WinControls.UI.RadPrintPreviewDialog.buttonSettings_Click(Object sender, EventArgs e)\r\n   at Telerik.WinControls.RadElement.OnMouseDown(MouseEventArgs e)\r\n   at Telerik.WinControls.RadItem.OnMouseDown(MouseEventArgs e)\r\n   at Telerik.WinControls.RadElement.OnCLREventsRise(RoutedEventArgs args)\r\n   at Telerik.WinControls.RadElement.OnBubbleEvent(RadElement sender, RoutedEventArgs args)\r\n   at 
    ...
    ...
    ...

    Erwin's code to disable the settings button worked, but I would like to know if there are any known reasons (and fixes) for the underlying cause?

    We're using the 2014.2.715.20 versions, Windows 7 in a VS2013 IDE.






  16. Dimitar
    Admin
    Dimitar avatar
    1404 posts

    Posted 17 Nov 2014 Link to this post

    Hello Todd,

    Thank you for writing.

    RadChartView now supports this functionality out of the box and you do not need to use this sample project any more. Detailed information is available here: Printing.

    Please let me know if there is something else I can help you with. 

    Regards,
    Dimitar
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
Back to Top
UI for WinForms is Visual Studio 2017 Ready