Skip to content
ComPDF

Positioning

Relative Positioning (Default)

Elements are arranged according to normal document flow, which is the default behavior.

csharp
CDiv div1 = page.CreateDiv();
div1.CreateText("First div");

CDiv div2 = page.CreateDiv();
div2.CreateText("Second div"); // Will appear below div1

Absolute Positioning

csharp
// Create absolutely positioned element
CDiv div = page.CreateDiv();
div.SetAbsolutePosition(
    left: 100,    // 100 points from page left edge
    bottom: 200,  // 200 points from page bottom edge
    width: 300    // Width 300 points
);

// Or use percentage width
div.SetAbsolutePosition(
    left: 100,
    bottom: 200,
    width: CUnitValue.CreatePercentValue(50)
);