Printing problem... with chart

2 posts, 0 answers
  1. Junyoung
    Junyoung avatar
    1 posts
    Member since:
    Nov 2011

    Posted 11 Jan 2012 Link to this post

    Hi.

    I tried to print out the chart.
    I created some codes with reference to the source code of demo project(Export PDF/Print), but following exception has occurred.

    I've tried to save docx file. It worked fine. please check my codes......

    ----------------------------------------------------------------------------------------------------------------------------------------------


    private void PrintChart()
    {
                RadRichTextBox RadRichTextBox1 = new RadRichTextBox();
                RadRichTextBox1.Document = CreateDocument();

    // below line made a exception : NullReferenceException was unhandled
                RadRichTextBox1.Print("test",PrintMode.Native);


    }



            private void CreateChartDocumentPart(RadDocument document)
            {
                Telerik.Windows.Documents.Model.Section section = new Telerik.Windows.Documents.Model.Section();
                Telerik.Windows.Documents.Model.Paragraph paragraph = new Telerik.Windows.Documents.Model.Paragraph();


                MemoryStream ms = new MemoryStream();
                currentChart.ExportToImage(ms, new PngBitmapEncoder());


                double imageWidth = currentChart.ActualWidth;
                double imageHeight = currentChart.ActualHeight;
                if (imageWidth > 625)
                {
                    imageWidth = 625;
                    imageHeight = currentChart.ActualHeight * imageWidth / currentChart.ActualWidth;
                }


                ImageInline image = new ImageInline(ms, new Size(imageWidth, imageHeight), "png");


                paragraph.Inlines.Add(image);
                section.Blocks.Add(paragraph);
                document.Sections.Add(section);


                ms.Close();
            }



            private RadDocument CreateDocument()
            {
                RadDocument document = new RadDocument();


                this.CreateChartDocumentPart(document);
                //this.CreateGridDocumentPart(document);


                return document;
            }


  2. Nikolay
    Admin
    Nikolay avatar
    386 posts

    Posted 13 Jan 2012 Link to this post

    Hi,

    Please, have a look at this forum post, it may be helpful in your scenario. In case the proposed solution does not work for you, could you please open a support ticket and send us a sample runnable application that we can debug locally and provide further support.

    All the best,
    Nikolay
    the Telerik team
    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>
  3. UI for WPF is Visual Studio 2017 Ready
Back to Top