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