Draw PDF circle shapes in C++
Contents
[
Hide
]
Draw an outlined circle
- Create a Document and add a page.
- Create a 400-by-200 Graph with a green border.
- Create a Circle centered at (100, 100) with radius 40.
- Set its stroke color to GreenYellow and add it to Shapes.
- Add the Graph to the page paragraphs.
- Save the PDF with Save().
#include <Aspose.PDF.Cpp/Color.h>
#include <Aspose.PDF.Cpp/Document.h>
#include <Aspose.PDF.Cpp/Generator/BorderInfo.h>
#include <Aspose.PDF.Cpp/Generator/BorderSide.h>
#include <Aspose.PDF.Cpp/Generator/BoundsCheckableList/BoundsCheckableList.h>
#include <Aspose.PDF.Cpp/Generator/Drawing/Circle.h>
#include <Aspose.PDF.Cpp/Generator/Drawing/Graph.h>
#include <Aspose.PDF.Cpp/Generator/GraphInfo.h>
#include <Aspose.PDF.Cpp/Generator/Paragraphs.h>
#include <Aspose.PDF.Cpp/Page.h>
#include <Aspose.PDF.Cpp/PageCollection.h>
using namespace System;
using namespace Aspose::Pdf;
using namespace Aspose::Pdf::Drawing;
void GraphExamples::AddCircle(String outputFile)
{
auto document = MakeObject<Document>();
auto page = document->get_Pages()->Add();
auto graph = MakeObject<Graph>(400.0, 200.0);
graph->set_Border(MakeObject<BorderInfo>(BorderSide::All, Color::get_Green()));
auto circle = MakeObject<Circle>(100, 100, 40);
circle->get_GraphInfo()->set_Color(Color::get_GreenYellow());
graph->get_Shapes()->Add(circle);
page->get_Paragraphs()->Add(graph);
document->Save(outputFile);
}
Draw a filled circle with text
- Create a Document and add a page.
- Create a 400-by-200 Graph with a green border.
- Create a Circle and configure its stroke and fill through GraphInfo.
- Assign a TextFragment containing Circle to the shape.
- Add the circle to Shapes.
- Add the Graph to the page paragraphs.
- Save the PDF with Save().
#include <Aspose.PDF.Cpp/Color.h>
#include <Aspose.PDF.Cpp/Document.h>
#include <Aspose.PDF.Cpp/Generator/BorderInfo.h>
#include <Aspose.PDF.Cpp/Generator/BorderSide.h>
#include <Aspose.PDF.Cpp/Generator/BoundsCheckableList/BoundsCheckableList.h>
#include <Aspose.PDF.Cpp/Generator/Drawing/Circle.h>
#include <Aspose.PDF.Cpp/Generator/Drawing/Graph.h>
#include <Aspose.PDF.Cpp/Generator/GraphInfo.h>
#include <Aspose.PDF.Cpp/Generator/Paragraphs.h>
#include <Aspose.PDF.Cpp/Page.h>
#include <Aspose.PDF.Cpp/PageCollection.h>
#include <Aspose.PDF.Cpp/Text/TextFragment.h>
using namespace System;
using namespace Aspose::Pdf;
using namespace Aspose::Pdf::Drawing;
using namespace Aspose::Pdf::Text;
// Port of GraphsCircleExamples.addCircleFilled.
void GraphExamples::AddCircleFilled(String outputFile)
{
auto document = MakeObject<Document>();
auto page = document->get_Pages()->Add();
auto graph = MakeObject<Graph>(400.0, 200.0);
graph->set_Border(MakeObject<BorderInfo>(BorderSide::All, Color::get_Green()));
auto circle = MakeObject<Circle>(100, 100, 40);
circle->get_GraphInfo()->set_Color(Color::get_GreenYellow());
circle->get_GraphInfo()->set_FillColor(Color::get_Green());
circle->set_Text(MakeObject<TextFragment>(u"Circle"));
graph->get_Shapes()->Add(circle);
page->get_Paragraphs()->Add(graph);
document->Save(outputFile);
}