---
title: "Move or copy PDF pages using JavaScript | Nutrient SDK"
canonical_url: "https://www.nutrient.io/guides/web/editor/page-manipulation/move-or-copy/"
md_url: "https://www.nutrient.io/guides/web/editor/page-manipulation/move-or-copy.md"
last_updated: "2026-06-08T19:21:59.292Z"
description: "Move or duplicate PDF pages using JavaScript with Nutrient Web SDK. Use movePages and duplicatePages operations to rearrange document pages programmatically."
---

# Move or copy PDF pages using JavaScript

To move or copy pages, you can use our page editor operations.

Using `movePages` moves the pages specified in the `pageIndexes` array before or after the specified page index:

```js

instance.applyOperations([
  {
    type: "movePages",
    pageIndexes: [0, 4], // Move pages 0 and 4.
    beforePageIndex: 7 // The specified pages will be moved after page 7.
  }
]);

```

Using `duplicatePages` duplicates the pages specified in the `pageIndexes` array. Each duplicated page will be inserted after the page being duplicated:

```js

instance.applyOperations([
  {
    type: "duplicatePages",
    pageIndexes: [0, 4] // Duplicate pages 0 and 4, and insert each duplicate after the original page.
  }
]);

```

After this operation is complete, call `exportPDF` to get a buffer containing the data for the final PDF.

If you need to apply this operation and export in one step, you can provide the same argument you provide to `applyOperations` to `exportPDFWithOperations` to get a buffer containing the data for the final PDF.

---

## Related pages

- [Adding margins to PDF pages using JavaScript](/guides/web/editor/page-manipulation/add-margins.md)
- [Crop PDFs using JavaScript](/guides/web/editor/page-manipulation/crop.md)
- [Remove pages from a PDF using JavaScript](/guides/web/editor/page-manipulation/remove.md)
- [Rotating PDF pages using JavaScript](/guides/web/editor/page-manipulation/rotate.md)

