Analyzing your prompt, please hold on...
An error occurred while retrieving the results. Please refresh the page and try again.
以下代码片段也适用于Aspose.PDF.Drawing库。
与条形图一样,圆形图可以用于显示多个单独类别的数据。然而,与条形图不同的是,圆形图只能在您拥有构成整体的所有类别的数据时使用。因此,让我们来看看如何使用Aspose.PDF for .NET添加一个Circle对象。
请按照以下步骤操作:
// 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");
}
}
我们绘制的圆形将如下所示:
此示例演示如何添加一个填充颜色的圆形对象。
// 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");
}
}
让我们看看添加填充圆形的结果:
Analyzing your prompt, please hold on...
An error occurred while retrieving the results. Please refresh the page and try again.