How do I create a custom shape on a transparent page background?

Q: Hi, I need to create a PDF document which has a custom shape in the
form of an octagon. The standard PDF is always rectangular with a
white opaque background. Using your tools is there any way to create a
PDF with a transparent background that will allow me to insert my own
custom shape?
A: You can create an octagon using ElementBuilder object. As a
starting point you may want to take a look at ElementBuilder sample
project (
For example,

ElementBuilder builder = new ElementBuilder();
ElementWriter writer = new ElementWriter();
page = doc.PageCreate();

Element element = builder.PathBegin(); // start building a path
// Build a path representing the octagon...
builder.MoveTo(100, 20);
builder.LineTo(200, 20);
builder.LineTo(500, 40);
... 6 more calls to LineTo
element = eb.PathEnd();

element.GetGState().SetStrokeColor(new ColorPt(1, 0, 0)); // Red

// Set stroke width.


Although most PDF viewers, render the page as solid white rectangle,
it is only an assumption. Using PDFNet you can render the page using
transparent background instead of solid white using
pdfdraw.SetPageTransparent(true). For example:

PDFDraw pdfdraw = new PDFDraw();
pdfdraw.Export(page, "my.png");