Analyzing your prompt, please hold on...
An error occurred while retrieving the results. Please refresh the page and try again.
The following code snippet also work with Aspose.PDF.Drawing library.
Like bar graphs, circle graphs can be used to display data in a number of separate categories. Unlike bar graphs, however, circle graphs can be used only when you have data for all the categories that make up the whole. So let’s take a look at adding a Circle object with Aspose.PDF for .NET.
Follow the steps below:
// For complete examples and data files, visit https://github.com/aspose-pdf/Aspose.PDF-for-.NET
private static void Circle()
{
// The path to the document directory
var dataDir = RunExamples.GetDataDir_AsposePdf_Images();
// Create PDF document
using (var document = new Aspose.Pdf.Document())
{
// Add page
var page = document.Pages.Add();
// Create Drawing object with certain dimensions
var graph = new Aspose.Pdf.Drawing.Graph(400, 200);
// Set border for Drawing object
var borderInfo = new Aspose.Pdf.BorderInfo(Aspose.Pdf.BorderSide.All, Aspose.Pdf.Color.Green);
graph.Border = borderInfo;
// Create a circle with the specified coordinates and radius
var circle = new Aspose.Pdf.Drawing.Circle(100, 100, 40);
// Set the circle's color
circle.GraphInfo.Color = Aspose.Pdf.Color.GreenYellow;
// Add the circle to the graph shapes
graph.Shapes.Add(circle);
// Add Graph object to paragraphs collection of page
page.Paragraphs.Add(graph);
// Save PDF document
document.Save(dataDir + "DrawingCircle1_out.pdf");
}
}
Our drawn circle will look like this:
This example shows how to add a Circle object that is filled with color.
// For complete examples and data files, visit https://github.com/aspose-pdf/Aspose.PDF-for-.NET
private static void CircleFilled()
{
// The path to the document directory
var dataDir = RunExamples.GetDataDir_AsposePdf_Images();
// Create PDF document
using (var document = new Aspose.Pdf.Document())
{
// Add page
var page = document.Pages.Add();
// Create Drawing object with certain dimensions
var graph = new Aspose.Pdf.Drawing.Graph(400, 200);
// Set border for Drawing object
var borderInfo = new Aspose.Pdf.BorderInfo(Aspose.Pdf.BorderSide.All, Aspose.Pdf.Color.Green);
graph.Border = borderInfo;
// Create a filled circle
var circle = new Aspose.Pdf.Drawing.Circle(100, 100, 40)
{
GraphInfo =
{
Color = Aspose.Pdf.Color.GreenYellow,
FillColor = Aspose.Pdf.Color.Green
},
Text = new Aspose.Pdf.Text.TextFragment("Circle")
};
// Add the circle to the graph shapes
graph.Shapes.Add(circle);
// Add Graph object to paragraphs collection of page
page.Paragraphs.Add(graph);
// Save PDF document
document.Save(dataDir + "DrawingCircle2_out.pdf");
}
}
Let’s see the result of adding a filled Circle:
Analyzing your prompt, please hold on...
An error occurred while retrieving the results. Please refresh the page and try again.