Examples

Adding Shapes to PDFs

Adding basic shapes such as circles, rectangles, lines and paths to a PDF document is straightforward using DynamicPDF Core Suite for .NET. The following C# examples illustrate.

Watch the Video

How to Add Circle to PDF

The following steps and C# sample code illustrate adding a Circle to a PDF document using DynamicPDF Core Suite for .NET.


Steps for Adding a Circle to a PDF Document


  1. Create a Document object.
  2. Create a Page object and add it to the Document instance.
  3. Create a Circle object by specifying the parameters.
  4. Add the Circle instance to the Page instance.
  5. Add the Document object's Draw method to draw and save the PDF document.

Sample Code - C#


Document document = new Document();
Page page = new Page();
document.Pages.Add( page );
Circle circle1 = new Circle(100, 100, 50, 100, Grayscale.Black, RgbColor.OrangeRed, 2, LineStyle.Solid);
page.Elements.Add(circle1);
document.Draw("Output.pdf");

PDF with an added circle.


How to Add Rectangle to PDF

The following steps and C# sample code illustrate adding a Rectangle to a PDF document using DynamicPDF Core Suite for .NET.


Steps for Adding a Rectangle to a PDF Document


  1. Create a Document object.
  2. Create a Page object and add it to the Document instance.
  3. Create a Rectangle object by specifying the parameters.
  4. Add the Rectangle instance to the Page instance.
  5. Add the Document object's Draw method to draw and save the PDF document.

Sample Code - C#


Document document = new Document();
Page page = new Page();
document.Pages.Add(page);
Rectangle rectangle = new Rectangle(10, 10, 400, 300, RgbColor.Red, RgbColor.Navy);
page.Elements.Add(rectangle);
document.Draw("Output.pdf");


PDf with an added rectangle.


How to Add Line to PDF

The following steps and C# sample code illustrate adding a Line to a PDF document using DynamicPDF Core Suite for .NET.


Steps for Adding a Circle to a PDF Document


  1. Create a Document object.
  2. Create a Page object and add it to the Document instance.
  3. Create a Line object by specifying the parameters.
  4. Add the Line instance to the Page instance.
  5. Add the Document object's Draw method to draw and save the PDF document.

Sample Code - C#


Document document = new();
Page page = new Page();
document.Pages.Add(page);
Line line = new(150, 0, 150, 300);
line.Color = RgbColor.Navy;
line.Width = 10;
line.Cap = LineCap.Butt;
page.Elements.Add(line);
document.Draw("Output.pdf");

PDF with an added line.


How to Add Path to PDF

The following steps and C# sample code illustrates adding a Path to a PDF document using DynamicPDF Core Suite for .NET.


Steps for Adding Path to a PDF Document


  1. Create a Document object.
  2. Create a Page object and add it to the Document instance.
  3. Create a Path object by specifying the parameters.
  4. Add four sub-paths to the Path instance (CurveSubPath, LineSubPath, CurveToSubPath and CurveFromSubPath).
  5. Add the Path instance to the Page instance.
  6. Add the Document object's Draw method to draw and save the PDF document.

Sample Code - C#


Document document = new Document();       
Page page = new Page();
document.Pages.Add( page );      
Path path = 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");


PDF with an added shape created using Path class.

GitHub Project

An example project is available on GitHub (examples.dynamicpdf-core-suite-dotnet-core). Examples are provided in C# and VB.NET. Clone or view the example project at GitHub. This specific example discussed on this page are all contained in following classes on GitHub


Clone or View Example Project on GitHub

Getting Started

Get started easily by installing DynamicPDF Core Suite for .NET through NuGet or manually. Then, refer to the documentation for more information on using and purchasing the product.


NuGet Package


The easiest way to install DynamicPDF Core Suite is by obtaining the NuGet package using Visual Studio's Package Manager. You can also obtain the NuGet package by downloading it directly. Refer to the installation documentation for more information.

NuGet Package ID: ceTe.DynamicPDF.CoreSuite.NET

DynamicPDF Core Suite Information


DynamicPDF Core Suite for .NET combines creating, merging, and visual report creation into one powerful product for creating PDF documents. It is ideal for anyone who needs to generate PDF documents or reports or work with existing PDFs in their applications. With a free Evaluation Edition to try and with flexible and royalty-free licensing options, why not start using DynamicPDF Core Suite for .NET today!



More Information on Shapes

Available on Other Platforms

DynamicPDF Core Suite is also available for the Java and COM/ActiveX platforms. Refer to the respective product pages for more details.


Why Choose DynamicPDF?

  • Transparent Pricing
  • Lots of Features
  • Easy to Use
  • Great Support
  • Efficient Performance
  • Product Maturity (Over 22 Years)
  • Free Evaluation
  • .NET Core Support (Most Products)
  • Flexible Licensing

We’re Not The Only Ones That Think We’re Great!