Skip to main content

@paprize/core

ReportBuilder

Defined in: report/ReportBuilder.ts:82

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:107

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

Returns

Monitor<ReportBuilderEvents>

Methods

removeSection()

removeSection(sectionId): void

Defined in: report/ReportBuilder.ts:114

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:178

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): boolean

Defined in: report/ReportBuilder.ts:126

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(pages) => voidCallback invoked when pagination for the section is completed.
Returns

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:4

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?booleanfalsePrevents an element from being split across pages. If an element does not fit in the available space on the current page, it will be moved entirely to the next page. If it still does not fit on an empty page, it will be skipped and not rendered.

PageContext

Defined in: report/ReportBuilderEvents.ts:4

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:53

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.
keepOnSamePagebooleanfalsePrevents an element from being split across pages. If an element does not fit in the available space on the current page, it will be moved entirely to the next page. If it still does not fit on an empty page, it will be skipped and not rendered.
pluginsPaginationPlugin[]undefinedList of plugins to use during pagination.

ReportBuilderEvents

Defined in: report/ReportBuilderEvents.ts:63

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:64

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:26

Context information for a paginated section.

Properties

PropertyTypeDescription
isPaginatedbooleanIndicates whether pagination for this section has completed.
isSuspendedbooleanIndicates whether pagination for this section is suspended and waiting for the suspension to be resolved.
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/ReportBuilder.ts:27

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?booleanfalsePrevents an element from being split across pages. If an element does not fit in the available space on the current page, it will be moved entirely to the next page. If it still does not fit on an empty page, it will be skipped and not rendered.
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:12

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.

PageOrientation

PageOrientation = "portrait" | "landscape"

Defined in: report/pageTypes.ts:39

Describes the page orientation.

  • 'portrait' (default): the page is taller than it is wide. Use the provided width and height as-is.
  • 'landscape': the page is wider than it is tall. When applying landscape, swap the width and height.

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