usePageMove

Returns functions that move pages to a new position, such as for a drag-to-reorder sidebar.

const { moveAfter, moveBefore } = usePageMove()

moveAfter(pageIdOrPageIds, afterPageId?)
moveBefore(pageIdOrPageIds, beforePageId?)
  • moveAfter inserts the pages after afterPageId; without it, at the end of the document.
  • moveBefore inserts the pages before beforePageId; without it, at the start of the document.
  • Several pages move together in the given order, as a single undo step.
  • Every id must identify an existing page, or the call throws InvalidInputError; with no document loaded, it throws DocumentNotLoadedError.

Example

import { usePageMove } from '@sdk-pdf/react'

function useMovePageToStart() {
  const { moveBefore } = usePageMove()

  return (pageId: string) => moveBefore(pageId)
}

On this page