How to Start Convert PDF Read PDF Build PDF Work with PDF Modules PDF Document PDF Pages Text Image Graph & Path Annotation, Markup & Drawing Redaction Security Digital Signature Forms Watermark Bookmark Link File Attachment File Metadata Printing Work with Other SDKs Barcode read Barcode create OCR Twain

Using C# PDF SDK
C# PDF Builder: How to draw, add a start shape to PDF file


C# Demo Code to create, draw, add a start graph to pdf document













Draw a start on PDF context


...
PDFContext ctx = new PDFContext();
//  set figure size: width 600 pixels; height 200 pixels
ctx.SetWidth(new RELength(600, Units.PX));
ctx.SetHeight(new RELength(200, Units.PX));
//  draw a star
REPath path = new REPath();
path.AddLine(100, 70, 300, 70);
path.AddLine(300, 70, 130, 170);
path.AddLine(130, 170, 200, 10);
path.AddLine(200, 10, 270, 170);
path.AddLine(270, 170, 100, 70);
path.CloseAllPath();
ctx.DrawPath(new REPen(new REColor(255, 0, 0), 5F), path);
Figure figure = new Figure(ctx);
...




Add context to PDF document


String outputFilePath = Program.RootPath + "\\" + "Sample25.pdf";

Document document = new Document();
PDFBuildHandler.Create(document, outputFilePath);
//  open document
document.Open();
//  create Figure
PDFContext ctx = new PDFContext();
...
...
Figure figure = new Figure(ctx);
document.Add(figure);
//  close document and save to the output file
document.Close();


Let's see the result of adding a start on PDF using C#: