PDFiumPageBuilder
Defined in: src/document/builder.ts:232
Builder for adding content to a PDF page.
Obtained from PDFiumDocumentBuilder.addPage. Use method chaining to add shapes, text, and other page objects.
Content is generated automatically when the document is saved — there is
no need to call generateContent() on builder pages.
Example
Section titled “Example”using builder = pdfium.createDocument();const page = builder.addPage({ width: 595, height: 842 });const font = builder.loadStandardFont('Helvetica');page .addRectangle(50, 700, 200, 100, { fill: { r: 200, g: 220, b: 255, a: 255 } }) .addText('Hello, PDF!', 60, 750, font, 24);const bytes = builder.save();Extends
Section titled “Extends”Accessors
Section titled “Accessors”disposed
Section titled “disposed”Get Signature
Section titled “Get Signature”get disposed():
boolean
Defined in: src/core/disposable.ts:74
Whether this resource has been disposed.
Returns
Section titled “Returns”boolean
Inherited from
Section titled “Inherited from”Methods
Section titled “Methods”[dispose]()
Section titled “[dispose]()”[dispose]():
void
Defined in: src/core/disposable.ts:163
Dispose of this resource, freeing WASM memory.
This method is idempotent - calling it multiple times has no effect after the first call.
Returns
Section titled “Returns”void
Inherited from
Section titled “Inherited from”addEllipse()
Section titled “addEllipse()”addEllipse(
cx,cy,rx,ry,style?):this
Defined in: src/document/builder.ts:353
Add an ellipse (or circle) to the page, inscribed in the given bounding box.
Approximated with four cubic Bezier segments (standard technique).
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
cx | number | Centre X in points |
cy | number | Centre Y in points |
rx | number | Horizontal radius in points |
ry | number | Vertical radius in points |
style? | ShapeStyle | Fill and stroke style |
Returns
Section titled “Returns”this
this for method chaining
addLine()
Section titled “addLine()”addLine(
x1,y1,x2,y2,style?):this
Defined in: src/document/builder.ts:327
Add a straight line to the page.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
x1 | number | Start X in points |
y1 | number | Start Y in points |
x2 | number | End X in points |
y2 | number | End Y in points |
style? | ShapeStyle | Stroke style (fill is ignored for lines) |
Returns
Section titled “Returns”this
this for method chaining
addRectangle()
Section titled “addRectangle()”addRectangle(
x,y,w,h,style?):this
Defined in: src/document/builder.ts:257
Add a rectangle to the page.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
x | number | Left position in points |
y | number | Bottom position in points |
w | number | Width in points |
h | number | Height in points |
style? | ShapeStyle | Fill and stroke style options |
Returns
Section titled “Returns”this
this for method chaining
addText()
Section titled “addText()”addText(
text,x,y,font,fontSize,colour?):this
Defined in: src/document/builder.ts:287
Add a text object to the page.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
text | string | The text content |
x | number | X position in points |
y | number | Y position in points |
font | PDFiumBuilderFont | Font from builder.loadStandardFont() |
fontSize | number | Font size in points |
colour? | Colour | Optional text colour (defaults to black) |
Returns
Section titled “Returns”this
this for method chaining
dispose()
Section titled “dispose()”dispose():
void
Defined in: src/core/disposable.ts:179
Alias for Symbol.dispose for explicit calls.
Returns
Section titled “Returns”void
Example
Section titled “Example”document.dispose();