Stirling-PDF icon indicating copy to clipboard operation
Stirling-PDF copied to clipboard

[Bug]: API split-pages does not respect pageNumbers

Open arty-hlr opened this issue 3 months ago • 2 comments

Installation Method

Local Installation

The Problem

When using /api/v1/general/split-pages with a range in the pageNumbers parameter, the files in the resulting zip files do not respect the given range. For example, giving "11-13" will generate 4 files:

  • pages 1-11
  • page 12
  • page 13
  • pages 14 to 465

Expected behavior would be like /extract-page in the web GUI, which extracts a single pdf containing pages 11-13.

Version of Stirling-PDF

0.46.1

Last Working Version of Stirling-PDF

No response

Page Where the Problem Occurred

http://localhost:8080/api/v1/general/split-pages

Docker Configuration


Relevant Log Output


Additional Information

No response

Browsers Affected

No response

No Duplicate of the Issue

  • [x] I have verified that there are no existing issues raised related to my problem.

arty-hlr avatar Sep 07 '25 10:09 arty-hlr

The behavior you're seeing from the /api/v1/general/split-pages endpoint is actually by design. This API splits the PDF at the specified page numbers, so entering a range like "11-13" results in separate files for each segment between those split points, not a single PDF containing just pages 11-13. This matches the documented and implemented logic for splitting PDFs in Stirling-PDF, where the numbers are treated as split points, not as a continuous extraction range (docs).

If you want to extract a single PDF containing a specific page range (like pages 11-13), use the "extract-page" feature in the web GUI, which is designed for that purpose (extract-page). The API and GUI use different logic paths for these features, which is why their behavior differs.

If you need to automate extracting a range via API, this would require a different endpoint or a feature request for API parity with the GUI's extract-page functionality.

To reply, just mention @dosu.


How did I do? Good | Irrelevant | Incorrect | Verbose | Hallucination | Report 🐛 | Other  Chat with Dosu Join Discord Share on X

dosubot[bot] avatar Sep 07 '25 10:09 dosubot[bot]

Are you expecting split to function the same as extract with no differences?

Frooodle avatar Sep 07 '25 11:09 Frooodle

I see that it corresponds to /split-pdfs though and there's not endpoint for /extract-page. My bad but it seemed to be the only corresponding endpoint, the description was ambiguous to me, and I wasn't aware of /split-pdfs. Then I guess this issue is asking for 2 things:

  • reword of the description of /general/split-pages to include that it will be split on each of the pages given as input (in contrast for example the info on the /split-pdfs page is very clear)
  • an API endpoint corresponding to /extract-page

Should I make a feature request for the 2nd point? Can the 1st minor point be part of this issue or should it be a new one?

arty-hlr avatar Sep 08 '25 07:09 arty-hlr

Extract pages uses the rearrange pages endpoint

As functionality is the same

Frooodle avatar Sep 08 '25 08:09 Frooodle

That's very very unclear, I'm not sure how one could understand from the name or description that /general/rearrange-pages provides the same functionality as /extract-page. Overall it's a naming and description issue to be honest. Then I guess at least the description for the endpoint should mention that it can do the same.

arty-hlr avatar Sep 08 '25 08:09 arty-hlr