@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
| Parameter | Type |
|---|---|
sectionId | string |
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
| Parameter | Type | Description |
|---|---|---|
options | SectionOptions | Configuration options for the section. |
components | SectionComponents | The DOM components associated with the section. |
onPaginationCompleted | (pages) => void | Callback 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
PageContext
Defined in: report/ReportBuilderEvents.ts:4
Context information for a paginated page.
Properties
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
| Property | Type |
|---|---|
bottom | string |
left | string |
right | string |
top | string |
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
| Property | Type |
|---|---|
height | string |
width | string |
PaginationCycleCompleted
Defined in: report/ReportBuilderEvents.ts:53
Context information for pagination cycle.
Properties
| Property | Type | Description |
|---|---|---|
sections | SectionContext[] | All paginated section within the report. |
PaginationOptions
Defined in: paginate/PaginationOptions.ts:10
Pagination options
Properties
ReportBuilderEvents
Defined in: report/ReportBuilderEvents.ts:63
Available events that can be subscribed to, during the pagination process.
Properties
| Property | Type | Description |
|---|---|---|
pageCompleted | (event) => void | Triggered when a page has been fully paginated. event: PageContext |
paginationCycleCompleted | (event) => void | Triggered when an entire pagination cycle is completed. event: PaginationCycleCompleted |
sectionCompleted | (event) => void | Triggered when a section has been fully paginated. event: SectionContext |
sectionCreated | (event) => void | Triggered when a new section is created. event: SectionContext |
ScheduleResult
Defined in: report/ReportBuilder.ts:64
Represents the result of a scheduled pagination process.
Properties
| Property | Type | Description |
|---|---|---|
sections | SectionContext[] | List of all registered sections. |
suspension | Promise<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
SectionContext
Defined in: report/ReportBuilderEvents.ts:26
Context information for a paginated section.
Properties
| Property | Type | Description |
|---|---|---|
isPaginated | boolean | Indicates whether pagination for this section has completed. |
isSuspended | boolean | Indicates whether pagination for this section is suspended and waiting for the suspension to be resolved. |
pages | PageContext[] | All paginated pages that belong to this section. |
sectionId | string | Unique identifier of the section. |
sectionIndex | number | Index of the section within the report. |
SectionOptions
Defined in: report/ReportBuilder.ts:27
Configuration options for a section.
Extends
Partial<Omit<PaginationOptions,"id">>
Properties
| Property | Type | Default value | Description |
|---|---|---|---|
hyphen? | string | "-" | Specifies the character used for hyphenation when a word is broken across lines. |
hyphenationDisabled? | boolean | false | Disables 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. |
id | string | undefined | Unique id of the section within the report. |
keepOnSamePage? | boolean | false | Prevents 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? | PageMargin | undefined | Page margins for this section. |
orientation? | "portrait" | "landscape" | undefined | Page orientation used for this section. Default portrait |
plugins? | PaginationPlugin[] | undefined | List of plugins to use during pagination. |
size | PageSize | undefined | Page size used for this section. |
suspense? | Promise<unknown>[] | undefined | A list of promises that must be resolved before the section can be paginated. |
TablePluginOptions
Defined in: plugins/TablePlugin.ts:12
Table plugin options
Properties
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
constpageMargin:object
Defined in: report/pageConst.ts:40
Predefined values for commonly used PageMargin
Type Declaration
| Name | Type | Description |
|---|---|---|
Narrow | PageMargin | Top: 0.4in, Right, Bottom, Left: 0.6in |
None | PageMargin | Top, Right, Bottom, Left: 0 |
Normal | PageMargin | Top, Right, Bottom, Left: 1in |
Wide | PageMargin | Top, Bottom: 0.5in, Right, Left: 2in |
pageSize
constpageSize:object
Defined in: report/pageConst.ts:8
Predefined values for commonly used PageSize
Type Declaration
| Name | Type | Description |
|---|---|---|
A1 | PageSize | 841mm x 594mm |
A2 | PageSize | 594mm x 420mm |
A3 | PageSize | 420mm x 297mm |
A4 | PageSize | 297mm x 210mm |
A5 | PageSize | 210mm x 148mm |
A6 | PageSize | 148mm x 105mm |
B3 | PageSize | 500mm x 353mm |
B4 | PageSize | 353mm x 250mm |
B5 | PageSize | 250mm x 176mm |
Legal | PageSize | 11in x 8.5in |
Letter | PageSize | 8.5in x 11in |
Tabloid | PageSize | 11in x 17in |