Duplicate PDF Pages in Linux

PSPDFKit Processor lets you duplicate pages of a document using the duplicatePages operation.

Before you get started, make sure Processor is up and running.

Duplicating Pages of a File on Disk

Send a request to the /process endpoint, attaching an input file and the operations JSON:

curl -X POST http://localhost:5000/process \
  -F file=@/path/to/example.pdf \
  -F operations='{
  "operations": [
    {
      "type": "duplicatePages",
      "pageIndexes": [
        "first"
      ]
    }
  ]
}' \
  -o result.pdf
POST /process HTTP/1.1
Content-Type: multipart/form-data; boundary=customboundary

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

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

{
  "operations": [
    {
      "type": "duplicatePages",
      "pageIndexes": [
        "first"
      ]
    }
  ]
}
--customboundary--

This will create a copy of the first page of a document and place it directly after the first page.

Duplicating Pages of a File from a URL

Send a request to the /process endpoint, attaching a URL pointing to an input file and the operations JSON:

curl -X POST http://localhost:5000/process \
  -F url=https://pspdfkit.com/downloads/examples/paper.pdf \
  -F operations='{
  "operations": [
    {
      "type": "duplicatePages",
      "pageIndexes": [
        "first"
      ]
    }
  ]
}' \
  -o result.pdf
POST /process HTTP/1.1
Content-Type: multipart/form-data; boundary=customboundary

--customboundary
Content-Disposition: form-data; name="url"

https://pspdfkit.com/downloads/examples/paper.pdf
--customboundary
Content-Disposition: form-data; name="operations"
Content-Type: application/json

{
  "operations": [
    {
      "type": "duplicatePages",
      "pageIndexes": [
        "first"
      ]
    }
  ]
}
--customboundary--

This will create a copy of the first page of a document and place it directly after the first page.