[]
ReportViewer.Viewer
Represents the report viewer component.
remarks
Use this class to render and interact with reports in the browser.
example
const viewer = new Viewer('#viewer');
• new Viewer(element, options?)
Initializes a new instance of the Viewer class.
example
const viewer = new ActiveReports.Viewer('#viewer', { language: 'en' });
await viewer.open('report.json');
| Name | Type | Description |
|---|---|---|
element |
string | object | Element |
The host element for the viewer. |
options? |
ViewerOptions |
Optional viewer configuration settings. |
• get availableExports(): string[]
Gets or sets the export formats shown in the export panel.
string[]
• set availableExports(formatKeys): void
Gets or sets the export formats shown in the export panel.
| Name | Type |
|---|---|
formatKeys |
string[] |
void
• get currentPage(): number
Gets the current page number (1-based).
number
• get documentLoaded(): Event<DocumentLoadEventArgs>
Gets the event fired after the document is fully rendered.
• get errorHandler(): ErrorHandler
Gets or sets the viewer error handler.
ErrorHandler
• set errorHandler(handler): void
Gets or sets the viewer error handler.
| Name | Type |
|---|---|
handler |
ErrorHandler |
void
• get history(): HistoryApi
Gets the history API.
• get mouseMode(): ViewerMouseMode
Gets or sets the mouse interaction mode.
• set mouseMode(value): void
Gets or sets the mouse interaction mode.
| Name | Type |
|---|---|
value |
ViewerMouseMode |
void
• get pageCount(): number
Gets the total number of pages in the current report.
number
• get renderMode(): ViewerRenderMode
Gets or sets the viewer render mode.
• set renderMode(mode): void
Gets or sets the viewer render mode.
| Name | Type |
|---|---|
mode |
ViewerRenderMode |
void
• get reportLoaded(): Event<ReportLoadEventArgs>
Gets the event fired after a report is loaded.
• get showParametersOnOpen(): ShowParametersOnOpen
Gets or sets when the parameters panel is shown.
• set showParametersOnOpen(mode): void
Gets or sets when the parameters panel is shown.
| Name | Type |
|---|---|
mode |
ShowParametersOnOpen |
void
• get stateChanged(): Event<ChangedEventArgs>
Gets the event that indicates viewer state changes.
Event<ChangedEventArgs>
• get theme(): undefined | UITheme
Gets or sets the current UI theme.
undefined | UITheme
• set theme(value): void
Gets or sets the current UI theme.
| Name | Type |
|---|---|
value |
undefined | UITheme |
void
• get toolbar(): Toolbar
Gets the viewer toolbar API.
• get viewMode(): ViewerViewMode | ViewMode
Gets or sets the viewer view mode.
• set viewMode(value): void
Gets or sets the viewer view mode.
| Name | Type |
|---|---|
value |
ViewerViewMode | ViewMode |
void
• get zoom(): ViewerZoomMode
Gets or sets the current zoom value.
• set zoom(value): void
Gets or sets the current zoom value.
| Name | Type |
|---|---|
value |
ViewerZoomMode |
void
▸ backToParent(): void
Navigates back to the parent report.
example
viewer.backToParent();
void
▸ canBackToParent(): boolean
Gets a value indicating whether back-to-parent navigation is available.
example
const canNavigate = viewer.canBackToParent();
boolean
true if back-to-parent navigation is available; otherwise, false.
▸ dispose(): void
Disposes the viewer and releases resources.
example
viewer.dispose();
void
▸ export(format, settings, params?): Promise<ExportResult>
Exports the current report to the specified format.
example
const result = await viewer.export('pdf', { title: 'Invoice' });
result.download('invoice.pdf');
| Name | Type | Description |
|---|---|---|
format |
string |
The export format identifier (for example, pdf, xlsx, or html). |
settings |
Record<string, string | number | boolean> |
The format-specific export settings. |
params? |
Object |
Optional export parameters. |
params.cancel? |
() => boolean |
- |
Promise<ExportResult>
A promise that resolves to the export result.
▸ goToFirstPage(): void
Navigates to the first page.
example
viewer.goToFirstPage();
void
▸ goToLastPage(): void
Navigates to the last page.
example
viewer.goToLastPage();
void
▸ goToNextPage(): void
Navigates to the next page.
example
viewer.goToNextPage();
void
▸ goToPage(pageNumber): void
Navigates to the specified page.
example
viewer.goToPage(3);
| Name | Type | Description |
|---|---|---|
pageNumber |
number |
The 1-based page number to navigate to. |
void
▸ goToPrevPage(): void
Navigates to the previous page.
example
viewer.goToPrevPage();
void
▸ highlight(result): Promise<void>
Highlights a search result.
example
const result = {} as SearchFeature.SearchResult;
await viewer.highlight(result);
| Name | Type | Description |
|---|---|---|
result |
null | SearchResult |
The search result to highlight, or null to clear. |
Promise<void>
A promise that resolves when highlighting is complete.
▸ open(report, settings?): Promise<LoadResult>
Opens a report from a URI, definition, or PageReport instance.
example
await viewer.open('report.json');
| Name | Type | Description |
|---|---|---|
report |
string | Report | PageReport |
The report source to open. |
settings? |
Partial<ReportSettings> |
Optional report settings. |
Promise<LoadResult>
A promise that resolves to the load result.
▸ print(): void
Prints the current report.
example
viewer.print();
void
▸ refresh(): void
Refreshes the current report.
example
viewer.refresh();
void
▸ resetDocument(): Promise<void>
Resets the current document state.
example
await viewer.resetDocument();
Promise<void>
A promise that resolves when the document is reset.
▸ search(options, resultFn, progressFn?, cancel?): Promise<SearchStatus>
Searches within the current report.
example
await viewer.search(
{ text: 'Total' },
(result) => console.log(result.pageIndex),
);
| Name | Type | Description |
|---|---|---|
options |
SearchOptions |
The search options. |
resultFn |
(result: SearchResult) => void |
The callback invoked for each search result. |
progressFn? |
(progress: { pageCount: null | number ; pageIndex: number }) => void |
The optional callback invoked with search progress. |
cancel? |
CancellationToken |
The optional cancellation token. |
Promise<SearchStatus>
A promise that resolves to the search status.
▸ toggleFullScreen(enabled?): void
Toggles full-screen mode.
example
viewer.toggleFullScreen(true);
| Name | Type | Description |
|---|---|---|
enabled? |
boolean |
Optional full-screen override. When omitted, the current state is toggled. |
void
▸ toggleSidebar(visible?): void
Toggles the sidebar panel visibility.
example
viewer.toggleSidebar(true);
| Name | Type | Description |
|---|---|---|
visible? |
boolean |
Optional visibility override. When omitted, the visibility is toggled. |
void
▸ toggleToolbar(show?): void
Toggles the toolbar visibility.
example
viewer.toggleToolbar(false);
| Name | Type | Description |
|---|---|---|
show? |
boolean |
Optional visibility override. When omitted, the visibility is toggled. |
void