Vector Graphics
DynamicPDF Core Suite supports adding vector line art like lines, rectangles, circles, and paths to PDFs by providing the Line, Rectangle, Circle, and Path classes.
^^^
Figure 1. DynamicPDF Core Suite vector graphics.
^^^
Circle
Add circles to a PDF document using the Circle class. The following example illustrates.
Example
Document document = new Document();
Page page = new Page();
document.Pages.Add(page);
Circle circle1 = new Circle(100, 100, 50, 100, Grayscale.Black, RgbColor.LightBlue,
2, LineStyle.Solid);
Circle circle2 = new Circle(150, 75, 50, 50, Grayscale.Black, RgbColor.Lime,
2, LineStyle.Solid);
page.Elements.Add(circle1);
page.Elements.Add(circle2);
document.Draw("Output.pdf"));
Dim document As New Document()
Dim page As New Page()
document.Pages.Add(page)
Dim circle1 As New Circle(100, 100, 50, 100, Grayscale.Black, RgbColor.OrangeRed, 2, LineStyle.Solid)
page.Elements.Add(circle1)
document.Draw("Output.pdf")
[ShapesExample.cs](https://github.com/DynamicPDF/examples-dynamicpdf-core-suite-dotnet-core/blob/master/dynamicpdf-csharp-examples/Examples/ShapesExample.cs){#gitlink-id target=_blank}
[ShapesExample.vb](https://github.com/DynamicPDF/examples-dynamicpdf-core-suite-dotnet-core/blob/master/dynamicpdf-vbnet-examples/Examples/ShapesExample.vb){#gitlink-id target=_blank}
Rectangle
Add rectangles to a PDF document using the Rectangle class. The following example illustrates.
Example
Document document = new Document();
Page page = new Page();
document.Pages.Add(page);
Rectangle rectangle = new Rectangle(50, 50, 200, 200,
Grayscale.Black, RgbColor.Gray, 4, LineStyle.Solid);
rectangle.CornerRadius = 10;
page.Elements.Add(rectangle);
document.Draw("Output.pdf");
Dim document As New Document()
Dim page As New Page()
document.Pages.Add(page)
Dim rectangle As New Rectangle(10, 10, 400, 300, RgbColor.Red, RgbColor.Navy)
page.Elements.Add(rectangle)
document.Draw("Output.pdf")
[ShapesExample.cs](https://github.com/DynamicPDF/examples-dynamicpdf-core-suite-dotnet-core/blob/master/dynamicpdf-csharp-examples/Examples/ShapesExample.cs){#gitlink-id target=_blank}
[ShapesExample.vb](https://github.com/DynamicPDF/examples-dynamicpdf-core-suite-dotnet-core/blob/master/dynamicpdf-vbnet-examples/Examples/ShapesExample.vb){#gitlink-id target=_blank}
Line
Add lines to a PDF document using the Line class. The following example illustrates.
Example
Document document = new Document();
Page page = new Page();
document.Pages.Add(page);
Line line = new Line(50, 50, 50, 400, 5, Grayscale.Black,
LineStyle.Solid);
line.Cap = LineCap.Round;
page.Elements.Add(line);
page.Elements.Add(new Line(60, 50, 150, 400, 2,
RgbColor.Blue, LineStyle.DashLarge));
document.Draw("Output.pdf");
Dim document As New Document()
Dim page As New Page()
document.Pages.Add(page)
Dim line As New Line(150, 0, 150, 300)
line.Color = RgbColor.Navy
line.Width = 10
line.Cap = LineCap.Butt
page.Elements.Add(line)
document.Draw("Output.pdf")
[ShapesExample.cs](https://github.com/DynamicPDF/examples-dynamicpdf-core-suite-dotnet-core/blob/master/dynamicpdf-csharp-examples/Examples/ShapesExample.cs){#gitlink-id target=_blank}
[ShapesExample.vb](https://github.com/DynamicPDF/examples-dynamicpdf-core-suite-dotnet-core/blob/master/dynamicpdf-vbnet-examples/Examples/ShapesExample.vb){#gitlink-id target=_blank}
Path
A path contains one or more straight or curved line segments drawn on a page or template. Core Suite supports paths through the Path class. A Path has numerous properties, including ClosePath, FillCollor, LineJoin, SubPaths, and numerous others. You draw a path by adding several sub-paths to a Path instance's SubPath collection.
Example
Document document = new Document();
Page page = new Page();
document.Pages.Add(page);
Path path = new Path(50, 150, RgbColor.DarkRed, RgbColor.LimeGreen,
3, LineStyle.Solid, true);
path.SubPaths.Add(new CurveSubPath(50, 400, 300, 150, -200, 400));
path.SubPaths.Add(new LineSubPath(330, 450));
path.SubPaths.Add(new CurveToSubPath(300, 120, 50, 300));
path.SubPaths.Add(new CurveFromSubPath(150, 130, 200, -100));
page.Elements.Add(path);
document.Draw("Output.pdf");
Dim document As New Document()
Dim page As New Page()
document.Pages.Add(page)
Dim path As New Path(50, 150, RgbColor.Blue, RgbColor.Yellow, 3, LineStyle.Solid, True)
path.SubPaths.Add(New CurveSubPath(50, 400, 300, 150, -200, 400))
path.SubPaths.Add(New LineSubPath(300, 400))
path.SubPaths.Add(New CurveToSubPath(300, 150, 50, 300))
path.SubPaths.Add(New CurveFromSubPath(150, 100, 200, -100))
page.Elements.Add(path)
document.Draw("Output.pdf")
[ShapesExample.cs](https://github.com/DynamicPDF/examples-dynamicpdf-core-suite-dotnet-core/blob/master/dynamicpdf-csharp-examples/Examples/ShapesExample.cs){#gitlink-id target=_blank}
[ShapesExample.vb](https://github.com/DynamicPDF/examples-dynamicpdf-core-suite-dotnet-core/blob/master/dynamicpdf-vbnet-examples/Examples/ShapesExample.vb){#gitlink-id target=_blank}