View as Markdown

API reference: @salmonui/pdf-viewer

PdfViewerActionsinterface

import type { PdfViewerActions } from '@salmonui/pdf-viewer';
interface PdfViewerActions {
    goToPage(page: number): void;
    search(query: string, options?: PdfViewerSearchOptions): Promise<PdfViewerSearchResult>;
    findNext(): void;
    findPrevious(): void;
    clearSearch(): void;
    setZoom(zoom: PdfViewerZoom): void;
    print(): Promise<boolean>;
    save(): Promise<Blob>;
    download(fileName?: string): Promise<void>;
    addTextMarkup(kind: PdfTextMarkupKind, options?: {
        readonly color?: string;
        readonly opacity?: number;
        readonly comment?: string;
    }): readonly PdfTextMarkupAnnotation[];
    removeAnnotation(id: string): void;
    getState(): PdfViewerStateSnapshot;
    openFind(open?: boolean): void;
}

Commands (actionsRef).

PdfViewerActions members (13)
NameSignatureDescription
goToPagegoToPage(page: number): void;

Scrolls to a page (1-based, clamped).

searchsearch(query: string, options?: PdfViewerSearchOptions): Promise<PdfViewerSearchResult>;

Runs a search over every page; resolves when all pages are searched.

findNextfindNext(): void;
findPreviousfindPrevious(): void;
clearSearchclearSearch(): void;
setZoomsetZoom(zoom: PdfViewerZoom): void;
printprint(): Promise<boolean>;

Opens the print dialog; resolves false when onBeforePrint cancelled.

savesave(): Promise<Blob>;

The document with the current form values and text markup annotations written into it.

downloaddownload(fileName?: string): Promise<void>;

Saves and downloads as fileName (default the fileName prop).

addTextMarkupaddTextMarkup(kind: PdfTextMarkupKind, options?: { readonly color?: string; readonly opacity?: number; readonly comment?: string; }): readonly PdfTextMarkupAnnotation[];

Marks the current text selection; returns the new annotations (one per page).

removeAnnotationremoveAnnotation(id: string): void;
getStategetState(): PdfViewerStateSnapshot;

Current page, page count and scale.

openFindopenFind(open?: boolean): void;

Opens or closes the find bar.