How do I add paths / vector graphics to PDF?

Q:

For a project I need to write path coordinates to a PDF. How do I add lines, paths, and other vector graphics to PDF?
Could you please provide me with some sample code?

A: Did you take a look at ElementBuilder sample project that comes as part of the SDK?

For example, something along the following lines:

PDFNet::Initialize();
{
    PDFDoc doc;  // could be a new of existing PDF doc

    // Create a blank page, then add some vector graphics to it.
    Page page = doc.PageCreate();
    doc.PagePushBack(page);

    ElementWriter writer;
    writer.Begin(page); 

    ElementBuilder eb;
    eb.PathBegin();

    eb.MoveTo(306, 396);
    eb.CurveTo(681, 771, 399.75, 864.75, 306, 771);
    eb.CurveTo(212.25, 864.75, -69, 771, 306, 396);
    eb.ClosePath();

    Element element = eb.PathEnd();
    element.SetPathFill(true);

    // Set the path color space and color
    GState gstate = element.GetGState();
    gstate.SetFillColorSpace(ColorSpace.CreateDeviceCMYK()); 
    gstate.SetFillColor(new ColorPt(1, 0, 0, 0));  // cyan
    gstate.SetTransform(0.5, 0, 0, 0.5, -20, 300);
    writer.WriteElement(element);
    writer.End(); 

    doc.Save("out.pdf", SDFDoc::e_linearized, 0);
}