Message API/docs/components/pdf/api

API References

Technical reference for page list, page selection, and page manipulation workflows.

pageList Payload

The viewer emits `pageList` as the latest page snapshot for the active file.

type PageListPayload = {
  activeId: string;
  activeIndex: number;
  currentPage: number;
  pageCount: number;
  pages: Array<{
    index: number;
    pageNumber: number;
    title: string;
    label: string;
    isSelected: boolean;
    thumbnailDataUrl?: string;
    thumbnailWidth?: number;
    thumbnailHeight?: number;
  }>;
};
pageList Payload

selectPage Payload

The host uses `selectPage` to navigate from its own page UI.

type SelectPagePayload = {
  pageIndex?: number;
  pageNumber?: number;
};
selectPage Payload

pageManipulation Payload

Use `pageManipulation` for PDF page actions. The exact fields depend on the action.

Treat the payload as a required base plus action-specific fields instead of one giant universal contract.

  • Base fields: `requestId` and `action` are always required.
  • Range actions: reorder, rotate, extract, and delete actions require `pageRange`.
  • Paste: `page-paste` requires `targetPageIndex`.
  • Insert / Replace: `page-insert` and `page-replace` require `pageRange`, `file`, and `selectedPages`.
  • Blank pages: `page-insert-blank` requires `pageRange`, `count`, `width`, and `height`.
type PageRange = [number] | [number, number];

type PageManipulationPayload = {
  requestId: string;
  action:
    | 'move-top' | 'move-bottom' | 'move-up' | 'move-down'
    | 'rotate-r' | 'rotate-l'
    | 'page-copy' | 'page-paste'
    | 'page-extract' | 'page-extract-delete' | 'page-delete'
    | 'page-insert' | 'page-replace' | 'page-insert-blank';
  pageRange?: PageRange[];
  targetPageIndex?: number;
  file?: File;
  selectedPages?: PageRange[];
  count?: number;
  width?: number;
  height?: number;
};
pageManipulation Payload

Result Events

Page navigation and page manipulation both return result events that the host should handle explicitly.

  • selectPageResult: Confirms the page-selection request.
  • pageManipulationResult: Reports success or failure for page-level edits.
type PageManipulationResultPayload = {
  success?: boolean;
  requestId?: string;
  action?: string;
  pageRange?: PageRange[];
  pages?: number[];
  currentPage?: number;
  pageCount?: number;
  error?: string;
  [key: string]: unknown;
};
Result Events