Skip to main content

@paprize/core

ReportBuilder​

Defined in: report/ReportBuilder.ts:54

The report builder class that contains the logic for handling pagination and managing the report layout.

Accessors​

monitor​

Get Signature​

get monitor(): Monitor<ReportBuilderEvents>

Defined in: report/ReportBuilder.ts:79

Monitor instance used to subscribe to pagination events. See ReportBuilderEvents for available event types.

Returns​

Monitor<ReportBuilderEvents>

Methods​

getJsonData()​

getJsonData<T>(defaultData?): Promise<T | null>

Defined in: report/ReportBuilder.ts:195

Retrieves JSON data injected by @paprize/puppeteer during server-side rendering (SSR).

If no injected data is available, the function returns the provided defaultData, or null if none is given.

⚠️ Important Notes:

  • This function is not type-safe — it performs no runtime type validation on the returned data.
  • It is available only during server-side rendering when using @paprize/puppeteer.
  • When used in client-side rendering or development mode, you should provide a defaultData value for testing purposes.
Type Parameters​
Type ParameterDescription
TThe expected type of the injected JSON data.
Parameters​
ParameterTypeDescription
defaultData?TOptional fallback value to return if no injected data is found.
Returns​

Promise<T | null>

A promise resolving to the injected JSON data if available, otherwise the provided default value or null.

removeSection()​

removeSection(sectionId): void

Defined in: report/ReportBuilder.ts:86

Removes a section from the registered sections, if it has already been registered in the report.

Parameters​
ParameterType
sectionIdstring
Returns​

void

schedulePagination()​

schedulePagination(): Promise<ScheduleResult>

Defined in: report/ReportBuilder.ts:152

Schedules a pagination operation.

It is not possible to schedule multiple pagination operations in parallel, as the process involves DOM manipulation, and concurrent modifications could cause conflicts and unexpected results. Each newly scheduled operation is queued and executed sequentially. When a new pagination is scheduled, any ongoing or pending operations will be aborted, and the new pagination will start immediately afterward.

Returns​

Promise<ScheduleResult>

A promise that resolves when the first pagination cycle is completed. It does not wait for suspended sections to resolve and be paginated. To wait for all sections to complete pagination, use the suspension property of the returned result object.

tryAddSection()​

tryAddSection(options, components, onPaginationCompleted): Promise<boolean>

Defined in: report/ReportBuilder.ts:98

Registers a section by its ID, specifying the page size, margins, and other options.

Parameters​
ParameterTypeDescription
optionsSectionOptionsConfiguration options for the section.
componentsSectionComponentsThe DOM components associated with the section.
onPaginationCompleted(context) => void | Promise<unknown>Callback invoked when pagination for the section is completed.
Returns​

Promise<boolean>

true if the section was added to the report’s section list, or false if it already exists.


LayoutOptions​

Defined in: paginate/LayoutOptions.ts:15

Layout options for the pagination engine

Properties​

PropertyTypeDefault valueDescription
hyphen?string"-"Specifies the character used for hyphenation when a word is broken across lines.
hyphenationDisabled?booleanfalseDisables automatic word hyphenation. When disabled, if a word (a sequence of text without whitespace) does not fit on the current page, it will move to the next page instead of being split with a hyphen character.
keepOnSamePage?KeepOnSamePageOptionsfalsePrevents an element from being split across pages.

PageContext​

Defined in: report/ReportBuilderEvents.ts:7

Context information for a paginated page.

Properties​

PropertyTypeDescription
pageContentHtmlstringHTML string representing the paginated content of this page.
pageIndexnumberIndex of this page within its section.
sectionIdstringIndex of the section to which this page belongs
totalPagesnumberTotal number of pages in the section that contains this page.

PageMargin​

Defined in: report/pageTypes.ts:20

Represents the margin sizes for a page. All values should be valid CSS size strings (e.g., '10mm', '1in').

Common presets are available in pageMargin

Properties​

PropertyType
bottomstring
leftstring
rightstring
topstring

PageSize​

Defined in: report/pageTypes.ts:7

Represents the dimensions of a page. All values should be valid CSS size strings (e.g., '210mm', '8.5in').

Common presets are available in pageSize

Properties​

PropertyType
heightstring
widthstring

PaginationCycleCompleted​

Defined in: report/ReportBuilderEvents.ts:68

Context information for pagination cycle.

Properties​

PropertyTypeDescription
sectionsSectionContext[]All paginated section within the report.

PaginationOptions​

Defined in: paginate/PaginationOptions.ts:10

Pagination options

Properties​

PropertyTypeDefault valueDescription
hyphenstring"-"Specifies the character used for hyphenation when a word is broken across lines.
hyphenationDisabledbooleanfalseDisables automatic word hyphenation. When disabled, if a word (a sequence of text without whitespace) does not fit on the current page, it will move to the next page instead of being split with a hyphen character.
idstringundefinedUnique id of the pagination.
keepOnSamePageKeepOnSamePageOptionsfalsePrevents an element from being split across pages.
pluginsPaginationPlugin[]undefinedList of plugins to use during pagination.

ReportBuilderEvents​

Defined in: report/ReportBuilderEvents.ts:78

Available events that can be subscribed to, during the pagination process.

Properties​

