Skip to content
ComPDF
DemoSampleAPI ReferenceFAQ
New Release

Open-Source PDF SDK & AI Document Processing

Get the full self-hosted SDK and AI document processing on GitHub. One-click deploy to quickly build your document workflows.

Positioning

Relative Positioning (Default)

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

java
CDiv div1 = page.createDivElement();
div1.createTextElement("First div");

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

Absolute Positioning

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

// Or use percentage width
div.setAbsolutePosition(
    100,
    200,
    CUnitValue.CreatePercentValue(50)
);