Make 2D Stacked Column MS Chart to PDF Sample
save microsoft stacked column chart to pdf in c# .net

Make 3D Stacked Column MS Chart to PDF Sample
save microsoft stacked 3d column chart to pdf in c# .net

C# code tutorial

This C#.NET guide demonstrates how to generate the Microsoft Stacked Column Chart (both 2D and 3D Stacked Column Chart), and insert the MS Stacked Column Chart image to PDF document.

Column stacked chart rotation, plot, size and other parameters can be customized by developers in the C# programming. The following C# sample code shows how to create and insert Microsoft Stacked Column Chart to PDF document quickly and easily.
Please note, before developers using the chart creating code, the MS Chart Control should be referred to your .NET program:

  • System.Windows.Forms.DataVisualization.Charting (for .NET WinForms project)
  • System.Web.UI.DataVisualization.Charting (for ASP.NET application)

Make and save Microsoft 2D Stacked Column Chart to PDF in C# code.
public static void InsertMSChartToPDF()
    // Create a new PDF document.
    PdfDocument document = new PdfDocument();

    // Create an empty page in this document.
    PdfPage page = document.AddPage();

    // Obtain an XGraphics object to render to
    XGraphics g = XGraphics.FromPdfPage(page);

    // Create stacked column chart stream object
    Stream chartStream = CreateMSStackedColumnChart();

    // Convert chart stream to XImage object
    XImage chartImage = XImage.FromStream(chartStream);

    // Insert the chart image to pdf page in any position
    g.DrawImage(chartImage, 50, 50);

    // Save and show the document

public static Stream CreateMSStackedColumnChart()
    // Create ms chart object
    Chart chart = new Chart();

    ChartArea chartArea = new ChartArea();
    Series series1 = new Series();
    Series series2 = new Series();
    Series series3 = new Series();

    // Input Data Point
    DataPoint dataPoint1 = new DataPoint(0, 5);
    DataPoint dataPoint2 = new DataPoint(0, 8.5);
    DataPoint dataPoint3 = new DataPoint(0, 9);
    DataPoint dataPoint4 = new DataPoint(0, 7);
    DataPoint dataPoint5 = new DataPoint(0, 5);
    DataPoint dataPoint6 = new DataPoint(0, 5);
    DataPoint dataPoint7 = new DataPoint(0, 4);
    DataPoint dataPoint8 = new DataPoint(0, 5);
    DataPoint dataPoint9 = new DataPoint(0, 3.5);
    DataPoint dataPoint10 = new DataPoint(0, 4);
    DataPoint dataPoint11 = new DataPoint(0, 3);
    DataPoint dataPoint12 = new DataPoint(0, 7);
    DataPoint dataPoint13 = new DataPoint(0, 2);
    DataPoint dataPoint14 = new DataPoint(0, 4);
    DataPoint dataPoint15 = new DataPoint(0, 8);

    // Set series1 with data, color, chart type and name
    series1.BorderColor = Color.FromArgb(180, 26, 59, 105);
    series1.ChartType = SeriesChartType.StackedColumn;
    series1.Color = Color.FromArgb(220, 65, 140, 240);
    series1.Name = "Series1";

    // Set series2 with data, color, chart type and name
    series2.BorderColor = Color.FromArgb(180, 26, 59, 105);
    series2.ChartType = SeriesChartType.StackedColumn;
    series2.Color = Color.FromArgb(220, 252, 180, 65);
    series2.Name = "Series2";

    // Set series3 with data, color, chart type and name
    series3.BorderColor = Color.FromArgb(180, 26, 59, 105);
    series3.ChartType = SeriesChartType.StackedColumn;
    series3.Color = Color.FromArgb(220, 224, 64, 10);
    series3.Name = "Series3";

    // Bind series data to chart

    // Set chart 3D style
    chartArea.Area3DStyle.Enable3D = false;

    // Bind chart area to chart object

    // Modify chart size
    chart.Size = new Size(400, 300);

    // Render chart graphics to stream
    MemoryStream ms = new MemoryStream();
    chart.SaveImage(ms, ChartImageFormat.Png);

    return ms;
Render and draw MS 3D Stacked Column Chart to PDF in C# code.

All the step and code are the same as above, only need change one line code chartArea.Area3DStyle.Enable3D = false; in the "CreateMSStackedColumnChart()" to the C# code below.

chartArea.Area3DStyle.Enable3D = true;
chartArea.Area3DStyle.Inclination = 15;
chartArea.Area3DStyle.IsRightAngleAxes = false;
chartArea.Area3DStyle.Perspective = 10;
chartArea.Area3DStyle.Rotation = 10;
chartArea.BackColor = Color.WhiteSmoke;            

More MS Chart to PDF tutorial