This sample demonstrates how to split a SFDT or DOCX document into multiple documents based on Bookmarks or Headings using the Syncfusion® React DOCX Editor (Document Editor).
The application loads a Word document, identifies all bookmarks and headings available in the document, extracts the corresponding content for each bookmark or heading, and generates a separate document for every extracted section. The generated documents are displayed in a categorized list, allowing users to preview, print, and download each extracted document individually.
This sample is useful for scenarios such as:
- Splitting a Word document into separate documents based on bookmarks.
- Splitting a Word document into separate documents based on headings.
- Load a SFDT or DOCX document into the Syncfusion React DOCX Editor.
- Split the document based on Bookmarks.
- Split the document based on Headings.
- Retrieve all bookmarks and heading hierarchy from the document.
- Generate an independent document for each extracted bookmark or heading section.
- Display extracted documents in a categorized list.
- Preview extracted documents in a read-only Document Editor.
- Download extracted documents in multiple formats:
- DOCX
- SFDT
- DOTX
- TXT
- Print extracted documents directly from the preview dialog.
Ensure the following software is installed before running the sample.
- Node.js (v18 or later recommended)
- npm
git clone <repository-url>cd <project-folder>npm installnpm startOpen your browser and navigate to:
http://localhost:3000
The sample automatically loads a Word document into the Syncfusion React DOCX Editor.
Choose one of the available split operations:
- Split Bookmarks – Extracts the content enclosed within each bookmark and generates a separate document for every bookmark.
- Split Headings – Extracts document sections based on headings and generates a separate document for each heading.
The sample performs the following steps:
-
Loads a Microsoft Word document into the Syncfusion React DOCX Editor.
-
The user selects one of the available split operations:
- Split Bookmarks
- Split Headings
-
Based on the selected operation:
- Split Bookmarks retrieves all bookmarks from the document.
- Split Headings retrieves all document headings along with their hierarchical structure.
-
The application iterates through each bookmark or heading and extracts the corresponding document content as an independent SFDT document.
-
Each extracted document is stored in memory together with its associated bookmark or heading name.
-
The generated documents are displayed in a categorized list for easy navigation.
-
Selecting an item from the list opens the corresponding document in a read-only Syncfusion Document Editor for preview.
-
Users can then:
- Preview the extracted document
- Print the document
- Download the document in one of the supported formats:
- DOCX
- SFDT
- DOTX
- TXT
---
Load Word Document (SFDT or DOCX)
│
▼
Open in Syncfusion Document Editor
│
▼
User Chooses Split Operation
┌───────────────────────┐
│ │
▼ ▼
Split by Bookmarks Split by Headings
│ │
▼ ▼
Retrieve All Bookmarks Retrieve All Headings
│ │
▼ ▼
Iterate Through Items (Bookmark/Heading)
│
▼
Extract Section as SFDT Document
│
▼
Store Generated Documents in Memory
│
▼
Display Extracted Document List
│
▼
User Selects a Document
│
▼
Preview in Read-only Document Editor
│
┌───────────┴───────────┐
▼ ▼
Print Document Download Document
(DOCX / SFDT / DOTX / TXT)
-
Product page: Syncfusion® React DOCX Editor
-
Documentation: Syncfusion® React DOCX Editor - Documentation
-
Online demo: Syncfusion® React DOCX Editor - Online demo
For any other queries, reach our Syncfusion® support team or post the queries through the community forums.
Request new feature through Syncfusion® feedback portal.
This is a commercial product and requires a paid license for possession or use Syncfusion's licensed software, including this component, is subject to the terms and conditions of Syncfusion's EULA. You can purchase a licnense here or start a free 30-day trial here.
