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

[Feature Request]: Split merged PDF into N-page chunks with custom names from external file

Open omegaatt36 opened this issue 4 months ago • 6 comments

Feature Description

Add support for splitting a PDF into fixed-size chunks (e.g., every N pages) and renaming the output files using a provided external list (e.g., a text file with one name per line).

Example workflow

  1. A Word template is 3 pages long.
  2. After performing a mail merge with 5 datasets, the result is a single 15-page PDF.
  3. The user wants to split this into 5 separate PDF files, each containing 3 pages.
  4. The output filenames should be taken from an external text file (e.g., names.txt), where each line corresponds to the filename for each split file.

So if names.txt contains:

FileA
FileB
FileC
FileD
FileE

The final output would be:

  • FileA.pdf (pages 1–3)
  • FileB.pdf (pages 4–6)
  • FileC.pdf (pages 7–9)
  • FileD.pdf (pages 10–12)
  • FileE.pdf (pages 13–15)

Current behavior

Stirling-PDF supports:

  • Splitting PDFs (per page or automated rules)
  • Auto-renaming output files based on PDF content

I think it is very similar to this https://github.com/Stirling-Tools/Stirling-PDF/issues/223.

However:

  • Auto-rename does not work well for my use case, because Chinese text is often not recognized correctly.
  • Splitting cannot currently be done by fixed N pages.

Why is this feature valuable?

This feature would be useful for scenarios such as:

  • Mail merge workflows (Word → PDF) where each dataset should have its own named PDF.
  • Bulk generation of reports/invoices where filenames are predefined in a list.
  • Workflows involving non-Latin text (e.g., Chinese), where auto-renaming fails.

I solved this with a simple bash script as a workaround, but it would be more convenient and user-friendly if integrated directly into Stirling-PDF.

Suggested Implementation

Proposal

  • Add an option in the split tool to upload/select a text file (one line per filename).
  • Apply those names in order when generating split PDFs.

If the team agrees with this proposal, I’d be happy to implement this feature and submit a PR.

Additional Information

No response

No Duplicate of the Feature

  • [x] I have verified that there are no existing features requests similar to my request.

omegaatt36 avatar Aug 19 '25 03:08 omegaatt36

I would suggest going a step further and implementing the ability to read a mapping between file names and page ranges, something like this:

FileA : 1,2-5,8
FileB : 3,4-8,10

adityaruplaha avatar Aug 24 '25 10:08 adityaruplaha

hello @omegaatt36 , have you started working on this feature or not yet?

mycherif2003-ops avatar Nov 05 '25 09:11 mycherif2003-ops

hello @omegaatt36 , have you started working on this feature or not yet?

Not yet 🥲

omegaatt36 avatar Nov 05 '25 10:11 omegaatt36

Doesn't split-by-size-or-count do this?

Frooodle avatar Nov 05 '25 10:11 Frooodle

AHH sorry missed the names.txt functionality

But the statement "Splitting cannot currently be done by fixed N pages" is incorrect so should have something to base code off

Frooodle avatar Nov 05 '25 10:11 Frooodle

so can i work on this one ? @Frooodle @omegaatt36

mycherif2003-ops avatar Nov 05 '25 10:11 mycherif2003-ops