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).
Methods
Section titled “Methods”artifact()
Section titled “artifact()”artifact(
kind,draw):this
Draws what draw draws as an artifact: decoration, running heads and footers, backgrounds;
content outside the structure tree.
Parameters
Section titled “Parameters”"layout" | "page" | "pagination" | "background"
(s) => void
Returns
Section titled “Returns”this
blendMode()
Section titled “blendMode()”blendMode(
mode):this
The blend mode.
Parameters
Section titled “Parameters”Returns
Section titled “Returns”this
fillColor()
Section titled “fillColor()”fillColor(
color):this
The colour fills (and text) use.
Parameters
Section titled “Parameters”Returns
Section titled “Returns”this
image()
Section titled “image()”image(
image,rect,alt?):this
Draws image scaled into rect; with alt, as a Figure structure element with that
alternate text.
Parameters
Section titled “Parameters”string
Returns
Section titled “Returns”this
link()
Section titled “link()”link(
rect,target,contents?):this
A link annotation over rect, with contents as its alternate text.
Parameters
Section titled “Parameters”target
Section titled “target”LinkTargetInit
contents?
Section titled “contents?”string
Returns
Section titled “Returns”this
opacity()
Section titled “opacity()”opacity(
fill,stroke):this
Fill and stroke opacity, 0 to 1.
Parameters
Section titled “Parameters”number
stroke
Section titled “stroke”number
Returns
Section titled “Returns”this
path()
Section titled “path()”path(
build):PendingPath
A path, built by build, to paint.
Parameters
Section titled “Parameters”(p) => void
Returns
Section titled “Returns”Example
Section titled “Example”surface.path((p) => p.moveTo(56, 590).lineTo(539, 590)).stroke({ width: 0.5 });restore()
Section titled “restore()”restore():
this
Restores the graphics state (Q).
Returns
Section titled “Returns”this
save()
Section titled “save()”save():
this
Saves the graphics state (q).
Returns
Section titled “Returns”this
strokeColor()
Section titled “strokeColor()”strokeColor(
color):this
The colour strokes use.
Parameters
Section titled “Parameters”Returns
Section titled “Returns”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.
Parameters
Section titled “Parameters”(s) => void
Returns
Section titled “Returns”this
Example
Section titled “Example”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 }));});Throws
Section titled “Throws”LaminaError invalid-argument for an unknown type without a role.
text()
Section titled “text()”text(
text,options):TextRunJs
Draws text: shaped, bidi-resolved, one line per line break (needs the text module).
Parameters
Section titled “Parameters”string
options
Section titled “options”Returns
Section titled “Returns”TextRunJs
what the run measures.
Throws
Section titled “Throws”LaminaError text-module-not-loaded, missing-glyph, font-not-shapable, …
textBox()
Section titled “textBox()”textBox(
text,options):TextLayoutJs
Lays text out in options.box, breaking lines at Unicode line-break opportunities.
Parameters
Section titled “Parameters”string
options
Section titled “options”Returns
Section titled “Returns”TextLayoutJs
the lines drawn and where the overflow starts (UTF-16 offsets).
Throws
Section titled “Throws”LaminaError as Surface.text; text-overflow with overflow: "error".
transform()
Section titled “transform()”transform(
matrix):this
Applies matrix (page space) to what is drawn next. See Matrix.
Parameters
Section titled “Parameters”matrix
Section titled “matrix”Returns
Section titled “Returns”this