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

Rotate Pages

Rotate one or more pages in the active PDF with rotate-r and rotate-l using the SDK.

Overview

The rotate actions change the orientation of existing pages in the active PDF. Both actions use pageRange to identify the affected pages.

Use rotate-r for clockwise rotation and rotate-l for counterclockwise rotation.

Examples

Rotate actions are direct page edits and return standard success or failure results.

typescript
// Rotate pages 0, 1, 2 clockwise
await viewer.documents.manipulatePages({
  action: "rotate-r",
  pageRange: [[0, 2]]
});

// Rotate page 4 counter-clockwise
await viewer.documents.manipulatePages({
  action: "rotate-l",
  pageRange: [[4]]
});
Examples

Vanilla TS Integration

Example function showing how to rotate pages programmatically using the SDK:

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

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

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

async function rotateCurrentPageRight(pageIndex: number): Promise<void> {
  try {
    await viewer.documents.manipulatePages({
      action: "rotate-r",
      pageRange: [[pageIndex]]
    });
    console.log("Page rotated");
  } catch (error) {
    console.error("Rotation failed:", error);
  }
}
Vanilla TS Integration

Live Preview

Open the focused demo to test page rotation live.

PDF Rotate Pages Demo

Focused live demo for rotate-r and rotate-l.

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