Rasterex APINPM Package/docs/components/pdf/move-pages

Move Pages

Reorder pages in the active PDF using move-top, move-bottom, move-up, and move-down with the SDK.

Overview

The move actions reorder existing pages in the active PDF. All move actions use pageRange to identify which pages should move.

Choose the move action based on the destination behavior you need: top, bottom, up by one step, or down by one step.

  • move-top: Moves the selected pages to the beginning of the document.
  • move-bottom: Moves the selected pages to the end of the document.
  • move-up: Moves the selected pages one position earlier.
  • move-down: Moves the selected pages one position later.

Examples

All move actions share the same method parameter structure. Only the action value changes.

typescript
// Move pages at index 3 and 4 to the beginning of the PDF
await viewer.documents.manipulatePages({
  action: "move-top",
  pageRange: [[3, 4]]
});

// Move page index 1 down by one position
await viewer.documents.manipulatePages({
  action: "move-down",
  pageRange: [[1]]
});
Examples

Vanilla TS Integration

Example function showing how to move a page range programmatically using the SDK:

typescript
import { createViewer } from "@rasterex/viewer";

const viewer = createViewer({
  container: "#viewer"
});

await viewer.mount();
await viewer.ready();

async function moveCurrentPageToTop(pageIndex: number): Promise<void> {
  try {
    await viewer.documents.manipulatePages({
      action: "move-top",
      pageRange: [[pageIndex]]
    });
    console.log("Page moved successfully");
  } catch (error) {
    console.error("Could not move page:", error);
  }
}
Vanilla TS Integration

Live Preview

Open the focused demo to test page move actions against a live PDF.

PDF Move Pages Demo

Focused live demo for move-top, move-bottom, move-up, and move-down.

Preview opens in a large modal for zoom-friendly review.