Skip to content
Apertura
API reference

@apertura/angular

Angular bindings for the Apertura viewer

7 exported symbols · 1 declared here · 6 re-exported

Classes

AperturaViewerComponent
class AperturaViewerComponent implements AfterViewInit, OnChanges, OnDestroy

A document viewer component for Angular. The API and lifecycle are complete, but the package is built with the shared tsup toolchain rather than ng-packagr, so it is suitable for JIT mode and for development. Publishing it for Angular production builds requires moving to ng-packagr and the partial-Ivy format, which is a separate step for when this wrapper reaches release.

file
ByteSourceInput | undefined
What to open: a `File`, a `Blob`, a byte buffer, or a URL.
options
ViewerOptions
Viewer options: zoom, fit mode, a custom format registry.
stateChange
EventEmitter<ViewerState>
ngAfterViewInit
() => void
A callback method that is invoked immediately after Angular has completed initialization of a component's view. It is invoked only once when the view is instantiated.
ngOnChanges
(changes: SimpleChanges) => void
A callback method that is invoked immediately after the default change detector has checked data-bound properties if at least one has changed, and before the view and content children are checked.
ngOnDestroy
() => void
A callback method that performs custom clean-up, invoked immediately before a directive, pipe, or service instance is destroyed.
viewer
Viewer | undefined
Direct access to the viewer, for cases the inputs do not cover.
Viewerfrom @apertura/viewer
class Viewer

A framework-independent document viewer. The single place that knows the full path from bytes to format to document to DOM. The React, Vue and Angular wrappers are thin adapters over this class, so their behaviour is identical by construction rather than by convention.

state
ViewerState
container
HTMLElement
view
DocumentView | undefined
The live view, for reaching format-specific APIs such as page navigation.
subscribe
(listener: (state: ViewerState) => void) => () => void
Subscribes to state changes. Returns an unsubscribe function.
open
(input: ByteSourceInput, options?: ViewerOptions) => Promise<void>
Opens a file and mounts its view. Calling it again before the previous call settles is correct: the older result is discarded. That is the normal case when a user picks files in quick succession.
refresh
() => void
Re-renders the current view.
close
() => void
Closes the document and clears the container.
destroy
() => void
Releases every resource. The instance must not be used afterwards.

Functions

createDefaultRegistryfrom @apertura/viewer
function createDefaultRegistry(): FormatRegistry

A registry with every supported format registered. The convenient entry point for an application that just needs to open a file. When bundle size matters, build a {@link FormatRegistry} by hand so only the parsers actually used are included.

createViewerfrom @apertura/viewer
function createViewer(container: HTMLElement, options?: ViewerOptions): Viewer

Creates a viewer mounted into the given element.

Interfaces

ViewerOptionsfrom @apertura/viewer
interface ViewerOptions extends ViewOptions, OpenOptions
registry?
FormatRegistry | undefined
The plugin set to use. Defaults to every supported format. Pass a custom registry to keep unused parsers out of the bundle.
renderOptions?
Record<string, unknown> | undefined
Extra options forwarded to the format renderer.
ViewerStatefrom @apertura/viewer
interface ViewerState
status
ViewerStatus
document
AperturaDocument | undefined
detection
DetectionResult | undefined
error
Error | undefined
progress
number
Parse progress, 0..1.

Type aliases

ViewerStatusfrom @apertura/viewer
type ViewerStatus = 'idle' | 'loading' | 'ready' | 'error'

Viewer state; UI wrappers render indicators from it.