PropertyTypeDescription
pageCompleted(event) => voidTriggered when a page has been fully paginated. event: PageContext
paginationCycleCompleted(event) => voidTriggered when an entire pagination cycle is completed. event: PaginationCycleCompleted
sectionCompleted(event) => voidTriggered when a section has been fully paginated. event: SectionContext
sectionCreated(event) => voidTriggered when a new section is created. event: SectionContext

ScheduleResult​

Defined in: report/ReportBuilder.ts:36

Represents the result of a scheduled pagination process.

Properties​

PropertyTypeDescription
sectionsSectionContext[]List of all registered sections.
suspensionPromise<void>If there are any suspended sections, this Promise tracks their state and resolves only after all suspended sections have been resumed and paginated.

SectionComponents​

Defined in: report/sectionComponents.ts:5

Represents the collection of DOM elements generated by the pagination engine from the report components on the current page.

Properties​

PropertyTypeDescription
pageContentHTMLElementThe main HTML element for the this page content This property is always defined.
pageFooterHTMLElement | nullThe HTML element that serves as the footer for this page. null if the page has no footer.
pageHeaderHTMLElement | nullThe HTML element that serves as the header for this page. null if the page has no header.
sectionFooterHTMLElement | nullThe HTML element that serves as the footer for the entire section. null if the section has no section footer.
sectionHeaderHTMLElement | nullThe HTML element that serves as the header for the entire section. null if the section has no section header.

SectionContext​

Defined in: report/ReportBuilderEvents.ts:29

Context information for a paginated section.

Properties​

PropertyTypeDescription
componentsSectionComponentsComponents used in this section.
isPaginatedbooleanIndicates whether pagination for this section has completed.
isSuspendedbooleanIndicates whether pagination for this section is suspended and waiting for the suspension to be resolved.
optionsSectionOptionsOptions used for paginating this section. Remarks Options may differ from the original SectionOptions provided during section creation, as some values may be
pagesPageContext[]All paginated pages that belong to this section.
sectionIdstringUnique identifier of the section.
sectionIndexnumberIndex of the section within the report.

SectionOptions​

Defined in: report/SectionOptions.ts:9

Configuration options for a section.

Extends​

Properties​

PropertyTypeDefault valueDescription
hyphen?string"-"Specifies the character used for hyphenation when a word is broken across lines.
hyphenationDisabled?booleanfalseDisables automatic word hyphenation. When disabled, if a word (a sequence of text without whitespace) does not fit on the current page, it will move to the next page instead of being split with a hyphen character.
idstringundefinedUnique id of the section within the report.
keepOnSamePage?KeepOnSamePageOptionsfalsePrevents an element from being split across pages.
margin?PageMarginundefinedPage margins for this section.
orientation?"portrait" | "landscape"undefinedPage orientation used for this section. Default portrait
plugins?PaginationPlugin[]undefinedList of plugins to use during pagination.
sizePageSizeundefinedPage size used for this section.
suspense?Promise<unknown>[]undefinedA list of promises that must be resolved before the section can be paginated.

TablePluginOptions​

Defined in: plugins/TablePlugin.ts:17

Table plugin options

Properties​

PropertyTypeDescription
cloneFooter?booleanIf true, the table footer (tfoot) will be cloned on each page.
cloneHeader?booleanIf true, the table header (thead) will be cloned on each page.
includeHeaderOnlyTables?booleanWhen true, tables containing only a header (no body rows) will not be removed.

KeepOnSamePageOptions​

KeepOnSamePageOptions = true | false | "prefer"

Defined in: paginate/LayoutOptions.ts:10

Controls how elements handle page breaks when they exceed the remaining space on a page.

  • true (Strict Keep): Forces the element to stay whole. Moves it to the next page if it doesn't fit. If it's larger than a full empty page, it is dropped.
  • false (Allow Split): Prioritizes rendering immediately. Splits the element across pages; if splitting is impossible, it moves to the next page or is dropped.
  • 'prefer' (Balanced): Attempts to keep the element whole by moving it to the next page first. If it still doesn't fit a full page, it falls back to splitting.

PageOrientation​

PageOrientation = "portrait" | "landscape"

Defined in: report/pageTypes.ts:38

Defines the physical orientation of the page.

  • portrait: Standard vertical orientation (height > width). Dimensions are applied exactly as defined. Default.
  • landscape: Horizontal orientation (width > height). The provided width and height values are automatically swapped.

pageMargin​

const pageMargin: object

Defined in: report/pageConst.ts:40

Predefined values for commonly used PageMargin

Type Declaration​

NameTypeDescription
NarrowPageMarginTop: 0.4in, Right, Bottom, Left: 0.6in
NonePageMarginTop, Right, Bottom, Left: 0
NormalPageMarginTop, Right, Bottom, Left: 1in
WidePageMarginTop, Bottom: 0.5in, Right, Left: 2in

pageSize​

const pageSize: object

Defined in: report/pageConst.ts:8

Predefined values for commonly used PageSize

Type Declaration​

NameTypeDescription
A1PageSize841mm x 594mm
A2PageSize594mm x 420mm
A3PageSize420mm x 297mm
A4PageSize297mm x 210mm
A5PageSize210mm x 148mm
A6PageSize148mm x 105mm
B3PageSize500mm x 353mm
B4PageSize353mm x 250mm
B5PageSize250mm x 176mm
LegalPageSize11in x 8.5in
LetterPageSize8.5in x 11in
TabloidPageSize11in x 17in