---
title: "Add page to PDF file using JavaScript | Nutrient SDK"
canonical_url: "https://www.nutrient.io/guides/web/editor/add-page/"
md_url: "https://www.nutrient.io/guides/web/editor/add-page.md"
last_updated: "2026-05-25T18:42:17.819Z"
description: "Learn how to add blank pages to PDF documents using JavaScript with Nutrient Web SDK. Insert pages before or after any index with configurable size, color, and rotation options."
---

# Add pages to PDFs using JavaScript

Using `addPage` adds a blank page before or after the specified page index using the provided configuration:

```js

instance.applyOperations([
  {
    type: "addPage",
    afterPageIndex: 1, // Add a new page after page 1.
    backgroundColor: new NutrientViewer.Color({ r: 100, g: 200, b: 255 }), // Set the new page background color.
    pageWidth: 750,
    pageHeight: 1000,
    rotateBy: 0 // No rotation.
    // Insets are optional.
  }
]);

```

## Exporting a PDF

After this operation is complete, you can call [`instance#exportPDF`](https://www.nutrient.io/api/web/NutrientViewer.Instance.html#exportPDF) to get an `ArrayBuffer` containing the data for the final PDF.

If you need to apply this operation and export the resulting document in one step, you can provide the same argument passed to [`instance#applyOperations`](https://www.nutrient.io/api/web/NutrientViewer.Instance.html#applyOperations) to [`instance#exportPDFWithOperations`](https://www.nutrient.io/api/web/NutrientViewer.Instance.html#exportPDFWithOperations) instead, and it’ll resolve to an `ArrayBuffer` containing the final PDF.
---

## Related pages

- [Edit PDF text using our JavaScript content editor](/guides/web/editor/edit-text.md)
- [Process documents via Document Engine or DWS API using JavaScript](/guides/web/editor/backend-processing.md)
- [Add Bates numbering in PDFs using JavaScript](/guides/web/editor/add-bates-number.md)
- [Add images to PDFs using JavaScript](/guides/web/editor/add-image.md)
- [Headless PDF editor](/guides/web/features/document-editor.md)
- [PDF editing toolbar and UI](/guides/web/features/document-editor-ui.md)
- [Split PDFs using JavaScript](/guides/web/editor/split.md)
- [PDF content editing API for Web](/guides/web/editor/content-editor-api.md)
- [Merge PDF files using JavaScript](/guides/web/editor/merge-or-combine.md)
- [JavaScript PDF editor library](/guides/web/editor.md)
- [Edit page labels in a PDF](/guides/web/editor/page-label.md)
- [Replace text in PDFs using JavaScript](/guides/web/editor/replace-text.md)

