Delete the last page of any PDF without counting pages

Negative page numbers count from the end: -1 is the last page. Drop trailing pages, keep the last page, or split off a signature page without knowing the count.

The last page, counted as -1 from the end, is removed without knowing the page count

Many PDF jobs are about the end of the document: an ad page a generator appends, a blank trailing page, a signature page you need on its own. The page number changes with every file, so a fixed number does not work. Negative page numbers do.

-1 is always the last page

In every JustAPI page tool, a negative number counts from the end. -1 is the last page, -2 the one before it. Ranges work too: -3--1 is the last three pages.

Recipes

Delete the last page, whatever the length, with the remove pages API:

curl https://api.justapi.tech/v1/pdf/remove-pages \
  -H "Authorization: Bearer ak_live_..." \
  -H "Content-Type: application/json" \
  -d '{"source": {"url": "https://files.example.com/generated.pdf"}, "options": {"pages": "-1"}}'

Delete the last two pages: "pages": "-2--1".

Keep only the last page, for a signature page, with extract pages: "pages": "-1".

Move the last page to the front with organize: "order": [-1, "1--2"].

What if the file is too short?

If -3 points before page 1, because the file has only two pages, the call fails with invalid_request and names the page. Nothing is charged. If your list would remove every page, the call is refused the same way, because a PDF needs at least one page.

In no-code tools

The page list is a string, so -1 goes in as text: "pages": "-1". In Bubble's API Connector, keep the quotes in the JSON body so it is not sent as a number. A number also works: "pages": -1.

Try it on a file with the free page remover: type -1 in the Pages box.