Skip to content

PDFiumPageBuilder

@scaryterry/pdfium


Defined in: src/document/builder.ts:227

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.

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();

get disposed(): boolean

Defined in: src/core/disposable.ts:73

Whether this resource has been disposed.

boolean

Disposable.disposed

[dispose](): void

Defined in: src/core/disposable.ts:148

Dispose of this resource, freeing WASM memory.

This method is idempotent - calling it multiple times has no effect after the first call.

void

Disposable.[dispose]


addRectangle(x, y, w, h, style?): this

Defined in: src/document/builder.ts:252

Add a rectangle to the page.

ParameterTypeDescription
xnumberLeft position in points
ynumberBottom position in points
wnumberWidth in points
hnumberHeight in points
style?ShapeStyleFill and stroke style options

this

this for method chaining


addText(text, x, y, font, fontSize): this

Defined in: src/document/builder.ts:281

Add a text object to the page.

ParameterTypeDescription
textstringThe text content
xnumberX position in points
ynumberY position in points
fontPDFiumBuilderFontFont from builder.loadStandardFont()
fontSizenumberFont size in points

this

this for method chaining


dispose(): void

Defined in: src/core/disposable.ts:164

Alias for Symbol.dispose for explicit calls.

void

document.dispose();

Disposable.dispose