Page chunking for RAG ingestion is a GroupDocs.Merger capability for .NET that cuts a Word or PowerPoint file into smaller files along page boundaries, so each piece fits the page or upload limit of a retrieval-augmented generation (RAG) pipeline or an AI tool. A pipeline that accepts four pages per file cannot take a 15-page catalogue as it is, and a deck of six slides will not pass a limit of two. GroupDocs.Merger for .NET offers three ways to get under such a limit, and this guide compares them: a page budget, one file per page, and an extract of chosen pages. Each result is an ordinary DOCX or PPTX file in the format you started with.
Each method is judged by how it picks pages, what it writes to disk and which situation it fits. The console output and file names below come from a licensed run of the sample on GroupDocs.Merger 26.11.0.
What This Guide Covers
The guide compares SplitIntoPageBudget, SplitIntoSinglePages and ExtractPagesForQuestion, three methods of the sample project, for developers who feed Word and PowerPoint documents to a RAG pipeline or an AI tool with page or upload limits.
Prerequisites:
.NET 8 SDK or later and GroupDocs.Merger for .NET 26.11
A Word or PowerPoint file longer than your page budget; the sample uses a 15-page catalogue, a 10-page handbook and a 6-slide deck
Warning
β οΈ Without a licence the library runs in evaluation mode and evaluation limits apply: it reads only the first pages. Get a temporary licence before you judge chunk counts.
Overview: a limit expressed in pages becomes a list of chunk starts, and one Split call writes the chunks.
How It Works
GetDocumentInfo reports the page count, the sample derives the first page of every chunk after the first, and SplitOptions receives them with SplitMode.Interval. When the document already fits, the list is empty and the sample saves the whole file as chunk 0.
A chunk cannot be cited by page without extra bookkeeping
The catalogue reported 15 pages and starts 5, 9 and 13, and wrote four chunks of 4, 4, 4 and 3 pages. The 6-slide deck with a budget of 2 started chunks at 3 and 5 and wrote three PPTX files of 2 slides each. In our run every one of the 420 catalogue rows landed in exactly one chunk, in order, and each of the three later chunks opened with the repeated table header row.
Method 2: One File per Page (SplitIntoSinglePages)
Overview: every page number goes into the list, so each page becomes its own file.
How It Works
SplitOptions without a mode uses SplitMode.Pages, which writes one file for each listed page. The list is built from PageCount, so no page number is typed by hand.
When to Use
β Retrieval returns single pages
β A citation should name a page and open it
β Not when many small files are a problem for your storage
The 10-page handbook produced 10 files, handbook-page_1.docx to handbook-page_10.docx.
Method 3: Extract the Pages One Question Needs (ExtractPagesForQuestion)
Overview: keep chosen pages in a new document and drop the rest, so the model receives a short, focused file.
How It Works
ExtractPages takes the page numbers from ExtractOptions, and Save writes the result in the source format, so a DOCX stays a DOCX. The sample then reopens the saved file and reads its page count as a check.
When to Use
β A retrieval step has already ranked the pages
β The same long document answers many questions
β Not for cutting a whole document into parts
Implementation
stringsourcePath="resources/parts-catalogue.docx";stringoutputPath="output/catalogue-pages-6-7.docx";Directory.CreateDirectory("output");using(varmerger=newMerger(sourcePath)){merger.ExtractPages(newExtractOptions(new[]{6,7}));merger.Save(outputPath);}usingvarextract=newMerger(outputPath);Console.WriteLine($"pages in the extract: {extract.GetDocumentInfo().PageCount}");
Pros and Cons
Advantages:
Smallest input for the model
Works on any page list
Limitations:
Needs the page numbers from somewhere else
Pages 6 and 7 of the catalogue produced catalogue-pages-6-7.docx, and reopening it reported 2 pages.
Side-by-Side Feature Comparison
Feature
Page budget
One file per page
Extract
Output unit
Chunk of several pages
Single page
Chosen pages
Mode or option
SplitMode.Interval
SplitMode.Pages
ExtractOptions
Short document
Saved whole as chunk 0
One file per page
Chosen pages only
Source format kept
Yes
Yes
Yes
Real-World Use Cases
Use Case 1: A catalogue behind a page cap
Challenge: a 15-page catalogue with 420 table rows exceeds a four-page limit. Solution: Method 1. Result: four chunks, with no row lost or repeated.
Use Case 2: A deck behind a slide cap
Challenge: a 6-slide deck exceeds a limit of two. Solution: Method 1 on a PPTX. Result: three files of 2 slides each.
Use Case 3: A question about two pages
Challenge: one answer needs only part of the catalogue. Solution: Method 3. Result: a 2-page document.
Common Pitfalls and How to Avoid Them
Expecting the same file names from both split modes.
Problem:SplitMode.Pages names files by page number starting at 1, while SplitMode.Interval numbers chunks from 0.
Solution: build any lookup from the pattern you passed, not from a guess.
Passing chunk lengths instead of chunk starts.
Problem:SplitMode.Interval cuts at the numbers you list, so lengths cut in the wrong places.
Solution: derive the starts from PageCount, as the sample does.
Judging results from an unlicensed run.
Problem: evaluation limits apply and only the first pages are read.
Solution: apply a temporary licence before comparing chunk counts.
Notes
Page operations on Word documents follow the real Word page layout since GroupDocs.Merger 26.11; the 26.11 release notes describe the earlier behaviour. This guide makes no statement about token counts or about the limits of any particular AI product.
How do I choose between page budgets and single pages?
Choose a page budget when a service caps pages per upload and you want few, larger files. Choose single pages when retrieval should return one page at a time and cite its number. Both use SplitOptions; only the mode and the list of page numbers differ. If you need only a handful of known pages, skip splitting and call ExtractPages.
FAQ
Can the same code cut a PowerPoint file?
Yes. SplitIntoPageBudget cut the 6-slide deck.pptx with the same calls as the Word catalogue.
What happens to a document shorter than the budget?
The list of chunk starts is empty, so the sample saves the whole document as one chunk with the extension taken from info.Type.
Do the chunks stay in the original format?
Yes. GroupDocs.Merger reads and writes DOCX and PPTX in their own format, so a catalogue chunk is a DOCX and a deck chunk is a PPTX.
Conclusion
Pick the method by the limit you face: a page budget for a cap per upload, single pages for page-level citation, an extract for one question. All three use GetDocumentInfo, Split or ExtractPages, and all three keep the source format. Start from the sample repository, swap in your own files and a licence, and compare the chunk counts with your limit.