GroupDocs.Merger for Python via .NET - Merge, split, reorder and manipulate document pages
Project description
Product Page | Docs | Demos | API Reference | Blog | Free Support | Temporary License
GroupDocs.Merger for Python via .NET is a document-manipulation API for combining and reorganizing documents. Join multiple files into one, split a document into several, and reorder, swap, move, rotate, extract, or remove pages — across Word, Excel, PowerPoint, PDF, Visio, images, eBooks, email, and text formats through one unified API, with no MS Office, OpenOffice, or other external software required. It also manages document passwords, changes page orientation, and renders page previews.
Get Started
pip install groupdocs-merger-net
from groupdocs.merger import Merger
with Merger("document1.docx") as merger:
merger.join("document2.docx")
merger.save("merged.docx")
How It Works
The package is a self-contained Python wheel that bundles the embedded .NET runtime and every native dependency (SkiaSharp, Aspose.Drawing) needed to load, manipulate, and save documents. No external software installation is required — just pip install and start merging. The wheel works across Python 3.5 – 3.14 on Windows, Linux, and macOS (Intel + Apple Silicon).
Features
- Merge / join — combine multiple documents of the same family into one; join whole files, page subsets, or images.
- Split — break a document into multiple files by page list or interval; split text by lines.
- Page management — extract, remove, swap, move, and rotate pages; change page orientation; target odd/even/range subsets.
- Password protection — add, change, or remove document passwords; set PDF owner passwords and permissions.
- Document introspection — read format, page count, size, and per-page dimensions without a full rebuild.
- Page previews — render pages to PNG, JPEG, or BMP via a Python page-stream callback.
- OLE & attachments — embed spreadsheets, presentations, diagrams, and PDF attachments.
- Cross-Platform — Windows x64/x86, Linux x64, macOS x64/ARM64.
Common Tasks
- Merge two or more PDFs (or DOCX, XLSX, PPTX) into a single document
- Split a multi-page document into one file per page or per interval
- Extract a subset of pages, or remove unwanted pages
- Reorder a document: swap two pages, move a page, rotate pages
- Add, change, or remove a password on a document
- Read a file's page count, size, and per-page dimensions before processing
Supported File Formats
For a complete list, see supported formats.
| Category | Formats |
|---|---|
| Word Processing | DOC, DOCX, DOCM, DOT, DOTX, DOTM, ODT, OTT, RTF, TXT |
| Spreadsheets | XLS, XLSX, XLSM, XLSB, XLT, XLTX, XLTM, XLAM, ODS, CSV, TSV |
| Presentations | PPT, PPTX, PPTM, PPS, PPSX, PPSM, POT, POTX, POTM, ODP, OTP |
| Fixed-Layout | PDF, XPS, TEX |
| Visio Diagrams | VSD, VSDX, VSDM, VSS, VSSX, VSSM, VST, VSTX, VSTM, VDX, VSX, VTX |
| Images | BMP, JPG, JPEG, PNG, GIF, TIF, TIFF, SVG, SVGZ, EMF, EMZ |
| eBooks & Web | EPUB, HTML, MHT, MHTML, ONE |
Examples
Merge two documents
from groupdocs.merger import Merger
with Merger("document1.docx") as merger:
merger.join("document2.docx")
merger.save("merged.docx")
Get document info
from groupdocs.merger import Merger
with Merger("document.pdf") as merger:
info = merger.get_document_info()
print("Type:", info.type.file_format)
print("Pages:", info.page_count)
print("Size:", info.size, "bytes")
for page in info.pages:
print(f" page {page.number}: {page.width}x{page.height}")
Split a document into single pages
from groupdocs.merger import Merger
from groupdocs.merger.domain.options import SplitOptions
with Merger("multipage.pdf") as merger:
merger.split(SplitOptions("page_{0}.pdf", [1, 2, 3]))
Extract, remove, and reorder pages
from groupdocs.merger import Merger
from groupdocs.merger.domain.options import (
ExtractOptions, RemoveOptions, SwapOptions, RotateOptions, RotateMode,
)
with Merger("document.pdf") as merger:
merger.extract_pages(ExtractOptions([1, 2, 3])) # keep pages 1-3
merger.swap_pages(SwapOptions(1, 3)) # swap pages 1 and 3
merger.rotate(RotateOptions(RotateMode.ROTATE90, [2]))
merger.save("reordered.pdf")
Add a password
from groupdocs.merger import Merger
from groupdocs.merger.domain.options import AddPasswordOptions
with Merger("document.pdf") as merger:
merger.add_password(AddPasswordOptions("secret"))
merger.save("protected.pdf")
Render page previews
from groupdocs.merger import Merger
from groupdocs.merger.domain.options import PreviewOptions, PreviewMode
def create_page_stream(page_number):
return open(f"page-{page_number}.png", "wb") # return a file/path stream
with Merger("document.pdf") as merger:
merger.generate_preview(PreviewOptions(create_page_stream, PreviewMode.PNG, [1, 2]))
Merge from binary streams
import io
from groupdocs.merger import Merger
with open("document1.pdf", "rb") as src:
with Merger(src) as merger:
with open("document2.pdf", "rb") as tgt:
merger.join(tgt)
buffer = io.BytesIO()
merger.save(buffer) # BytesIO is updated after save
data = buffer.getvalue()
AI Agent & LLM Friendly
This package is designed for seamless integration with AI agents, LLMs, and automated code generation tools.
AGENTS.mdin the package — AI coding assistants (Claude Code, Cursor, GitHub Copilot) auto-discover the API surface, usage patterns, and troubleshooting tips from the installed package- MCP server — connect your AI tool to GroupDocs documentation for on-demand API lookups:
{ "mcpServers": { "groupdocs-docs": { "url": "https://docs.groupdocs.com/mcp" } } }
- Machine-readable docs — full documentation available as plain text for RAG and LLM context:
- Single file:
https://docs.groupdocs.com/merger/python-net/llms-full.txt - Per page: append
.mdto any docs URL
- Single file:
Evaluation Mode
The API works without a license in evaluation mode, with these limitations:
- Output is restricted: PDF output carries an evaluation watermark and other formats show an equivalent evaluation mark.
- A page/document-count cap applies to processed documents.
To remove these limitations, apply a license or request a temporary license:
from groupdocs.merger import License
License().set_license("path/to/license.lic")
Or set the environment variable (auto-applied at import):
export GROUPDOCS_LIC_PATH="path/to/license.lic"
Troubleshooting
| Issue | Platform | Fix |
|---|---|---|
System.Drawing.Common is not supported |
Linux/macOS | apt-get install libgdiplus (Linux) or brew install mono-libgdiplus (macOS) |
The type initializer for 'Gdip' threw an exception |
macOS | brew install mono-libgdiplus |
| Garbled text / missing fonts in output | Linux | apt-get install ttf-mscorefonts-installer fontconfig && fc-cache -f |
DOTNET_SYSTEM_GLOBALIZATION_INVARIANT errors |
Linux | Do NOT set this variable. ICU must be available. |
IncorrectPasswordException / PasswordRequiredException |
All | Open with Merger(path, LoadOptions(password="...")) |
System Requirements
- Python 3.5 - 3.14
- Windows x64/x86, Linux x64, macOS x64/ARM64
- No additional software required
More Resources
Also available for other platforms: .NET | Java | Node.js
Product Page | Docs | Demos | API Reference | Blog | Free Support | Temporary License
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file groupdocs_merger_net-26.6.0-py3-none-win_amd64.whl.
File metadata
- Download URL: groupdocs_merger_net-26.6.0-py3-none-win_amd64.whl
- Upload date:
- Size: 148.6 MB
- Tags: Python 3, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.15
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a92568b800658c8de95908bf8f5cba19f2220fcebbeaa7041e8e3d369f00c4b2
|
|
| MD5 |
2701a46e3db46d721aecf03bffa3c338
|
|
| BLAKE2b-256 |
3b46d30d123a0733830195df7b076b01f6b9a4a92961320ab36b13b2499eed07
|
File details
Details for the file groupdocs_merger_net-26.6.0-py3-none-manylinux1_x86_64.whl.
File metadata
- Download URL: groupdocs_merger_net-26.6.0-py3-none-manylinux1_x86_64.whl
- Upload date:
- Size: 148.4 MB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.15
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2116c0ff861cf7bc7c18b90a6a0d096314b12bc46568380d6a2d54f61fab765c
|
|
| MD5 |
6a1b5d47d3888bcd0189070ac228085d
|
|
| BLAKE2b-256 |
18f70460ac09d8e1d1b56a1767d566d9e4cd1886cc2bf89bb2e6b8f80c4634e6
|
File details
Details for the file groupdocs_merger_net-26.6.0-py3-none-macosx_11_0_arm64.whl.
File metadata
- Download URL: groupdocs_merger_net-26.6.0-py3-none-macosx_11_0_arm64.whl
- Upload date:
- Size: 147.6 MB
- Tags: Python 3, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.15
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
03c85680e87dd2968eb6497d699f3938eab3c6c62589f24b05e8fd2f65872feb
|
|
| MD5 |
2cd2c83e44a650c564219982ccdd7409
|
|
| BLAKE2b-256 |
eb9c38e42444329c1417aaa747ccc7ec91483cab257d56084a90ce8033b20288
|
File details
Details for the file groupdocs_merger_net-26.6.0-py3-none-macosx_10_14_x86_64.whl.
File metadata
- Download URL: groupdocs_merger_net-26.6.0-py3-none-macosx_10_14_x86_64.whl
- Upload date:
- Size: 149.8 MB
- Tags: Python 3, macOS 10.14+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.15
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bd4a4805e4cc05234375b92bdab08217f4be436022c3fb0d8fa34dc32e4ca1b2
|
|
| MD5 |
8ad0a50fca5803246d66637af6a4df91
|
|
| BLAKE2b-256 |
562e04a3b359659646966b3d3a5d7cb230895e65d2c162f9097491b4a9088285
|