• DR-IT Software
  • Products
  • Documentation
  • Product page
  • Examples
  • API reference
  • Support

Draw Shapes

Draws shapes and paths on a PDF page.

Code

using DRIT.Pdf;

using var doc = new PdfDocument();
var page = doc.Pages.Add(PdfPageSize.A4);
var content = page.Content;

// Draw a filled rectangle
content.FillRectangle(new PdfRect(100, 700, 200, 100), PdfColor.LightGray);

// Draw a stroked rectangle
content.DrawRectangle(new PdfRect(350, 700, 200, 100));

// Draw a path
var path = new PdfPathContent();
path.MoveTo(new PdfPoint(100, 500));
path.LineTo(new PdfPoint(200, 600));
path.LineTo(new PdfPoint(300, 500));
path.ClosePath();
content.DrawPath(path, PdfFillRule.EvenOddRule);

doc.Save("shapes.pdf");

Output

shapes.pdf

  • Improve this Doc
Back to top

DR-IT Software documentation

DR-IT Software · Products · Documentation index · Product page · Downloads · Support · Licensing

Generated by DocFX