Skip to content

Surface

What a page is drawn with. Methods that set state return the surface, so calls chain; invalid geometry is reported by Page.finish (invalid-geometry).

artifact(kind, draw): this

Draws what draw draws as an artifact: decoration, running heads and footers, backgrounds; content outside the structure tree.

"layout" | "page" | "pagination" | "background"

(s) => void

this


blendMode(mode): this

The blend mode.

BlendMode

this


fillColor(color): this

The colour fills (and text) use.

Color

this


image(image, rect, alt?): this

Draws image scaled into rect; with alt, as a Figure structure element with that alternate text.

Image

Rect

string

this


link(rect, target, contents?): this

A link annotation over rect, with contents as its alternate text.

Rect

LinkTargetInit

string

this


opacity(fill, stroke): this

Fill and stroke opacity, 0 to 1.

number

number

this


path(build): PendingPath

A path, built by build, to paint.

(p) => void

PendingPath

surface.path((p) => p.moveTo(56, 590).lineTo(539, 590)).stroke({ width: 0.5 });

restore(): this

Restores the graphics state (Q).

this


save(): this

Saves the graphics state (q).

this


strokeColor(color): this

The colour strokes use.

Color

this


tag(tag, draw): this

Draws what draw draws inside the structure element tag: its text, paths and images become the element’s content, elements opened inside it its children, links its Link children, in reading order. Elements and artifacts draw leaves open end with it, also when it throws. A page using an element makes the document tagged.

Tag

(s) => void

this

s.tag("Sect", (s) => {
s.text("Results", { font, size: 18, at: [56, 96], tag: "H1" });
s.tag({ type: "P", lang: "en-GB" }, (s) => s.textBox(summary, { font, size: 11, box }));
});

LaminaError invalid-argument for an unknown type without a role.


text(text, options): TextRunJs

Draws text: shaped, bidi-resolved, one line per line break (needs the text module).

string

TextOptions

TextRunJs

what the run measures.

LaminaError text-module-not-loaded, missing-glyph, font-not-shapable, …


textBox(text, options): TextLayoutJs

Lays text out in options.box, breaking lines at Unicode line-break opportunities.

string

TextBoxOptions

TextLayoutJs

the lines drawn and where the overflow starts (UTF-16 offsets).

LaminaError as Surface.text; text-overflow with overflow: "error".


transform(matrix): this

Applies matrix (page space) to what is drawn next. See Matrix.

Transform

this