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

Printing problem... with chart

1 Answer 73 Views
Chart
This is a migrated thread and some comments may be shown as answers.
Junyoung
Top achievements
Rank 1
Junyoung asked on 11 Jan 2012, 09:22 AM
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;
        }


1 Answer, 1 is accepted

Sort by
0
Nikolay
Telerik team
answered on 13 Jan 2012, 08:51 AM
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 >>
Tags
Chart
Asked by
Junyoung
Top achievements
Rank 1
Answers by
Nikolay
Telerik team
Share this question
or