Move, duplicate or drop pages: PDF page order recipes

Copy-paste page order lists for common jobs: move the cover to the end, reverse a PDF, interleave scanned fronts and backs, and repeat a page. One API call each.

A cover page moved from the front of the document to the end

The PDF Organize API takes one list of page numbers. Here are the lists for the jobs people ask about most. Each one is a single call with options.order.

Move the cover to the end

{ "order": ["2-", 1] }

Pages 2 to the end, then page 1.

Move the last page to the front

{ "order": [-1, "1--2"] }

-1 is the last page and 1--2 is page 1 to the second to last. This works without knowing the page count.

Reverse the whole document

{ "order": ["-1-1"] }

A range that runs backwards, from the last page to the first, gives the pages in reverse. Useful when a scanner fed the stack upside down.

Interleave fronts and backs

A one-sided scanner scans all the fronts, then you flip the stack and it scans all the backs, in reverse. For 5 sheets, the file has fronts on pages 1 to 5 and backs on pages 10 down to 6. The right order is:

{ "order": [1, 10, 2, 9, 3, 8, 4, 7, 5, 6] }

Build this list in code: for sheet i from 1 to n, add i, then 2n + 1 - i.

Repeat a page

{ "order": [1, 2, 3, 1] }

The cover appears at the start and the end. Repeating a page copies it, so the file grows by that page's size.

Drop pages while reordering

Leave them out. [3, 1] on a 3-page file drops page 2. If you only drop pages, the remove pages API reads more clearly in code.

Check the result

The response includes stats.pages and stats.source_pages. Compare them with the length of your list to catch a mistake before you send the file on.

Every list here also works in the free page organizer: type the numbers separated by commas.