Make Pie Chart to PDF Sample
insert pie chart to pdf in c# .net

C# code tutorial

PDF Chart PDF Creating & Inserting PDF to Image PDF Digital Signature PDF Extracting PDF Processing & Editing PDF Protecting PDF Barcode

Popular .NET SDK


A pie chart is a circular graph that shows the relative contribution with different categories. A wedge of the circle represents each category's value, which caused a pie graph to be cut into different sized slices.

Pie chart can communicate information and data visually, so that reader can make a better viewer by the data trend. C# PDF pie chart maker provide easiest chart builder and designer for developers. PDF chart color, title, legend, gridline, location and style can all be modified in programing and development.

In the following online demo, developer can draw and add a pie chart to pdf page using .NET PDF chart maker library.


static void AddPieChartToPDF()
{
    // Create a new PDF document.
    PdfDocument document = new PdfDocument();

    // Create a page.
    PdfPage page = document.AddPage();

    // Generate a 2d pie chart graph
    Chart chart = PieChart();

    // Create a chart frame, set chart location and size
    ChartFrame chartFrame = new ChartFrame();
    chartFrame.Location = new XPoint(30, 30);
    chartFrame.Size = new XSize(500, 600);
    chartFrame.Add(chart);

    // Render chart symbols into pdf page
    XGraphics g = XGraphics.FromPdfPage(page);
    chartFrame.Draw(g);

    // Save and show the document           
    document.Save("PieChart.pdf");
    Process.Start("PieChart.pdf");
}

static Chart PieChart()
{
    // Set chart type to Pie2D
    Chart chart = new Chart(ChartType.Pie2D);

    // Add series data
    Series series = chart.SeriesCollection.AddSeries();
    series.Add(new double[] { 1, 5, 11, 3, 20 });
            
    // Add series legend
    XSeries xseries = chart.XValues.AddXSeries();
    xseries.Add("Series 1", "Series 2", "Series 3", "Series 4", "Series 5");
    chart.Legend.Docking = DockingType.Right;

    // Set label display type
    chart.DataLabel.Type = DataLabelType.Percent;

    // Set label location
    chart.DataLabel.Position = DataLabelPosition.Center;

    return chart;
}

More Excel tutorial