Skip to main content

Class: PdfStructureContainer

A builder for grouping tagged PDF content under a shared structure element. It can add text, blocks, lists, tables, images, and nested sections to the same semantic container.

Constructors

Constructor

new PdfStructureContainer(
page,
embeddedFonts,
node,
fontFamilies?,
textDefaults?): PdfStructureContainer;

Creates a structure container bound to a page, embedded fonts, and parent structure node.

Parameters

ParameterTypeDescription
pageInternalPageModelThe internal page model to write into.
embeddedFontsReadonlyMap<string, ParsedTrueTypeFont>The embedded font registry used for text layout.
nodeInternalStructureNodeThe parent structure node for tagged content.
fontFamiliesReadonlyMap<string, FontFamilyFaces>Font families registered with the document.
textDefaults?TextDefaultsDocument-wide text defaults.

Returns

PdfStructureContainer

Methods

bmp()

bmp(data, options): this;

Adds a tagged BMP image to this structure container.

Parameters

ParameterTypeDescription
dataBinaryDataThe binary image or font data.
optionsBmpImageOptionsOptions that control the operation.

Returns

this


circle()

circle(
cx,
cy,
radius,
style?): this;

Draws a circle. See PdfPage.circle.

Parameters

ParameterType
cxnumber
cynumber
radiusnumber
style?ShapeStyle

Returns

this


container()

Creates a nested tagged structure container.

Param

The structure tag to create.

Param

Either structure options or a build callback.

Param

An optional build callback when options are provided separately.

Call Signature

container(tag, build?): PdfStructureContainer;

Creates a nested tagged structure container.

Parameters
ParameterTypeDescription
tagPdfContainerTagThe structure tag to create.
build?(container) => voidAn optional callback that receives the created container.
Returns

PdfStructureContainer

The created structure container.

Call Signature

container(
tag,
options?,
build?): PdfStructureContainer;

Creates a nested tagged structure container.

Parameters
ParameterTypeDescription
tagPdfContainerTagThe structure tag to create.
options?PdfStructureOptionsOptions that control the operation.
build?(container) => voidAn optional callback that receives the created container.
Returns

PdfStructureContainer

The created structure container.


ellipse()

ellipse(
cx,
cy,
rx,
ry,
style?): this;

Draws an ellipse. See PdfPage.ellipse.

Parameters

ParameterType
cxnumber
cynumber
rxnumber
rynumber
style?ShapeStyle

Returns

this


flow()

flow(options?): PdfFlow;

Creates a flow helper that writes into this structure container.

Parameters

ParameterTypeDescription
optionsFlowOptionsOptions that control the operation.

Returns

PdfFlow

The created flow helper.


gif()

gif(data, options): this;

Adds a tagged GIF image to this structure container.

Parameters

ParameterTypeDescription
dataBinaryDataThe binary image or font data.
optionsGifImageOptionsOptions that control the operation.

Returns

this


image()

image(data, options): this;

Adds a raster image (auto-detecting the format) tagged under this container.

Parameters

ParameterTypeDescription
dataBinaryDataThe image bytes.
optionsJpegImageOptionsPlacement and tagging options.

Returns

this


jbig2()

jbig2(data, options): this;

Adds a tagged JBIG2 image to this structure container.

Parameters

ParameterTypeDescription
dataBinaryDataThe binary image or font data.
optionsJbig2ImageOptionsOptions that control the operation.

Returns

this


jp2()

jp2(data, options): this;

Adds a tagged JPEG 2000 image to this structure container.

Parameters

ParameterTypeDescription
dataBinaryDataThe binary image or font data.
optionsJp2ImageOptionsOptions that control the operation.

Returns

this


jpeg()

jpeg(data, options): this;

Adds a tagged JPEG image to this structure container.

Parameters

ParameterTypeDescription
dataBinaryDataThe binary image or font data.
optionsJpegImageOptionsOptions that control the operation.

Returns

this


line()

line(
x1,
y1,
x2,
y2,
style?): this;

Draws a straight line between two points. See PdfPage.line.

Parameters

ParameterType
x1number
y1number
x2number
y2number
style?ShapeStyle

Returns

this


link(url, options): this;

Adds a tagged URI link annotation to this structure container.

Parameters

ParameterTypeDescription
urlstringThe URI target.
optionsUriLinkOptionsOptions that control the operation.

Returns

this


list()

list(items, options): this;

Adds a tagged list to this structure container.

Parameters

ParameterTypeDescription
itemsreadonly ListItem[]The list items to add.
optionsListOptionsOptions that control the operation.

Returns

this


path()

path(commands, style): this;

Adds vector path commands. Mirrors PdfPage.path.

Parameters

ParameterType
commandsPathCommand[]
stylePathStyle

Returns

this


png()

png(data, options): this;

Adds a tagged PNG image to this structure container.

Parameters

ParameterTypeDescription
dataBinaryDataThe binary image or font data.
optionsPngImageOptionsOptions that control the operation.

Returns

this


rect()

rect(
x,
y,
width,
height,
style?): this;

Draws a rectangle. See PdfPage.rect.

Parameters

ParameterType
xnumber
ynumber
widthnumber
heightnumber
style?ShapeStyle

Returns

this


structure()

Creates a nested tagged structure container.

Param

The replacement structure role.

Param

Either structure options or a build callback.

Param

An optional build callback when options are provided separately.

Call Signature

structure(role, build?): PdfStructureContainer;

Creates a nested tagged structure container.

Parameters
ParameterTypeDescription
role| string & object | PdfStandardStructureTagThe replacement structure role.
build?(container) => voidAn optional callback that receives the created container.
Returns

PdfStructureContainer

The created structure container.

Call Signature

structure(
role,
options?,
build?): PdfStructureContainer;

Creates a nested tagged structure container.

Parameters
ParameterTypeDescription
role| string & object | PdfStandardStructureTagThe replacement structure role.
options?PdfStructureOptionsOptions that control the operation.
build?(container) => voidAn optional callback that receives the created container.
Returns

PdfStructureContainer

The created structure container.


svg()

svg(data, options): this;

Adds a tagged SVG graphic to this structure container.

Parameters

ParameterTypeDescription
datastring | BinaryDataThe SVG text data.
optionsSvgImageOptionsOptions that control the operation.

Returns

this


table()

table(rows, options): this;

Adds a tagged table to this structure container.

Parameters

ParameterTypeDescription
rowsreadonly TableRow[]The table rows to add.
optionsTableOptionsOptions that control the operation.

Returns

this


text()

text(text, options): this;

Adds tagged text to this structure container.

Parameters

ParameterTypeDescription
textstringThe text to add.
optionsTextOptionsOptions that control the operation.

Returns

this


textBlock()

textBlock(text, options): this;

Adds a tagged multiline text block to this structure container.

Parameters

ParameterTypeDescription
textstringThe text to add.
optionsTextBlockOptionsOptions that control the operation.

Returns

this


tiff()

tiff(data, options): this;

Adds a tagged TIFF image to this structure container.

Parameters

ParameterTypeDescription
dataBinaryDataThe binary image or font data.
optionsTiffImageOptionsOptions that control the operation.

Returns

this


webp()

webp(data, options): this;

Adds a tagged WebP image to this structure container.

Parameters

ParameterTypeDescription
dataBinaryDataThe binary image or font data.
optionsWebpImageOptionsOptions that control the operation.

Returns

this