---
title: "Duplicate PDF page server-side | Nutrient SDK"
canonical_url: "https://www.nutrient.io/guides/document-engine/editor/page-manipulation/duplicate/"
md_url: "https://www.nutrient.io/guides/document-engine/editor/page-manipulation/duplicate.md"
last_updated: "2026-06-08T07:47:35.189Z"
description: "Document Engine lets you duplicate pages of a document using the /build endpoint."
---

# Duplicate PDF pages

Document Engine lets you duplicate pages of a document using the `/build` endpoint.

- Ensure [Document Engine is up and running](https://www.nutrient.io/sdk/document-engine/getting-started.md).

- Send a [multipart POST request](https://www.baeldung.com/postman-form-data-raw-x-www-form-urlencoded) with [instructions](https://www.nutrient.io/api/reference/document-engine/upstream/#tag/Build-API) to Document Engine’s `/api/build` endpoint.

For more information, refer to the [API reference](https://www.nutrient.io/api/reference/document-engine/upstream/#tag/Build-API) to learn about the `/api/build` endpoint and all the actions you can perform on PDFs with Document Engine.

For an overview of multipart requests, refer to the [brief tour of multipart requests](https://www.nutrient.io/blog/a-brief-tour-of-multipart-requests/) blog post.









## Duplicating pages of a file on disk

Send a multipart request to the [`/api/build` endpoint](https://www.nutrient.io/api/reference/document-engine/upstream/#tag/Document-Editing/operation/build-document), attaching the input file(s) and the `instructions` JSON:

The following example duplicates the second page (with index `1`) of the document before merging it with the other pages.

It splits the eight-page document into four parts. The first part is the first page of the document. The second and third parts are the second page, which is the page we want to duplicate. This is why it appears twice. The fourth part is the remainder of the pages.

### SHELL

```shell

curl -X POST http://localhost:5000/api/build \
  -H "Authorization: Token token=<API token>" \
  -F document=@/path/to/example-document.pdf \
  -F instructions='{
  "parts": [
    {
      "file": "document",
      "pages": {
        "start": 0,
        "end": 0
      }
    },
    {
      "file": "document",
      "pages": {
        "start": 1,
        "end": 1
      }
    },
    {
      "file": "document",
      "pages": {
        "start": 1,
        "end": 1
      }
    },
    {
      "file": "document",
      "pages": {
        "start": 2,
        "end": 7
      }
    }
  ]
}' \
  -o result.pdf

```

### HTTP

```http

POST /api/build HTTP/1.1
Content-Type: multipart/form-data; boundary=customboundary
Authorization: Token token=<API token>

--customboundary
Content-Disposition: form-data; name="document"; filename="example-document.pdf"
Content-Type: application/pdf

<PDF data>
--customboundary
Content-Disposition: form-data; name="instructions"
Content-Type: application/json

{
  "parts": [
    {
      "file": "document",
      "pages": {
        "start": 0,
        "end": 0
      }
    },
    {
      "file": "document",
      "pages": {
        "start": 1,
        "end": 1
      }
    },
    {
      "file": "document",
      "pages": {
        "start": 1,
        "end": 1
      }
    },
    {
      "file": "document",
      "pages": {
        "start": 2,
        "end": 7
      }
    }
  ]
}
--customboundary--

```

The following example merges three documents and duplicates the second document. The output PDF contains two copies of the pages from the second document, merged with the pages from the other documents in the order that they were specified in in [`instructions.parts`](https://www.nutrient.io/api/reference/document-engine/upstream/#model/BuildInstructions).

### SHELL

```shell

curl -X POST http://localhost:5000/api/build \
  -H "Authorization: Token token=<API token>" \
  -F document1=@/path/to/example-document1.pdf \
  -F document-to-duplicate=@/path/to/example-document-to-duplicate.pdf \
  -F document3=@/path/to/document3.pdf \
  -F instructions='{
  "parts": [
    {
      "file": "document1"
    },
    {
      "file": "document-to-duplicate"
    },
    {
      "file": "document-to-duplicate"
    },
    {
      "file": "document3"
    }
  ]
}' \
  -o result.pdf

```

### HTTP

```http

POST /api/build HTTP/1.1
Content-Type: multipart/form-data; boundary=customboundary
Authorization: Token token=<API token>

--customboundary
Content-Disposition: form-data; name="document1"; filename="example-document1.pdf"
Content-Type: application/pdf

<PDF data>
--customboundary
Content-Disposition: form-data; name="document-to-duplicate"; filename="example-document-to-duplicate.pdf"
Content-Type: application/pdf

<PDF data>
--customboundary
Content-Disposition: form-data; name="document3"; filename="document3.pdf"
Content-Type: application/pdf

<PDF data>
--customboundary
Content-Disposition: form-data; name="instructions"
Content-Type: application/json

{
  "parts": [
    {
      "file": "document1"
    },
    {
      "file": "document-to-duplicate"
    },
    {
      "file": "document-to-duplicate"
    },
    {
      "file": "document3"
    }
  ]
}
--customboundary--

```

## Duplicating pages of a file from a URL

The following example specifies the `document-to-duplicate` part of the multipart request with a URL, instead of with a path to the document on the disk:

### SHELL

```shell

curl -X POST http://localhost:5000/api/build \
  -H "Authorization: Token token=<API token>" \
  -F document1=@/path/to/example-document1.pdf \
  -F document3=@/path/to/document3.pdf \
  -F instructions='{
  "parts": [
    {
      "file": "document1"
    },
    {
      "file": {
        "url": "https://pspdfkit.com/downloads/examples/paper.pdf"
      }
    },
    {
      "file": {
        "url": "https://pspdfkit.com/downloads/examples/paper.pdf"
      }
    },
    {
      "file": "document3"
    }
  ]
}' \
  -o result.pdf

```

### HTTP

```http

POST /api/build HTTP/1.1
Content-Type: multipart/form-data; boundary=customboundary
Authorization: Token token=<API token>

--customboundary
Content-Disposition: form-data; name="document1"; filename="example-document1.pdf"
Content-Type: application/pdf

<PDF data>
--customboundary
Content-Disposition: form-data; name="document3"; filename="document3.pdf"
Content-Type: application/pdf

<PDF data>
--customboundary
Content-Disposition: form-data; name="instructions"
Content-Type: application/json

{
  "parts": [
    {
      "file": "document1"
    },
    {
      "file": {
        "url": "https://pspdfkit.com/downloads/examples/paper.pdf"
      }
    },
    {
      "file": {
        "url": "https://pspdfkit.com/downloads/examples/paper.pdf"
      }
    },
    {
      "file": "document3"
    }
  ]
}
--customboundary--

```

This creates a copy of the first page of a document and places it directly after the first page.
---

## Related pages

- [Remove pages from PDFs](/guides/document-engine/editor/page-manipulation/remove.md)
- [Move or rearrange PDF pages](/guides/document-engine/editor/page-manipulation/move-or-rearrange.md)
- [Rotate PDF pages](/guides/document-engine/editor/page-manipulation/rotate.md)

